Page 1 of 1
Boxplot with datetime x-axis
Posted: Tue Jul 03, 2007 3:59 pm
by 9245552
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
Posted: Wed Jul 04, 2007 10:40 am
by narcis
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;
Posted: Thu Jul 05, 2007 12:21 pm
by 9245552
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
Posted: Thu Jul 05, 2007 1:53 pm
by narcis
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.
Posted: Fri Jul 06, 2007 5:40 pm
by Marjan
Hi.
Thanks for reporting this one. The TCustomBoxPlot series does not yet implement Clicked method. We'll try to improve this in future.
Posted: Wed Sep 19, 2007 10:58 am
by narcis
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.