Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
625 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 Reply

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...