MSChart Y-Axis and X-Axis Labelling

2020-02-14 03:53发布

问题:

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

回答1:

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();
        }
    }