CursorTool and Annotation (scientific format)

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
GE-BB-CB
Newbie
Newbie
Posts: 4
Joined: Fri Feb 13, 2015 12:00 am

CursorTool and Annotation (scientific format)

Post by GE-BB-CB » Tue Jun 09, 2015 9:34 am

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
Last edited by GE-BB-CB on Tue Jun 09, 2015 1:11 pm, edited 1 time in total.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: CursorTool and Annotation (scientific format)

Post by Narcís » Tue Jun 09, 2015 11:51 am

Hello Benoît,

Can you please attach a simple example project we can run "as-is" to reproduce the problem here?

Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

GE-BB-CB
Newbie
Newbie
Posts: 4
Joined: Fri Feb 13, 2015 12:00 am

Re: CursorTool and Annotation (scientific format)

Post by GE-BB-CB » Tue Jun 09, 2015 12:15 pm

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
Attachments
CursorTool.zip
(3.91 KiB) Downloaded 559 times
Last edited by GE-BB-CB on Tue Jun 09, 2015 1:11 pm, edited 1 time in total.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: CursorTool and Annotation (scientific format)

Post by Narcís » Tue Jun 09, 2015 1:06 pm

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.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply