Reputation: 8174
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;
Upvotes: 2
Views: 372
Reputation: 54453
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..
Upvotes: 3