Question

Is it possible to draw multiple lines with a single TLineSeries using TeeChart? I would like to specify a field in the dataset that the series should group by, drawing one line per group. Or is this not possible and a series should be added to the chart for each group/line that should be displayed?

Was it helpful?

Solution

You could achieve it setting XValues.Order to loNone and adding a null point each time you want to start a new line. However, to speed up drawing and point handling TFastLineSeries uses the same color (SeriesColor) for all points. If you want to use diferent colors for individual points you should use the TLineSeries instead.

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
var i, j: Integer;
begin
  Chart1.View3D:=false;
  Chart1.Legend.Visible:=false;

  with Chart1.AddSeries(TFastLineSeries) as TFastLineSeries do
  begin
    XValues.Order:=loNone;
    TreatNulls:=tnDontPaint;
    for i:=0 to 4 do
    begin
      if i>0 then AddNullXY(0,0);  //start a new line

      AddXY(0,Random*1000);
      for j:=1 to 24 do
        AddXY(j, Chart1[0].YValue[Chart1[0].Count-1] + random*10 - 5);
    end;
  end;
end;

Anyway, I don't see why one would like to do the above instead of creating several TFastLine series.

--

Best Regards,

Yeray Alonso

Steema Support Central

OTHER TIPS

You could also try using the DBCrosstabSource component which connects to any dataset and automatically creates series from database data, using Group and Label fields and formula (sum or count values). You'll find examples at the All Features -> Welcome! -> Database Charts -> DB Crosstab source section in the new features demo available here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top