Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Chart > Telerik.Charting.ChartSeriesCollection.GetMaxYValue()

Not answered Telerik.Charting.ChartSeriesCollection.GetMaxYValue()

Feed from this thread
  • Chris Ward avatar

    Posted on Jan 13, 2012 (permalink)

    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

    Reply

  • Yavor Yavor admin's avatar

    Posted on Jan 18, 2012 (permalink)

    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).

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / WinForms > Chart > Telerik.Charting.ChartSeriesCollection.GetMaxYValue()
Related resources for "Telerik.Charting.ChartSeriesCollection.GetMaxYValue()"

[ Features | Demos | Documentation | Knowledge Base | Telerik TV | Code Library | Step-by-step Tutorial | Blogs | Self-Paced Trainer ]