pixels to value conversion

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
odissey1
Newbie
Newbie
Posts: 35
Joined: Thu Oct 23, 2003 4:00 am

pixels to value conversion

Post by odissey1 » Mon Dec 08, 2008 8:45 pm

Hi,
I need to specify shape (circle) size in axis values, based on required size in pixels (e.g. 20px).

There are functions available like XScreenToValue / YScreenToValue which can help in that regard like:

size:=XScreenToValue(20)-XScreenToValue(0);

Is there a direct function converting pixels to axis value? (I know there is a reverse function Size->Pixels)

regards,
odissey1

wwp3321
Newbie
Newbie
Posts: 60
Joined: Wed Jul 02, 2003 4:00 am

Post by wwp3321 » Tue Dec 09, 2008 1:12 am

You can use CalcXPosValue() as following

int X0 = Chart1->Axes->Bottom->CalcXPosValue( 100 );
int Y0 = Chart1->Axes->Left->CalcYPosValue(50);

odissey1
Newbie
Newbie
Posts: 35
Joined: Thu Oct 23, 2003 4:00 am

Post by odissey1 » Tue Dec 09, 2008 2:46 am

8574101 wrote:You can use CalcXPosValue() as following

int X0 = Chart1->Axes->Bottom->CalcXPosValue( 100 );
int Y0 = Chart1->Axes->Left->CalcYPosValue(50);
Nope, that won't work, X:=CalcXPosValue(Val) is an integer and returns chart point 'X' position for a given axis value 'Val'.


I am looking for a function inverse to CalcSizeValue:
dX:=Chart1.BottomAxis.CalcSizeValue(Val);

something like
Val:=Chart1.BottomAxis.CalcValueSize(dX);


For example, for pixel size 20 this can be achieved as
Val:=Chart1.BottomAxis.CalcPosPoint(20)-Chart1.BottomAxis.CalcPosPoint(0);

or like this :)
Val:=20 * 1000000.0 / Chart1.BottomAxis.CalcSizeValue(1000000);

But why there is no any straight function?

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

Post by Narcís » Tue Dec 09, 2008 12:22 pm

Hi odissey1,

What about this?

Code: Select all

  Val:=Chart1.Axes.Bottom.IStartPos + 20;
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

odissey1
Newbie
Newbie
Posts: 35
Joined: Thu Oct 23, 2003 4:00 am

Post by odissey1 » Tue Dec 09, 2008 6:48 pm

narcis wrote:Hi odissey1,

What about this?

Code: Select all

  Val:=Chart1.Axes.Bottom.IStartPos + 20;
Nope, this is not it. The result should be a Float, not an integer.

Let me re-phrase my question:
I nedd a Bubble point with radius 20pix. Let say that the BottomAxis spans from 0 to 100 units. What Radius value shoud I assign to a Bubble series to obtain a desired 20 pixels on the screen?

odissey1

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

Post by Narcís » Wed Dec 10, 2008 9:03 am

Hi odissey1,

Thanks for the info.

In that case you can do something like this:

Code: Select all

  pos:=Chart1.Axes.Bottom.IStartPos + 20;
  val:=Chart1.Axes.Bottom.CalcPosPoint(pos);
  radius:=val-Chart1.Axes.Bottom.Minimum;
Where pos is an Integer and val and radius are Double variables.

Hope this helps!
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