This is a migrated thread and some comments may be shown as answers.

Telerik.Charting.ChartSeriesCollection.GetMaxYValue()

1 Answer 21 Views
Chart (obsolete as of Q1 2013)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Chris Ward
Top achievements
Rank 1
Chris Ward asked on 13 Jan 2012, 10:04 PM

I have a chart that shows percent.  I would like the Y axis to show 0 through 100 if the maximum value in the series is less than 100.  If the maximum value is greater than 100 then I would like the chart to automaticaly scale the Y axis.

I thought that I could use Telerik.Charting.ChartSeriesCollection.GetMaxYValue() method, however it is not working as I expect.  The value it returns is Infinity, not the maximum value. This is how I am trying to achomplish.

if(chart.Series.GetMaxYValue() <= 100)
{
     chart.PlotArea.YAxis.MaxValue = 100;
     chart.PlotArea.YAxis.Appearance.TextAppearance.TextProperties.Color = Color.Black;
}
else
 {
     chart.PlotArea.YAxis.AutoScale = true;
     chart.PlotArea.YAxis.Appearance.TextAppearance.TextProperties.Color = Color.Red;
}

However when the maximum value is less than 100, I never get inside the IF startment, it always bounces to the ELSE.

To diagnose, I put the following line of code in so I can se the value returned by GetMaxYValue().

var x = chart.Series.GetMaxYValue();

Inside the debugger I can see the value of x is Infinity.

Any thoughts on what I'm doing wrong?  Is there a better way to achomplish this?

Thanks,

Chris

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 18 Jan 2012, 04:04 PM
Hi,

One possible cause for why this data is not available, is the event in which it is used. You can move the logic in the .BeforeLayout event of the chart control, when the data should be available.
Another option is to query the underlying datasource directly, instead of querying the chart. This has the additional advantage of not needing to refresh the layout/control, if the information is acquired before constructing it.
I hope this information gets you started properly.

All the best,
Yavor
the Telerik team

SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

Tags
Chart (obsolete as of Q1 2013)
Asked by
Chris Ward
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or