TBoxSeries add last value

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
nh128
Newbie
Newbie
Posts: 3
Joined: Mon Jul 01, 2013 12:00 am

TBoxSeries add last value

Post by nh128 » Mon Nov 03, 2014 1:45 am

How can I add the last observation to a Box Plot Chart?

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TBoxSeries add last value

Post by Yeray » Mon Nov 03, 2014 1:23 pm

Hello,

You could have a TPointSeries with a single value you update each time a new point is added to the TBoxSeries. Ie:

Code: Select all

uses TeeBoxPlot, Series;

var BoxPlot: TBoxSeries;
    LastPoint: TPointSeries;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;

  BoxPlot:=Chart1.AddSeries(TBoxSeries) as TBoxSeries;
  BoxPlot.FillSampleValues;

  LastPoint:=Chart1.AddSeries(TPointSeries) as TPointSeries;
  LastPoint.AddXY(0, BoxPlot.YValue[BoxPlot.Count-1]);
end;

procedure TForm1.Button1Click(Sender: TObject);
var newPoint: Double;
begin
  newPoint:=BoxPlot.YValues.MinValue+random*BoxPlot.YValues.Range;
  BoxPlot.Add(newPoint);
  LastPoint.YValue[0]:=newPoint;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply