Making a 4 sided Graph / 4 sided (Cartesian) grid In Visual Studio

ぐ巨炮叔叔 提交于 2019-11-27 16:19:28

This is quite simple. All you need to do is tell the Chart to place the Crossing of the Axis at certain points, instead of keeping it unset (NaN).

You also should set the range by setting Minimum and Maximum:

ChartArea CA = chart1.ChartAreas[0];
Series S1 = chart1.Series[0];
S1.ChartType = SeriesChartType.Line;

CA.AxisX.Maximum = 100;
CA.AxisX.Minimum = -100;
CA.AxisY.Maximum = 100;
CA.AxisY.Minimum = -100;

CA.AxisX.Crossing = 0;
CA.AxisY.Crossing = 0;

CA.AxisX.Interval = 10;
CA.AxisY.Interval = 10;

CA.AxisX.LineWidth = 3;
CA.AxisY.LineWidth = 3;

CA.AxisX.MajorGrid.Enabled = false;
CA.AxisY.MajorGrid.Enabled = false;
CA.AxisX.MinorTickMark.Enabled = false;
CA.AxisY.MinorTickMark.Enabled = false;


// now we add a few points:
S1.Points.AddXY(-21,81);
S1.Points.AddXY(52,60);
S1.Points.AddXY(-53, -11);
S1.Points.AddXY(-53, 88);

You can use most chart types, though not all, like Pie.

You can play around with many other properties to make it work as you want; especially the Interval may be of interest!

Other properies of interest include these:

CA.AxisX.ArrowStyle = AxisArrowStyle.Triangle;
CA.AxisX.MinorTickMark.Enabled = false;    
CA.AxisX.LabelStyle.Enabled = false;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!