2 posts, 0 answers
  1. Chris Ward
    Chris Ward avatar
    52 posts
    Member since:
    Jan 2010

    Posted 13 Jan 2012 Link to this post

    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;
         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?



  2. Yavor
    Yavor avatar
    11 posts

    Posted 18 Jan 2012 Link to this post


    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,
    the Telerik team

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

  3. DevCraft R3 2016 release webinar banner
Back to Top