MSChart/C# : Show Y price on candle/bar chart on the Y axis when mouse moving

Moi même 1 Reputation point
2021-11-26T12:54:47.607+00:00

Hello.
I am an absolute beginner and I would like to be able to display a horizontal line when the mouse moves over the chart and at that line, on the Y2 axis, display the price in a rectangle the color of the moving line.
I searched and thought I understood that it was necessary to use an annotation but I do not know how to:
-Display / Clear the annotation at this location because I do not know the position of the Y2 axis
-Display the price value at the mouse level and not the bar prices. Because I only get the value of Y in pixels and I don't know where to find the values of the scales for the X and Y axes
All your help will be welcome
Thanks everyone.

Developer technologies | C#
{count} votes

1 answer

Sort by: Most helpful
  1. Moi même 1 Reputation point
    2021-11-29T22:23:13.567+00:00

    Thank you for your interest in my question...

    153358-candlestick.png

    On this chart, to retrieve the value of Y for candle 25, I do :

    DataPoint Right = chart.series[0].Popints[25];  
    LinbeAnnotation line = new LineAnnotation();  
    line.Y = right.YValues[1]; (0=High, 1=Low, 2=Open,3=Close)  
    

    line.Y = 2150 (you can see it on AxisY2 and X = 25...

    But i would like to get the coordonate of the low point (in purple on my picture) but i don't know how to do.
    I searched here (i m french ) https://learn.microsoft.com/fr-fr/dotnet/api/system.web.ui.datavisualization.charting.datapoint?view=netframework-4.8 but i don't understand how to find the high and low value..
    Sorry but i m a beginner...


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.