-1

I want to plot values in the multiple of hundreds on the Y axis but the values after calculations comes out to be different for example: 6233,12466,18699... how can I make them like 6000,12000,18000... This is just one data.

I want to keep the y values on Y axis to be in the multiple of 100.

The formula I am using to calculate the points is

m_oLineChart.ChartArea.AxisY.UnitMajor = Math.Round((m_oLineChart.ChartArea.AxisY.Max - m_oLineChart.ChartArea.AxisY.Min) / 5);
Reza Aghaei
  • 120,393
  • 18
  • 203
  • 398
XXDebugger
  • 1,581
  • 3
  • 26
  • 48
  • 1
    The numbers on the Axis are Labels that are spaced in Intervals as fit. Reaza's answer ought to help. __Your code doesn't even compile with a MSChart !!__ – TaW Aug 13 '16 at 07:09

2 Answers2

1

If you want to show y-axis labels with a specific interval, you can use Interval property of AxisY.

Example

void Form1_Load(object sender, EventArgs e)
{
    chart1.ChartAreas[0].AxisY.Interval = 6000;
    var random = new Random();
    for (int i = 0; i < 10; i++)
    {
        chart1.Series[0].Points.Add(random.Next(6000, 20000));
    }
}

enter image description here

Reza Aghaei
  • 120,393
  • 18
  • 203
  • 398
  • It would be great if you let me know what's wrong with the answer. – Reza Aghaei Aug 12 '16 at 22:14
  • 1
    To make sure this work he might need to also set the Minimum; to further influens the Labels he might want to use the IntervalOffset. – TaW Aug 13 '16 at 07:08
0

If you really want to round the actual values to nearest hundred use the following

Math.Round(18699d / 100d, 0) * 100; // = 18600

To nearest thousand

Math.Round(18699d / 1000d, 0) * 1000; // = 18000
Vijai
  • 2,369
  • 3
  • 25
  • 32