How to build more than one legend on the same dbchart

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
hexfhhu
Newbie
Newbie
Posts: 21
Joined: Thu Dec 07, 2006 12:00 am

How to build more than one legend on the same dbchart

Post by hexfhhu » 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.

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.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Dec 12, 2006 2:59 pm

Hi hexfhhu,

1. Please see Pep's reply at your other thread.

2. Axes will be scaled according to the given increment provided the requested label scaling fits on the axis. Otherwise labels increment automatically increases to fit in the axis.

Anyway, you can try forcing that using:

Code: Select all

  Chart1.Axes.Bottom.LabelsSeparation:=0; 
Setting LabelsSeparation to zero is the extrem case to force as many labels as possible being drawn. You can try "playing" a little bit with this property setting it to small values that produce the labels as you expect.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply