MSChart Y-Axis and X-Axis Labelling

codeBlocks picture codeBlocks · Mar 8, 2011 · Viewed 7.9k times · Source

I have data plotted onto a MSChsart line graph.

On the Y axis I have values ranging form 0 300. could anyone let me know is it possible to

change my:

Y-axis LABEL values from (0 to 300) to a value of (-150 to 150).

without changing my Y-axis DATA values.

By this I mean I want the labels to show different values, but I dont want to edit my data values plotted. So for example if I have data plotted on Y-axis value of 150, the Y=axis label should be showing it at 0.

Any help would be greatly appreciated

Answer

Stecya picture Stecya · Mar 8, 2011

Implemt Customize event

    private void chart1_Customize(object sender, EventArgs e)
    {
        foreach (var label in chart1.ChartAreas[0].AxisY.CustomLabels)
        {
            label.Text = (double.Parse(label.Text) - 150).ToString();
        }
    }