急问:关于 TDBChart (200分)

L

liuyy

Unregistered / Unconfirmed
GUEST, unregistred user!
[:)]请教:如何用Delphi动态实现控件TDBChart中
TBarSeries和TLineSeries两种类型的图形根据不同的数据集生成及转换?

本人已经写了一部分代码,但遇到的问题是:
直方图无论什么样的数据集都可以在两种图形转换中正常显示,
线图出现转换时无法显示的情况,是为什么?

//******直方图
if strWhichChar='1' then
begin
MySeriesBarPlan:=TBarSeries.Create( Self );
With MySeriesBarPlan do
begin
Title:='计划';
SeriesColor :=clGreen;
ParentChart:=Dbch_MoneyPlan;
DataSource:=adoq_chart;
Marks.Style :=smsValue;
XLabelsSource:=strXLabel;
YValues.ValueSource:= 'Sum_PlanMoney';
end;

MySeriesBarFact:=TBarSeries.Create( Self );
With MySeriesBarFact do
begin
Title:='实际';
SeriesColor :=clRed;
MySeriesBarFact.
ParentChart:=Dbch_MoneyPlan;
DataSource:=adoq_chart;
Marks.Style :=smsValue;
XLabelsSource:=strXLabel;
YValues.ValueSource:= 'Sum_FactMoney';
end;
end;

//******线图
if strWhichChar='2' then
begin
MySeriesLinPlan:=TLineSeries.Create( Self );
With MySeriesLinPlan do
begin
Title:='计划';
SeriesColor :=clGreen;
ParentChart:=Dbch_MoneyPlan;
DataSource:=adoq_chart;
Marks.Style :=smsValue;
XLabelsSource:=strXLabel;
YValues.ValueSource:= 'Sum_PlanMoney';
end;

MySeriesLinFact:=TLineSeries.Create( Self );
With MySeriesLinFact do
begin
Title:='实际';
SeriesColor :=clRed;
ParentChart:=Dbch_MoneyPlan;
DataSource:=adoq_chart;
Marks.Style :=smsValue;
XLabelsSource:=strXLabel;
YValues.ValueSource:= 'Sum_FactMoney';
end;
end;
 
啊!这个,我也想知道,把分分了吧
 
加两个series ,当调用一个时 ,另一个active:=false
 
继续请教ugvanxk:
实现前提:我的Chart需要的数据集是在程序中动态生成的两组值,计划数和实际数,
而不是程序执行前Chart可以事先绑定好的。
具体的解释是:Chart无论是直方图显示,还是线形显示,每种图形显示时都需要
同时显示上述两组数据状况,即实现的是直方图(两组数据)和
线形图(两组数据)的转换。所以,事先无法加入固定的Series。
不知道我说的是否清楚,请再予以回答。
谢谢!

 
多人接受答案了。
 
顶部