How reduce the height of an mschart by breaking up the y-axis

≡放荡痞女 提交于 2020-01-15 04:57:14

问题


How can I reduce the height of an mschart like this:

[EDIT] In my case I do not want break chart view.

this.chart1.ChartAreas[0].AxisY.ScaleBreakStyle.Enabled = false;

回答1:


You seem to be looking for AxisY.ScaleBreakStyle.

Here is an example:

Series s = chart1.Series[0];
ChartArea ca = chart1.ChartAreas[0];
Axis ay = ca.AxisY;
s.ChartType = SeriesChartType.Line;
for (int i = 0; i < 100; i++) s.Points.AddXY(i, rnd.Next(100) + 50 );
s.Points.AddXY(s.Points.Count, 123456);

ay.ScaleBreakStyle.Enabled = true;   // <<<=== enable or disable!
ay.ScaleBreakStyle.LineWidth = 1;
ay.ScaleBreakStyle.LineColor = Color.OrangeRed;
ay.ScaleBreakStyle.StartFromZero = StartFromZero.Auto;
ay.ScaleBreakStyle.Spacing = 2;
ay.ScaleBreakStyle.StartFromZero = StartFromZero.Auto;

Note that there a quite a few cases where it will not work. MSDN:

Scale breaks are not supported under any of the following conditions:

  • Pie, doughnut, funnel, pyramid, radial or any stacked chart types are used.

  • Custom intervals for labels, tick marks or grid lines are enabled.

  • The minimum or maximum value for the axis is set.

  • Custom labels are used.

  • A logarithmic Y-axis is specified.

  • Axis views on the Y-axis, which include scrolling and zooming, are used.

  • 3-D charts are used.

Update: Of course you can also disable the break at runtime..



来源:https://stackoverflow.com/questions/43279241/how-reduce-the-height-of-an-mschart-by-breaking-up-the-y-axis

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