delphi 图表 控件_将基本图表集成到Delphi应用程序中

仉英朗
2023-12-01

delphi 图表 控件

In most modern database applications some kind of graphical data representation is preferable or even required. For such purposes, Delphi includes several data-aware components: DBImage, DBChart, DecisionChart, etc. The DBImage is an extension to an Image component that displays a picture inside a BLOB field. Chapter 3 of this database course discussed displaying images (BMP, JPEG, etc.) inside an Access database with ADO and Delphi. The DBChart is a data-aware graphic version of the TChart component.

在大多数现代数据库应用程序中,某些图形数据表示形式是可取的,甚至是必需的。 为此, Delphi包含几个数据感知组件:DBImage,DBChart,DecisionChart等。DBImage是Image组件的扩展,该组件在BLOB字段内显示图片。 本数据库课程的第3章讨论了如何使用ADO和Delphi在Access数据库中显示图像(BMP,JPEG等)。 DBChart是TChart组件的数据感知图形版本。

Our goal in this chapter is to introduce the TDBChart by showing you how to integrate some basic charts into your Delphi ADO based application.

本章的目标是通过向您展示如何将一些基本图表集成到基于Delphi ADO的应用程序中来介绍TDBChart。

发球图 ( TeeChart )

The DBChart component is a powerful tool for creating database charts and graphs. It is not only powerful but also complex. We won't be exploring all of its properties and methods, so you'll have to experiment with it to discover all that it is capable of and how it can best suit your needs. By using the DBChart with the TeeChart charting engine you can quickly make graphs directly for the data in datasets without requiring any code. TDBChart connects to any Delphi DataSource. ADO recordsets are natively supported. No additional code is required—or just a little as you'll see. The Chart editor will guide you through the steps to connect to your data—you don't even need to go to the Object Inspector.

DBChart组件是用于创建数据库图表和图形的强大工具。 它不仅功能强大,而且复杂。 我们不会探索其所有属性和方法,因此您将不得不对其进行试验以发现其所有功能以及如何使其最适合您的需求。 通过将DBChart与TeeChart图表引擎一起使用,您可以快速为数据集中的数据直接创建图形,而无需任何代码。 TDBChart连接到任何Delphi数据源。 本地支持ADO记录集。 不需要其他代码,或者只需要一点即可。 图表编辑器将指导您完成连接数据的步骤,您甚至无需进入对象检查器。

Runtime TeeChart libraries are included as part of Delphi Professional and Enterprise versions. TChart is also integrated with QuickReport with a custom TChart component on the QuickReport palette. Delphi Enterprise includes a DecisionChart control in the Decision Cube page of the Component palette.

运行时TeeChart库是Delphi Professional和Enterprise版本的一部分。 TChart还通过QuickReport面板上的自定义TChart组件与QuickReport集成。 Delphi Enterprise在“组件”面板的“决策多维数据集”页面中包含一个DecisionChart控件。

准备图表 ( Preparing to Chart )

Our task will be to create a simple Delphi form with a chart filled with values from a database query. To follow along, create a Delphi form as follows:

我们的任务将是创建一个简单的Delphi表单,其中的图表填充了数据库查询中的值。 接下来,创建一个Delphi表单,如下所示:

1. Start a new Delphi Application—one blank form is created by default. 

1.启动一个新的Delphi应用程序-默认情况下会创建一个空白表格。

2. Place the next set of components on the form: ADOConnection, ADOQuery, DataSource, DBGrid, and a DBChart. 

2.将下一组组件放在窗体上:ADOConnection,ADOQuery,DataSource,DBGrid和DBChart。

3. Use the Object Inspector to connect ADOQuery with ADOConnection, DBGrid with DataSource with ADOQuery. 

3.使用对象检查器将ADOQuery与ADOConnection相连接,将DBGrid与DataSource与ADOQuery相连接。

4. Set up a link with our demo database (aboutdelphi.mdb) by using the ConnectionString of the ADOConnection component. 

4.使用ADOConnection组件的ConnectionString建立与我们的演示数据库(aboutdelphi.mdb)的链接。

5. Select the ADOQuery component and assign the next string to the SQL property:

5.选择ADOQuery组件,然后将下一个字符串分配给SQL属性:


SELECT TOP 5 customer.Company,
SUM(orders.itemstotal) AS SumItems,
COUNT(orders.orderno) AS NumOrders
FROM customer, orders
WHERE customer.custno = orders.custno
GROUP BY customer.Company
ORDER BY SUM(orders.itemstotal) DESC
This query uses two tables: orders and customer. Both tables were imported from the (BDE/Paradox) DBDemos database to our demo (MS Access) database. This query results in a recordset with only 5 records. The first field is the Company name, the second (SumItems) is a sum of all the orders made by the company and the third field (NumOrders) represents the number of orders that were made by the company. Note that those two tables are linked in a master-detail relationship.

6. Create a persistent list of database fields. (To invoke the Fields Editor double click the ADOQuery component. By default, the list of fields is empty. Click Add to open a dialog box listing the fields retrieved by the query (Company, NumOrders, SumItems). By default, all fields are selected. Select OK.) Even though you don't need a persistent set of fields to work with a DBChart component - we'll create it now. The reasons wi
6.创建数据库字段的持久列表。 (要调用字段编辑器,请双击ADOQuery组件。默认情况下,字段列表为空。单击“添加”以打开一个对话框,其中列出了查询所检索的字段(公司,NumOrders,SumItems)。默认情况下,所有字段都是即使您不需要持久的字段集来使用DBChart组件,我们现在也将创建它。 无线的原因

7. Set ADOQuery.Active to True in the Object Inspector to see the resulting set at design time. 

7.在对象检查器中将ADOQuery.Active设置为True,以在设计时查看结果集。

翻译自: https://www.thoughtco.com/integrating-basic-charts-into-delphi-4077445

delphi 图表 控件

 类似资料: