我正在尝试使用System.Windows.Forms.DataVisualization.Charting
在WinForms中绘制一个图表,其中AxisX和AxisX2的范围不同,
chartArea1.AxisX.Minimum=0;
chartArea1.AxisX.Maximum=600;
chartArea1.AxisX2.Minimum=0;
chartArea1.AxisX2.Maximum=300;
AxisX标签范围(0-600)显示在AxisX2而不是范围(0-300)。请帮我显示AxisX2标签而不是AxisX标签。
答案 0 :(得分:1)
我试过,如果我添加这行代码,它对我有用:
private void Form1_Activated(object sender, EventArgs e)
{
//Added some point just for an example
chart1.Series["Series1"].Points.AddXY(1, 1);
chart1.Series["Series1"].Points.AddXY(2, 2);
chart1.Series["Series1"].Points.AddXY(3, 3);
chart1.Series["Series1"].XAxisType = System.Windows.Forms.DataVisualization.Charting.AxisType.Secondary;
}
我在Form1.Designer.cs
我已经检查过:
chartArea1.AxisX.Maximum = 600D;
chartArea1.AxisX.Minimum = 0D;
chartArea1.AxisX2.Maximum = 300D;
chartArea1.AxisX2.Minimum = 0D;
这应该可以解决问题。