DelphiLearn PythonPythonPython GUIRAD StudioWindows

Tutorial: Generate Python Dummy Data And Plot It To Enterprise-Grade Delphi TChart

blogbanner3 25

In this tutorial, we will learn about how to do data visualizations using Delphi’s TChart or TeeChart.

TChart is the 100% Native Data-Aware Charting Component Library for Delphi and C++ Builder (v5 and later) and all RAD Studio versions.

 

1. Generate the Dummy Data with Python

To create dummy data in Python, you can use pandas or the Faker library.

Here is the easiest way to create dummy data using pandas, and export them to CSV:

By default, it will create 30 rows with columns called A, B, C, and D and the index alpha-numeric. Run the code above in your favorite Python IDE (for me, it’s PyScripter, because it’s lightweight), you will get the following result:

1 6 3191024

The result:

1 7 4081770

Or you can try Faker, to generate more sophisticated data, with this code:

The code above will generate dummy data with various Python data types and 1000 rows of observations in total:

1 9 8391501

 

2. How can we use TChart?

The TChart component is the basic building block for ‘non-database-aware’ Charts.

First, start an empty VCL app, by navigating to File -> New -> Windows VCL Application – Delphi:

1 3 5233832

Select the TChart component from the Delphi palette and simply drag it onto your form to include a Chart in your application:

1 4tchart 5567600

This is how TChart will look like in your empty VCL:

1 5 9042671

You can edit the chart by double-click the TChart component. For example, you can add new data series, by navigating to Series > Add > Choose the chart as you need:

2 0 6585783
2 02 2503253

You can easily create enterprise-grade plots using the Import option or TDataImport class. Using this functionality, you can seamlessly plot any data from any sources, like .CSV files, SQLs, JSON, the dataset from URLs, and many more. Unfortunately, this feature only available in TChart Pro, so I strongly recommend you to try TChart Pro which offers hundreds of Graph styles in 2D and 3D for data visualization, 56 mathematical, statistical, and financial Functions for you to choose from together with an unlimited number of axes and 30 Palette components. Visit this link, this tutorial, or this video for more information.

So, for this tutorial, we need to input our data, and create our data series manually. In Series, go to Data Source by double-clicking the Series, and change Random to Manual.

2 1adddata 6671121

Now, you can input our dummy data generated by Pandas. In this example, I input 4 data series with 10 rows of observations:

2 1adddata2 7145307

This is how our data visualized in TChart’s Bar Chart:

2 3 9150516

This is how our data visualized in TChart’s Line Chart:

2 4 1356814

Congratulations! You have learn how to visualize Python’s data using Delphi’s TChart!

Check out Python4Delphi which easily allows you to build Python GUIs for Windows using Delphi.

Related posts
CodeIDELearn PythonPythonPython GUITkinter

How To Make More Than 20 ChatGPT Prompts Work With Python GUI Builders And Matplotlib Library?

CodeIDELearn PythonPythonPython GUITkinter

How To Make More Than 20 ChatGPT Prompts Work With Python GUI Builders And Pillow Library?

CodeDelphiDelphiFMXLearn PythonProjectsPythonPython GUI

How To Create A Weather App With The Python Delphi Ecosystem and Weatherstack API

CodeDelphiDelphiFMXLearn PythonProjectsPythonPython GUI

How To Create A Music Player With The Python Delphi Ecosystem

Leave a Reply

Your email address will not be published. Required fields are marked *