Sub chart order

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Richard
Newbie
Newbie
Posts: 11
Joined: Tue Feb 12, 2013 12:00 am

Sub chart order

Post by Richard » Mon Jun 10, 2013 3:50 pm

Hi

I have a 5 by 5 grid of subcharts.

I would like to have it zoom one of the charts to full size if the mouse is held down over it - I have achieved this - but the charts do not have any way of re-ordering them, so if I Click on the first chat I made, most of it is hidden behind the other charts. If I click on the last one it woks fine - can I reorder the charts so that this will work - I want to avoid destroying all the charts if I can as I was hoping to get a nice zoom in feel with the clicked on chart getting bigger with the other small charts behind them!

Thanks for any help

Richard

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

Re: Sub chart order

Post by Yeray » Wed Jun 12, 2013 2:46 pm

Hi Richard,

Here is how you could swap two charts in a same TSubChartTool:

Code: Select all

procedure TForm1.SwapChart(Index1, Index2: Integer);
var tmp : TSubChart;
begin
  tmp:=ChartTool1.Charts[Index2];
  ChartTool1.Charts[Index1].Index:=Index2;
  tmp.Index:=Index1;

  Chart1.Draw;
end;
Then you can use the Chart OnMouseDown event to check what SubChart has been clicked, and then you could swap the chart directly with the chart with index 0, or swap it with all the charts up to the index 0.
Here you have a starting point:

Code: Select all

procedure TForm1.Chart1Click(Sender: TObject);
begin
  if ChartTool1.Charts[0].Clicked(myMouseDown.X, myMouseDown.Y) then
    SwapChart(0,1);
end;

procedure TForm1.Chart1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  myMouseDown.X:=X;
  myMouseDown.Y:=Y;
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

Richard
Newbie
Newbie
Posts: 11
Joined: Tue Feb 12, 2013 12:00 am

Re: Sub chart order

Post by Richard » Fri Jun 14, 2013 8:53 am

Thanks for the heads up - it was the index value I was missing

Post Reply