Scale Breaks


https://www.nevron.com/Forum/Topic12451.aspx
Print Topic | Close Window

By Manal Goyal - 6 Years Ago
I am trying to apply automatic scale breaks into my charts. I have few questions like, why there is this useless piece of chart still showing me around the breaks,(see the image for your reference).
By Nevron Support - 6 Years Ago
Hi Manal,
The reason for this is that by default the scale break will inflate the range in order to prevent cutting off the data - take a look at this topic:
http://helpdotnetvision.nevron.com/UsersGuide_Axes_Scale_ScaleConfigurator_ScaleBreaks.html

If you want to limit or turn off scale break inflate you need to modify the NAutoScaleBreak class - for example:

NChart chart = nChartControl1.Charts[0];

NDateTimeScaleConfigurator dateTimeScale = new NDateTimeScaleConfigurator();
NAutoScaleBreak autoScaleBreak = new NAutoScaleBreak();

DateTime dt1 = DateTime.Now;
DateTime dt2 = dt1 + TimeSpan.FromDays(1);
double halfDaySapn = (dt2.ToOADate() - dt1.ToOADate()) / 2;

NAbsoluteScaleBreakInflate scaleBreakInflate = new NAbsoluteScaleBreakInflate();
scaleBreakInflate.LeftInflate = halfDaySapn;
scaleBreakInflate.RightInflate = halfDaySapn;
autoScaleBreak.Inflate = scaleBreakInflate;

dateTimeScale.ScaleBreaks.Add(autoScaleBreak);
chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = dateTimeScale;

chart.BoundsMode = Nevron.GraphicsCore.BoundsMode.Stretch;

NLineSeries line = new NLineSeries();
line.UseXValues = true;
line.DataLabelStyle.Visible = false;

line.XValues.Add(DateTime.Now);
line.XValues.Add(DateTime.Now + TimeSpan.FromDays(1));
line.Values.Add(10);
line.Values.Add(20);

line.XValues.Add(DateTime.Now + TimeSpan.FromDays(100));
line.XValues.Add(DateTime.Now + TimeSpan.FromDays(101));
line.Values.Add(10);
line.Values.Add(20);

chart.Series.Add(line);

This code shows how to apply a half day inflate around the scale break instead of the relative scale break which is set by default. If you want to remove the inflate completely you can write:

NAutoScaleBreak autoScaleBreak = new NAutoScaleBreak();
autoScaleBreak.Inflate = new NAbsoluteScaleBreakInflate(0);

Let us know if you have any questions or meet any problems.