0

IDE: c++ Builder XE5 Update 2

TeeChart Build: 2014.11.140512

I am trying to bring certain series on a TChart component to the front(as you would typically do with a BringToFront() function).

I've done some reading and found the following options/suggestions:

A. Change the ZOrder property of the series.

B. Use TChart.ExchangeSeries()

Using TChart.ExchangeSeries() is not a proper way of changing the z-order of a series. Its primary function is to swap around two series in a TChart component's SeriesList(which then inherently changes the z-order of those series). If you require your series-ordering to be fixed(fixed ordering in SeriesList), then this will not work.

Changing the ZOrder properties of the series delivered better results. However, changing the ZOrder of the first series(Series[0]) apparently does nothing. Series[0] seem to like sitting at the back of the class.

The above might be the result of my implementation. In which case, some more details:

On my TChart component I have multiple series. The series-types can be changed dynamically. The types to which the series can be changed are limited to TLineSeries and TBarSeries.

I always want the TLineSeries at the front.

Any advice on how this can be done?

(Will we ever see that elusive TChartSeries.BringToFront() function?) :)

1 Answer 1

0

Any advice on how this can be done?

Looks like mixing series styles and changing ZOrder is not working very well. For example, using this code snippet:

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.AddSeries(TLineSeries.Create(Self)).FillSampleValues(10);
  Chart1.AddSeries(TLineSeries.Create(Self)).FillSampleValues(10);
  Chart1.AddSeries(TBarSeries.Create(Self)).FillSampleValues(10);
  Chart1.AddSeries(TBarSeries.Create(Self)).FillSampleValues(10);
  Chart1.AddSeries(TBarSeries.Create(Self)).FillSampleValues(10);
end;

procedure TForm1.Button1Click(Sender: TObject);
var i: Integer;
begin
  for i:=0 to Chart1.SeriesCount-1 do
  begin
    Chart1[i].Marks.Visible:=False;

    if Chart1[i] is TLineSeries then
      Chart1[i].ZOrder:=Chart1.SeriesCount - 1 - i
    else
      Chart1[i].ZOrder:=i;
  end;
end;

Line series are brought to the front but bar series style remain there. I have also tried with bar series StackGroups: However, it doesn't make much of a difference. We'd need StackGroups for line series as well for this work.

(Will we ever see that elusive TChartSeries.BringToFront() function?) :)

Why not? I have added your request to Steema Software's bugzilla platform: http://bugs.teechart.net/show_bug.cgi?id=853. Feel free to sign up and add yourself to the CC List to receive automatic issue updates.

1
  • Thanks for adding the request! Luckily, at present and due to the nature of the project and the initial manner in which it will be used, I should be able to avoid the issue for the time being(by not changing Series[0] to a TLineSeries; line-series at higher indices seem to work).
    – HvS
    Commented Jul 18, 2014 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.