Page 1 of 1

Sub chart order

Posted: Mon Jun 10, 2013 3:50 pm
by 16564986
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

Re: Sub chart order

Posted: Wed Jun 12, 2013 2:46 pm
by yeray
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;

Re: Sub chart order

Posted: Fri Jun 14, 2013 8:53 am
by 16564986
Thanks for the heads up - it was the index value I was missing