[英]How do I automatically update a chart when a table gets a new record?
Suppose I have a table with a colour field — red/white/blue — and every time my app receives an event over TCP/IP and inserts a new row into the database, I want a data-aware pie chart component to auto-update showing the ratio of those colours. 假设我有一个带有颜色字段(红色/白色/蓝色)的表,并且每次我的应用程序通过TCP / IP接收到一个事件并将新行插入数据库时,我都希望有一个数据感知的饼图组件自动更新显示这些颜色的比例。 How can I do that?
我怎样才能做到这一点?
I've seen examples of data-aware components, but they just show the value of each row of a table (I haven't gotten too far yet). 我已经看到了数据感知组件的示例,但是它们只是显示表的每一行的值(我还没有走太远)。 In fact, I am not even sure that adding another row in the database will add another row to the DB-aware grid (push, as opposed to pull).
实际上,我什至不确定在数据库中添加另一行是否会将另一行添加到支持DB的网格(推式,而不是拉式)。
I am not even sure that adding another row in the database will add another row to the DB aware grid (push, as opposed to pull).
我什至不确定在数据库中添加另一行是否会将另一行添加到DB感知网格(推式,而不是拉式)。
If the dataset is live
, adding a row to the dataset will update the grid. 如果数据集是
live
,则向数据集添加一行将更新网格。
Look, let's just imagine that I have a table who's primary key is a colour - red/white/blue - and every time my app receives an event over TCP/IP and inserts a new row into the database I want a data-aware pie chart component to auto-update showing the ratio of those colours.
看,让我们想象一下,我有一个主键是颜色的表-红色/白色/蓝色-每次我的应用程序通过TCP / IP接收事件并将新行插入数据库时,我都希望有一个数据感知派图表组件自动更新以显示这些颜色的比率。
Connection
to your form, set it up so it connects to your database. Connection
添加到您的表单,进行设置以使其连接到您的数据库。 connection
active
property to true
connection
active
属性设置为true
connection1
connection1
sql
property to SELECT (count(*) / b.totalcount) as percentage, b.totalcount FROM table1 a CROSS JOIN (select count(*) as totalcount from table1) b GROUP BY a.color
sql
属性设置为SELECT (count(*) / b.totalcount) as percentage, b.totalcount FROM table1 a CROSS JOIN (select count(*) as totalcount from table1) b GROUP BY a.color
active
property to true
active
属性设置为true
datasource
on the form, set its dataset
to query1
datasource
,将其dataset
设置为query1
datasource
to datasource1
datasource
datasource1
设置为datasource1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.