23891

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

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

<img src=https://www.e-learn.cn/content/wangluowenzhang/"https://i.stack.imgur.com/xv8Zw.png" alt="Chart with flat area">

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

this.chart1.ChartAreas[0].AxisY.ScaleBreakStyle.Enabled = false;</pre>
    

Answer1:

You seem to be looking for AxisY.ScaleBreakStyle.

Here is an example:

<img src=https://www.e-learn.cn/content/wangluowenzhang/"https://i.stack.imgur.com/hBfIC.png" alt="enter image description here">

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:

    <li>

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

    </li> <li>

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

    </li> <li>

    The minimum or maximum value for the axis is set.

    </li> <li>

    Custom labels are used.

    </li> <li>

    A logarithmic Y-axis is specified.

    </li> <li>

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

    </li> <li>

    3-D charts are used.

    </li> </ul>

    <strong>Update:</strong> Of course you can also <strong>disable</strong> the break at runtime..

Recommend

  • Graph dynamic update
  • Bar and Line charts are not synced when in the same chart area
  • C# change color in chart
  • I have an error about chart columns order
  • Exporting a function, cast into a pointer through a DLL
  • Chart Auto Scroll (Oscilloscope Effect)
  • OleDbException: no value given for parameters when no parameters are defined
  • Sort a list by polar angle in counterclockwise order in Prolog
  • Extract text from caret position textarea
  • How to move multiple Views in Android?
  • VBA Select Random Row In Range of Select
  • Taking Modulo of Double NUmber
  • takes many refreshes before server side code is updated?
  • Why do labels disappear in ASP.NET charting?
  • How to debug a Pivot Chart Macro?
  • Select any random string from a list
  • Context is null in SignalR hub
  • How to provide the custom angle to label in excel using C#
  • Yii: any way to save the images in compressed form?
  • A new chart every sheet
  • How to draw a line dynamically in android [duplicate]
  • Android Studio Can't Find tools.jar
  • How to detect interior vertices in groups of 2d polygons? (E.g. ZIP Codes to determine a territory)
  • Algorithm for a smudge tool?
  • FB SDK and cURL: Unknown SSL protocol error in connection to graph.facebook.com:443
  • Using $this when not in object context
  • How do I fake an specific browser client when using Java's Net library?
  • Why doesn't :active or :focus work on text links in webkit? (safari & chrome)
  • Perl system calls when running as another user using sudo
  • How to apply VCL Styles to DLL-based forms in Inno Setup?
  • Rearranging Cells in UITableView Bug & Saving Changes
  • Traverse Array and Display in markup
  • How get height of the a view with gone visibility and height defined as wrap_content in xml?
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Android Google Maps API OnLocationChanged only called once
  • Sorting a 2D array using the second column C++
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • UserPrincipal.Current returns apppool on IIS
  • java string with new operator and a literal