0
votes

I am creating a Firemonkey (FMX) application. I use TChart with a Line Series (TLineSeries). I need to draw a chart line that is not continuous. The x-axis is date time and I want the line to be drawn say between 10 and 11AM and then again between 3PM and 4PM. I tried the following but it always draws a continuous line from the first point (X1) to the last point (X4):

Series.TreatNulls:=TTreatNullsStyle.tnDontPaint;


Series.AddXY(X1,1);
Series.AddXY(X2,1);
Series.AddNullXY(X2,1);
Series.AddNullXY(X3,1);
Series.AddXY(X3,1);
Series.AddXY(X4,1);

Where

X1=date value at 10AM
X2=date value at 11AM
X3=date value at 3PM
X4=date value at 4PM

I tried various combinations of TreatNulls but still no success. I am using TeeChart Version 2021.32

Any suggestions would be appreciated.

1

1 Answers

0
votes

I've given it a try and it seems to work fine for me here with the code below.
Note a single null point is enough to avoid drawing two sectors (A-null-B)

uses Series, Constants;

procedure TForm1.FormCreate(Sender: TObject);
var X1, X2, X3, X4: TDateTime;
begin
  Caption:=TeeMsg_Version;
  X1:=Date+DateTimeStep[dtOneHour]*10;
  X2:=Date+DateTimeStep[dtOneHour]*11;
  X3:=Date+DateTimeStep[dtOneHour]*15;
  X4:=Date+DateTimeStep[dtOneHour]*16;

  with Chart1.AddSeries(TLineSeries) do
  begin
    XValues.DateTime:=True;
    AddXY(X1,1);
    AddXY(X2,1);
    //AddNullXY(X2,1);
    AddNullXY(X3,1);
    AddXY(X3,1);
    AddXY(X4,1);
  end;

  Chart1.Legend.Hide;
  //Chart1.View3D:=False;
  Chart1.Axes.Left.SetMinMax(0,2);
  Chart1.Axes.Left.Increment:=0.5;
  Chart1.Axes.Bottom.Increment:=DateTimeStep[dtOneHour];
end;

screenshot