Hello,
How do I show a crosshair cursor which displays the X-axis and the Y-axis values?
-Mike
Cursor x and y values
Re: Cursor x and y values
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Newbie
- Posts: 18
- Joined: Tue Apr 09, 2013 12:00 am
Re: Cursor x and y values
Hello,
What is ChartTool2 in the example? What does it mean by Annotion Tool?
Also...the picture are not shown.
-Mike
What is ChartTool2 in the example? What does it mean by Annotion Tool?
Also...the picture are not shown.
-Mike
Re: Cursor x and y values
Hi Mike,
Sorry if it wasn't clear enough.
I've made a more complete example from it. You only need to add a Chart to the form at design time and the following code:
Don't hesitate to let us know if you find any problem when adapting it to your specific needs.
Sorry if it wasn't clear enough.
I've made a more complete example from it. You only need to add a Chart to the form at design time and the following code:
Code: Select all
uses {...} Series, TeeTools;
//...
private
{ Private declarations }
procedure cursorToolChange(Sender: TCursorTool; x, y: Integer;
const XValue, YValue: Double; Series: TChartSeries; ValueIndex: Integer);
//...
var cursorTool: TCursorTool;
annotatTool: TAnnotationTool;
procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D:=false;
Chart1.AddSeries(TPointSeries).FillSampleValues;
cursorTool:=Chart1.Tools.Add(TCursorTool) as TCursorTool;
cursorTool.OnChange:=cursorToolChange;
annotatTool:=Chart1.Tools.Add(TAnnotationTool) as TAnnotationTool;
annotatTool.PositionUnits := muPixels;
annotatTool.Shape.CustomPosition := true;
Chart1.Draw;
annotatTool.Shape.Top := Chart1.Axes.Bottom.PosAxis + 20;
end;
procedure TForm1.cursorToolChange(Sender: TCursorTool; x, y: Integer;
const XValue, YValue: Double; Series: TChartSeries; ValueIndex: Integer);
begin
annotatTool.Text := floattostr(XValue);
Chart1.Draw;
annotatTool.Shape.Left := Chart1.Axes.Bottom.CalcXPosValue(XValue) - (annotatTool.Shape.Width div 2);
Caption := 'X: ' + floattostr(XValue) + ' Y: ' + floattostr(YValue);
end;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |