Boxplot with datetime x-axis

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Markus
Newbie
Newbie
Posts: 6
Joined: Fri Jun 15, 2007 12:00 am

Boxplot with datetime x-axis

Post by Markus » Tue Jul 03, 2007 3:59 pm

Hi to all,

I'm looking for a possibility to display a boxplot with a customized x-axis, for example for datetime entries.

Example:
DATE VALUES
01.01.07 10:00:00 0
01.01.07 10:00:00 2
01.01.07 10:00:00 3
...
01.01.07 10:00:00100

04.01.07 19:00:00 2
04.01.07 19:00:00 4
..
04.01.07 19:00:00 3

Now I would need two separate boxplots for the entries of VALUES, one for 01.01.07 10:00:00 and one for 04.01.07 19:00:00. I only found a position property which is an integer.

I would be grateful for any hint.

Regards,
Markus

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

Post by Narcís » Wed Jul 04, 2007 10:40 am

Hi Markus,

One way to achieve what you request is using something like this:

Code: Select all

uses DateUtils;

procedure TForm1.FormCreate(Sender: TObject);
begin
  With Series1 do
  begin
    AddArray([3,6,8,15,19,21]);
    Position:=EncodeDateTime(07,01,01,10,0,0,0);
  end;

  With Series2 do
  begin
    AddArray([23,42,28,65,79,91]);
    Position:=EncodeDateTime(04,01,07,19,0,0,0);
  end;

  Chart1.Axes.Bottom.AxisValuesFormat:='';
end;

procedure TForm1.Chart1GetAxisLabel(Sender: TChartAxis;
  Series: TChartSeries; ValueIndex: Integer; var LabelText: String);
begin
  if Sender=Chart1.Axes.Bottom then
    LabelText:=DateTimeToStr(StrToFloat(LabelText));
end;
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

Markus
Newbie
Newbie
Posts: 6
Joined: Fri Jun 15, 2007 12:00 am

Post by Markus » Thu Jul 05, 2007 12:21 pm

Hi Narcis,

great, that helped.

Now I want to add several boxplots dynamicallyand assign a OnMouseenter event:

procedure TForm1.Button3Click(Sender: TObject);
var aBoxSeries : TBoxSeries;
i : integer;
begin
DBChart1.RemoveAllSeries;
DBChart1.FreeAllSeries;

for i := 0 to 2 do
begin
aBoxSeries := TBoxSeries.Create(self);
aBoxSeries.AddArray([3,6,8,15,19,21]);
aBoxSeries.OnMouseEnter := Series1MouseEnter;
aBoxSeries.Cursor := crHandPoint;
aBoxSeries.ParentChart := DBChart1;
aBoxSeries.Title := 'Boxplot' + IntToStr(i);

aBoxSeries.Position := i;
DBChart1.AddSeries(aBoxseries);
DBChart1.Checkdatasource(aBoxSeries);
end;
end;

procedure TForm1.Series1MouseEnter(Sender: TObject);
begin
if sender is TBoxSeries then
begin
Form1.Caption := 'Entered: ' + (Sender as TBoxSeries).Title + ' position: ' +
FloatToStr((Sender as TBoxSeries).position);
end;
end;

procedure TForm1.DBChart1ClickSeries(Sender: TCustomChart; Series: TChartSeries;
ValueIndex: Integer; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
self.Caption := 'Clicked on ' + Series.Title;
end;


But if i point to any boxplot, i get "Entered Boxplot0 Position0" instead of the correct position and if i Click a boxplot I always get "Clicked on Boxplot2"

What did I do wrong?

Regards,

Markus

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

Post by Narcís » Thu Jul 05, 2007 1:53 pm

Hi Markus,

There seems to be a problem with TBoxSeries' Clicked method as code below doesn't work fine either.

Code: Select all

procedure TForm1.DBChart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
var i: Integer;
begin
  for i:=0 to DBChart1.SeriesCount-1 do
    if DBChart1[i].Clicked(X,Y) <> -1 then
    begin
      Form1.Caption := 'Entered: ' + DBChart1[i].Title + ' position: ' + 
        FloatToStr((DBChart1[i] as TBoxSeries).position);

      break;
    end;
end;

procedure TForm1.DBChart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
var i: Integer;
begin
  for i:=0 to DBChart1.SeriesCount-1 do
    if DBChart1[i].Clicked(X,Y) <> -1 then
      self.Caption := 'Clicked on ' + DBChart1[i].Title;
end;
I've added this defect (TV52012319) to our bug list to be fixed for future releases.
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

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Fri Jul 06, 2007 5:40 pm

Hi.

Thanks for reporting this one. The TCustomBoxPlot series does not yet implement Clicked method. We'll try to improve this in future.
Marjan Slatinek,
http://www.steema.com

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

Post by Narcís » Wed Sep 19, 2007 10:58 am

Hi Markus,

Clicked method for BoxPlot series has been implemented in TeeChart Pro v8.01 which has posted last weekend at the client download area.
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