TcursorTool
Posted: Fri Dec 11, 2009 10:28 am
Hello,
I use TcursorTool like it :
the problem is that there is not the same number of points between Series1 and Series2. How can i do to have the Series1 Yvalue correct with its Xvalue?
I use ValueIndex but it is not correct in this case. I precise that there is no reason to print the Yvalue of Series1 if its Xvalue doesn't exist
Thanks for help
Regards
I use TcursorTool like it :
Code: Select all
Procedure Tform1.CursorSynchronize( Source, Dest: TCursorTool );
begin
Dest.ParentChart.AutoRepaint:=False; // stop repainting
Dest.RedrawCursor; // hide cursor
Dest.XValue := Source.XValue;
Dest.RedrawCursor; // draw cursor again
Dest.ParentChart.AutoRepaint:=True; // enable repainting
end;
procedure TForm1.FormShow(Sender: TObject);
var
i:integer;
begin
for i := 0 to 10do
Series1.AddXY(i,i+1);
for i := 80 to 100 do
Series1.AddXY(i,i+1);
for i := 0 to 100do
Series2.AddXY(i,i+1);
end;
procedure TForm1.ChartTool1SnapChange(Sender: TCursorTool; x, y: Integer;
const XValue, YValue: Double; Series: TChartSeries; ValueIndex: Integer);
begin
CursorSynchronize(sender,ChartTool1);
label1.Caption:='Y1='+FormatFloat('0.00',Series1.YValue[ValueIndex]);
label2.Caption:='X1='+FloatToStr(XValue);
label3.Caption:='Y2='+FormatFloat('0.00',Series2.YValue[ValueIndex]);
label4.Caption:='X2='+FloatToStr(XValue);
end;
I use ValueIndex but it is not correct in this case. I precise that there is no reason to print the Yvalue of Series1 if its Xvalue doesn't exist
Thanks for help
Regards