2
votes

Are true dashed series possible in TeeChart?

I am trying to represent several data channels on TChart to show data outages. According to the plan each series should contain multiple ranges. Each range represents one dash on the chart and is built only with two points: start point and end point, to speed up chart drawing.

I didn't find interrupted line series, so I built my example with multiple FastLineSeries on the line, setting their colors by hand:

unit BCLMain;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, VclTee.TeeGDIPlus, VCLTee.TeEngine,
  Vcl.ExtCtrls, VCLTee.TeeProcs, VCLTee.Chart, VCLTee.Series;

type
  TForm1 = class(TForm)
    Chart1: TChart;
    procedure FormShow(Sender: TObject);
  private
    procedure _fillSeries(serIndex: Integer);
  public
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormShow(Sender: TObject);
var
  i: Integer;
begin
  Chart1.ClearChart();
  Chart1.View3D := False;
  for i := 0 to 4 do _fillSeries(i);
end;

procedure TForm1._fillSeries(serIndex: Integer);
const
  serc: array[0..4] of TColor = (clRed, clGreen, clBlue, clYellow, clFuchsia);
var
  i, r: Integer;
  ser: TFastLineSeries;
begin
  for i := 0 to 4 do begin
    ser := TFastLineSeries.Create(Chart1);
    ser.Color := serc[serIndex];
    ser.Pen.Width := 5;
    Chart1.AddSeries(ser);
    r := Random(20);
    ser.AddXY(i*10+r, serIndex);
    ser.AddXY((i+1)*10-1+r, serIndex);
  end;
end;

end.

The problem here is that dashes in the line are not interpreted as a single series: they could not be hidden/shown at once and are represented as multiple items in legend.

enter image description here

How to make true interrupted series?

If it is not possible, then how to join pieces of a single line in the legend? (In the future I would like to show/hide each line by clicking a corresponding checkbox in the legend).

1
Take a look at the Gnatt chart type which is used to plot start/stop data.Brian
Works with a Gnatt chart series for each horizontal row (so you can get check boxes to hide/show each series).Brian

1 Answers

3
votes

A Gnatt chart series per horizontal line should get you close. Turn off Color Each for the series so all segments are the same color.

enter image description here