Hi.

If i know the y value how can i find the x value and vice versa?

Example for (Chart1.SeriesList.Series[0].MaxYValue) how can i find the x ?

If i know the y value how can i find the x value and vice versa?

Example for (Chart1.SeriesList.Series[

The MaxYValue property returns the largest Y value in the chart series, it does not return you the index of the data point (which would be needed in order to get the corresponding X value). You could walk the series YValues[index] until you found the yvalue that = MaxYValue, which would then give you the index, but if there are 2 data points where the YValue = MaxYValue, then you would not be able to determine what data point you needed to get. Eg, given the 6 sample data points in the format of index = (x, y)

0 = (1, 5)

1 = (2, 7)

2 = (10, 20)

3 = (11, 14)

4 = (15, 12)

5 = (8, 20)

The series MaxYValue would return 20. But because there are 2 data points with Y=20, you would be unable to determine if the corresponding X value was supposed to be 10 or 8. So, only if EVERY y value and EVERY x value is unique, will you be able to do what you are asking.

Russell

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.

Russell

---

function FindXForY(YValue: Double; Series: TChartSeries): Double;

var dwIndex: Integer;

begin

// Set default result

result:=0;

// Find the index of the y value

for dwIndex:=0 to Pred(Series.YValues.Count)

begin

if (Series.YValue[dwIndex] = YValue) then

begin

// Return the x value

result:=Series.XValue[dwIn

// Done

break;

end;

end;

end;

function FindYForX(XValue: Double; Series: TChartSeries): Double;

var dwIndex: Integer;

begin

// Set default result

result:=0;

// Find the index of the y value

for dwIndex:=0 to Pred(Series.XValues.Count)

begin

if (Series.XValue[dwIndex] = XValue) then

begin

// Return the y value

result:=Series.YValue[dwIn

// Done

break;

end;

end;

end;