Page 1 of 1

TBoxSeries add last value

Posted: Mon Nov 03, 2014 1:45 am
by 16466434
How can I add the last observation to a Box Plot Chart?

Re: TBoxSeries add last value

Posted: Mon Nov 03, 2014 1:23 pm
by yeray
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;