How do you handle multi layer graph

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Tony Jackson
Newbie
Newbie
Posts: 2
Joined: Wed Sep 02, 2015 12:00 am
Contact:

How do you handle multi layer graph

Post by Tony Jackson » Fri Sep 04, 2015 1:35 pm

My situation is complicated. We are using TChart to populate it with patterns on a circuit board. The patterns each are series. The circuit board is an image. See attachment.

We have countless series based on the number of patterns. What we are adding is grip handles on the patterns. These will be point series.

I wish to create the grip handle point series at design time since they are a constant number (being 4). The problem is that with them being created first they are behind the patterns and circuit board.

How can i bring the grip handle point series to the front. I have read about zorder and exchange. However, with us having a varied number of other series how can I set the grip handle point series to the front?

The only alternative it to create the grip handle point series after the other series are created to ensure that they reside on the top. However, this could cause problems with pattern changes, etc.
Attachments
Graph.png
Graph.png (290.44 KiB) Viewed 4236 times

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: How do you handle multi layer graph

Post by Yeray » Mon Sep 07, 2015 7:55 am

Hello,

So resuming, you have a set of known series you want to be on the front, and you want to check it several times or at least at runtime.
We could take this simple example then, where I create some bars and lines. As you'll see, at the start some bars overlap some lines.
But the TLineSeries have been added to SeriesOnFront TChartSeriesList and if you click on the Button the series on that list are moved to the front.

Code: Select all

uses Series;

var SeriesOnFront: TChartSeriesList;

procedure TForm1.FormCreate(Sender: TObject);

  procedure CreateLine;
  begin
    SeriesOnFront.Add(Chart1.AddSeries(TLineSeries));
    with Chart1[Chart1.SeriesCount-1] as TLineSeries do
    begin
     FillSampleValues;
     Pen.Width:=2;
     Title:='Line' + IntToStr(Chart1.SeriesCount);
    end;
  end;

  procedure CreateBar;
  begin
    with Chart1.AddSeries(TBarSeries) as TBarSeries do
    begin
     FillSampleValues;
     Marks.Visible:=false;
     Title:='Bar' + IntToStr(Chart1.SeriesCount);
    end;
  end;

begin
  Chart1.View3D:=false;

  SeriesOnFront:=TChartSeriesList.Create;

  CreateBar;
  CreateLine;
  CreateBar;
  CreateLine;
  CreateBar;
  CreateLine;
end;

procedure TForm1.Button1Click(Sender: TObject);
var i, j: Integer;
begin
  for i:=Chart1.SeriesCount-1 downto 1 do
    if SeriesOnFront.IndexOf(Chart1[i]) = -1 then
      for j:=i-1 downto 0 do
        if SeriesOnFront.IndexOf(Chart1[j]) > -1 then
        begin
          Chart1.ExchangeSeries(i, j);
          Break;
        end;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply