Page 1 of 1

How can I get Y values using single ConstantLine

Posted: Thu Nov 15, 2018 3:03 pm
by Junseob
Hello,

I have some problems when I get Y values.

My chart has few Y axes but only have 1 ConstantLine in there.
When we are creating ConstantLine, it needs to be set the owner Y axis.
Therefore it can be read only its' axis value.

I want to get every axis values using 1 ConstantLine. I don't want to make many ConstantLine for reading Y value.
Is it possible?

Re: How can I get Y values using single ConstantLine

Posted: Fri Nov 16, 2018 9:18 am
by ArctionKestutis
Hello,

You will loose precision, but you can use converters. That is, in event handler you could use screen coordinates to/from axis values converters (Axis.ValueToCoord and Axis.CoordToValue) to estimate the position of ConstantLine. For example,

Code: Select all

            ConstantLine constantLine = chart.ViewXY.ConstantLines[0];
            // get screen coordinates [px] for Line value
            float yCoord = chart.ViewXY.YAxes[0].ValueToCoord(constantLine.Value, false);

            for (int iY = 0; iY < chart.ViewXY.YAxes.Count; iY++)
            {
                AxisY axisY = chart.ViewXY.YAxes[iY];
                // estimate Axis value for corresponding screen coordinate
                double yValue;
                axisY.CoordToValue(yCoord, out yValue, false);
                System.Diagnostics.Debug.WriteLine(string.Format("Yaxis #[{0}], Line at [{1}]", iY, yValue));
            }
Hope this helps.

Re: How can I get Y values using single ConstantLine

Posted: Wed Jan 09, 2019 12:12 pm
by MathewNi
Junseob wrote: Thu Nov 15, 2018 3:03 pm Hello,

I will always recommend probiotics for women and have some problems when I get Y values.

My chart has few Y axes but only have 1 ConstantLine in there.
When we are creating ConstantLine, it needs to be set the owner Y axis.
Therefore it can be read only its' axis value.

I want to get every axis values using 1 ConstantLine. I don't want to make many ConstantLine for reading Y value.
Is it possible?
Can you regain the precision that you lost by using converters after the fact somehow?