The attached demo adds random series at run-time after clicking onto the corresponding button and displays the series titles in a 2-column legend. However, the legend is updated only with every second series added.
I'd also like to mention that copying the data from a RandomChartSource to the series' built-in chart source by calling the CopyFrom method does not compile. What am I doing wrong?
procedure TForm1.Button1Click(Sender: TObject);
var
series : TLineSeries;
i : integer;
begin
// create new random data
RandomChartSource1.RandSeed := random(MaxInt);
series := TLineSeries.Create(self);
series.SeriesColor := rgb(random(256),random(256),random(256));
series.Title := Format('Series #%d', [Chart1.SeriesCount]);
// copy random data to series Listsource
// this does not compile:
// series.ListSource.CopyFrom(RandomChartSource1);
for i:=0 to RandomChartSource1.PointsNumber-1 do
series.AddXY(RandomChartSource1.Item[i]^.X, RandomChartSource1.Item[i]^.Y);
// add series to chart
Chart1.AddSeries(series);
end;
[Edit] BTW, maybe it would be nice if there would be an option to populate the legend by rows instead of by columns.