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.

close
Related posts
DelphiDelphiVCLPythonPython GUIWindows

What is DelphiVCL.Application.CreateHandle?

DelphiDelphiVCLPythonPython GUIWindows

Creating A New Application With DelphiVCL.Application.Create

DelphiDelphiVCLPythonPython GUIWindows

All You Need To Know About Application.DialogHandle

DelphiDelphiVCLPythonPython GUIWindows

What is the FieldAddress Property in DelphiVCL.Application?

Deixe uma resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

pt_BRPortuguese