Page 1 of 1
CursorTool and Annotation (scientific format)
Posted: Tue Jun 09, 2015 9:34 am
by 16571512
Hello,
I have a problem with a CursorTool.
I would like to show the XValue on an Annotation of my CursorTool. The bottom axis values are in scientific format (1*10E-5 for example).
When I move the cursor, the XValue is shown but if the cursor Snap property is false, the value in the Annotation is wrong.
For example, if I move the cursor between 1*10E-5 and 1*10E-4, the value in the Annotation will be 1.0*14E-59, 1.1*16E-58, 1.9*14E-52, 3.5*18E-58, 4.8*10E-54... 9.9*19E-59 and 1.0*10E-45
How can I solve this problem ?
Thanks,
Benoît
Re: CursorTool and Annotation (scientific format)
Posted: Tue Jun 09, 2015 11:51 am
by narcis
Hello Benoît,
Can you please attach a simple example project we can run "as-is" to reproduce the problem here?
Thanks in advance.
Re: CursorTool and Annotation (scientific format)
Posted: Tue Jun 09, 2015 12:15 pm
by 16571512
Hello Narcis,
I attach a little project where you have the same problem.
Drag the cursor to reproduce the problem.
Edit: Note that the problem doesn't exist if the property Snap is set to True.
Benoît
Re: CursorTool and Annotation (scientific format)
Posted: Tue Jun 09, 2015 1:06 pm
by narcis
Hi Benoît,
Thanks for the example. I could reproduce the problem and added it (
bug #1230) to the bug list to be fixed for future releases.
I can't think of a workaround as the example below doesn't work correctly either. Looks like a problem with internal axes and screen coordinates calculation.
Code: Select all
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, TeeGDIPlus, TeeComma, ExtCtrls, TeeProcs, TeEngine, Chart, TeeTools;
type
TForm1 = class(TForm)
Chart1: TChart;
TeeCommander1: TTeeCommander;
procedure FormCreate(Sender: TObject);
procedure ChartTool1Change(Sender: TCursorTool; x, y: Integer;
const XValue, YValue: Double; Series: TChartSeries;
ValueIndex: Integer);
private
{ Private declarations }
Annotation1 : TAnnotationTool;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
uses Series;
procedure TForm1.FormCreate(Sender: TObject);
var
Series1 : TLineSeries;
Cursor1 : TCursorTool;
i : Integer;
begin
Chart1.View3D:=False;
Chart1.Axes.Bottom.AxisValuesFormat:='#.#,x10E-#';
Chart1.Axes.Bottom.Increment:=0.001000000000000000;
Series1:=TLineSeries.Create(Self);
Series1.ParentChart:=Chart1;
for i := 0 to 25 - 1 do
Series1.AddXY(i/1000, 5);
Cursor1:=TCursorTool.Create(Self);
Cursor1.ParentChart:=Chart1;
Cursor1.Series:=Series1;
Cursor1.Style:=cssVertical;
Cursor1.OnChange:=ChartTool1Change;
Annotation1:=TAnnotationTool.Create(Self);
Annotation1.ParentChart:=Chart1;
end;
procedure TForm1.ChartTool1Change(Sender: TCursorTool; x, y: Integer;
const XValue, YValue: Double; Series: TChartSeries; ValueIndex: Integer);
begin
//Annotation1.Text:=Series.GetHorizAxis.LabelValue(XValue);
Annotation1.Text:=FormatFloat('#.#,x10E-#', XValue);
end;
end.