How to build more than one legend on the same dbchart
Posted: Tue Dec 12, 2006 1:32 am
Hi
I have two problem ( delphi7 and TeeChart7.07):
1. How to build more than one legend on the same dbhart ,and can move the legend to anywhere on the dbchart according to custom needs run time, becuse I have four groups series on the dbchart, every group series include about 10 LineSeries, and want to arrange the four groups series on four different legend.
2. When I link dbchart LineSeries to a sql table ,why do not change the dbchart bottomaxis Increment property to "Increment:=DateTimeStep[dtOneYear]" runtime?
I have the picture of the Result runtime,but I do not know how to send here.
I have two problem ( delphi7 and TeeChart7.07):
1. How to build more than one legend on the same dbhart ,and can move the legend to anywhere on the dbchart according to custom needs run time, becuse I have four groups series on the dbchart, every group series include about 10 LineSeries, and want to arrange the four groups series on four different legend.
2. When I link dbchart LineSeries to a sql table ,why do not change the dbchart bottomaxis Increment property to "Increment:=DateTimeStep[dtOneYear]" runtime?
I have the picture of the Result runtime,but I do not know how to send here.
Code: Select all
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, ADODB, TeEngine, Series, StdCtrls, ExtCtrls, TeeProcs,
Chart, DBChart;
type
TForm1 = class(TForm)
DBChart1: TDBChart;
ADOQuery1: TADOQuery;
Button1: TButton;
Series1: TLineSeries;
ADOConnection1: TADOConnection;
Chart1: TChart;
ADOQuery2: TADOQuery;
Series2: TLineSeries;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses math;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var dd:TDatetime;
y:double;
begin
ADOQuery1.Close;
ADOQuery1.SQL.Text:='select ValDate,e from tb_0001 order by ValDate';
series1.XLabelsSource:='ValDate';
series1.YValues.ValueSource:='e';
series1.Clear;
ADOQuery1.Open;
DBChart1.BottomAxis.Increment:=DateTimeStep[dtOneYear];
DBChart1.BottomAxis.MinorTickCount:=11;
DBChart1.BottomAxis.DateTimeFormat:='YYYY';
ADOQuery2.Close;
ADOQuery2.SQL.Text:='select ValDate,sigma from tb_0002 order by ValDate';
ADOQuery2.Open;
Series2.Clear;
while not ADOQuery2.Eof do
begin
dd:=ADOQuery2.Fields[0].AsDateTime;
y:=ADOQuery2.Fields[1].Value;
Series2.AddXY(dd,y);
ADOQuery2.next;
end;
Chart1.BottomAxis.Increment:=DateTimeStep[dtOneYear];
Chart1.BottomAxis.MinorTickCount:=11;
Chart1.BottomAxis.DateTimeFormat:='YYYY';
end;
end.