none
Chart Controls for .NET Framework: IsLogarithmic bug RRS feed

  • General discussion

  • The following behavior seems to be a bug:

    An empty chart series with logarithmic scale throws a System.InvalidOperationException with the message: "Chart Area Axes - A logarithmic scale cannot be used for this axis."

    How to reproduce:

    Chart chart = new Chart(); // Create chart
    this.Controls.Add(chart); // 'this' is a form
    chart.ChartAreas.Add(new ChartArea()); // Create chart area
    chart.Series.Add(new Series { ChartArea = chart.ChartAreas[0].Name }); // Create series
    chart.ChartAreas[0].AxisX.IsLogarithmic = true; // Set x-axis to log-scale
    //chart.Series[0].Points.AddXY(1, 1); // Adding this line fixes the bug!

    Thursday, March 1, 2018 6:42 PM

All replies

  • Hi,

    I suppose, if target axis is X, you need to add one line for LogarithmBase like this:

    chart.ChartAreas[0].AxisX.IsLogarithmic = true; // Set x-axis to log-scale
    chart.ChartAreas[0].Axisx.LogarithmBase = Math.E; // Set logarithmic base

    Regards,

    Ashidacchi

    • Edited by Ashidacchi Friday, March 2, 2018 2:52 AM
    Friday, March 2, 2018 2:49 AM
  • Adding "chart.ChartAreas[0].Axisx.LogarithmBase = Math.E;" to the code sample I provided in my original post does not fix the mentioned bug.

    The default value for Axis.LogarithmicBase is 10d. The property is therefore not uninitialized.

    Monday, March 5, 2018 3:02 PM
  • Hi,

    Please check if min and max value is not zero or less than zero.
    We cannot use value to be more than zero with logarithm.

    Regards,

    Ashidacchi >> http://hokusosha.com/

    Monday, March 5, 2018 11:12 PM