Recent

Author Topic: TAChart Multi-Column Legend  (Read 3745 times)

wp

  • Hero Member
  • *****
  • Posts: 13484
TAChart Multi-Column Legend
« on: October 28, 2011, 12:02:43 am »
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?

Code: [Select]
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.
« Last Edit: October 28, 2011, 08:38:08 am by wp »

Ask

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 687
Re: TAChart Multi-Column Legend
« Reply #1 on: October 28, 2011, 02:40:53 pm »
Quote
the legend is updated only with every second series added
Fixed in r33135

Quote
CopyFrom method does not compile. What am I doing wrong?
Heh, it was a subtle typo in the method name.
Fixed in r33132

Quote
an option to populate the legend by rows instead of by columns.
Added ItemFillOrder in r33137-33138.

 

TinyPortal © 2005-2018