Page 1 of 1

Easier way to axis Y value

Posted: Mon Aug 31, 2015 9:38 am
by 16475102
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 12472 times

Re: Easier way to axis Y value

Posted: Mon Aug 31, 2015 10:12 am
by yeray
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".

Re: Easier way to axis Y value

Posted: Mon Aug 31, 2015 10:26 am
by 16475102
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

Re: Easier way to axis Y value

Posted: Mon Aug 31, 2015 11:04 am
by yeray
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].

Re: Easier way to axis Y value

Posted: Mon Aug 31, 2015 11:19 am
by 16475102
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

Re: Easier way to axis Y value

Posted: Mon Aug 31, 2015 1:00 pm
by yeray
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.

Re: Easier way to axis Y value

Posted: Mon Aug 31, 2015 1:57 pm
by 16475102
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 12435 times

Re: Easier way to axis Y value

Posted: Tue Sep 01, 2015 9:11 am
by yeray
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 692 times

Re: Easier way to axis Y value

Posted: Thu Sep 03, 2015 5:31 am
by 16475102
Good day,

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

Have a nice day