Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
603 views
in Technique[技术] by (71.8m points)

c# - MSChart Y-Axis and X-Axis Labelling

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...