Easier way to axis Y value

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Gucci
Newbie
Newbie
Posts: 22
Joined: Mon Jul 27, 2015 12:00 am

Easier way to axis Y value

Post by Gucci » Mon Aug 31, 2015 9:38 am

Good day,

Currently I am using the interpolation formula too axis my Y - values, but I found that my values does not match according to what the grid say.

My question is as follows :

I know what my x value is : example 2015-09-11 ( xval := Chart1.Axes.Bottom.CalcPosPoint(X);

Why cant I now loop through TCHartGrid for each column and each row and go and get each matching y value for each series matching my "Date"

Please see attached example.
example.png
example.png (83.6 KiB) Viewed 11463 times

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Easier way to axis Y value

Post by Yeray » Mon Aug 31, 2015 10:12 am

Hello,

I guess your function calculates each value taking in consideration the 10 last values from the sources series. This makes the function to have a shift/lag of 10 values.
To present this lag in the grid with the XValues synchronized, it would mean the first 10 rows on the function section would be empty and that wouldn't be true; the series linked to the function is populated from the index=0 to the index="source count - period - 1".
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Gucci
Newbie
Newbie
Posts: 22
Joined: Mon Jul 27, 2015 12:00 am

Re: Easier way to axis Y value

Post by Gucci » Mon Aug 31, 2015 10:26 am

Sorry I think I lost you,

The only thing I asking if it is possible when my mouse is on the x axis, cant I get the exact value that is in the TchartGrid.

Example x = 2015/08/31
Give me the exact value of all Y series for the 2018/08/31; The answer in this case is 52.632 for Series 2

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Easier way to axis Y value

Post by Yeray » Mon Aug 31, 2015 11:04 am

Hello,

I misunderstood you, I'm sorry.
I think you are doing almost exactly the same that is being done here. Just change OnClick event for OnMouseMove event and Chart1[0].XValue[minDistIndex] for Chart1[0].YValue[minDistIndex].
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Gucci
Newbie
Newbie
Posts: 22
Joined: Mon Jul 27, 2015 12:00 am

Re: Easier way to axis Y value

Post by Gucci » Mon Aug 31, 2015 11:19 am

This is what I am trying to explain

procedure TForm6.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
var Index,IndexLine : Integer;
xval , stock : Double;
begin
Index := tmpMyCandle.Clicked(X, Y); // GET INDEX OF CLICK CANDLE
xval := Chart1.Axes.Bottom.CalcPosPoint(X); //INDEX OF X AXIS -> WE HAVE THE DATE NOW

MouseCloseAnnot.Active:=Index<>-1;


FloatToStr(tmpMyCandle.CloseValues[Index]); // WE HAVE THE CLOSE VALUE FOR THE DAY THIS IS PERFECT !!!!!!!!!!!!!!
///QUESTION why cant we with a line series do the similar as a a candle series, or dont I understand something not right

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Easier way to axis Y value

Post by Yeray » Mon Aug 31, 2015 1:00 pm

Hello,

This should work in the same way for a TLineSeries. The only difference is that a TLineSeries draws line segments between two values, so when the mouse is over a line segment, the Clicked function will return the index of the point on the left.
But in the first post you mentioned "interpolation", so I guess you are already doing something like in the example at All features\Welcome!\Chart Styles\Standard\Line (Strip)\Interpolating Line series in the features demo.

If you still find problems with it, please try to arrange a simple example project we can run as-is to reproduce the problem here.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Gucci
Newbie
Newbie
Posts: 22
Joined: Mon Jul 27, 2015 12:00 am

Re: Easier way to axis Y value

Post by Gucci » Mon Aug 31, 2015 1:57 pm

Hi,

I please see sample code with explanation.

Here is another screen shot of what I am trying,

example.png
example.png (89.96 KiB) Viewed 11426 times
Attachments
sample.zip
(11.59 KiB) Downloaded 571 times

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Easier way to axis Y value

Post by Yeray » Tue Sep 01, 2015 9:11 am

Hello,

There are still some details I still don't understand. Ie, I'm not sure if you want the YValue corresponding to the mouse X position or corresponding to the label under the mouse.
Taking the code from the Interpolating Line series example I pointed out in the last post, I modified your example showing a few variations:
ClickedAxisSample.zip
(4.17 KiB) Downloaded 591 times
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Gucci
Newbie
Newbie
Posts: 22
Joined: Mon Jul 27, 2015 12:00 am

Re: Easier way to axis Y value

Post by Gucci » Thu Sep 03, 2015 5:31 am

Good day,

Sorry for the late reply, thank you very much this is exactly what I was looking for.

Have a nice day

Post Reply