Nevron Forum

How to inflate an ordinal scale so that 0 is touching the left axis wall?

https://www.nevron.com/Forum/Topic6552.aspx

By Keith Mason - Tuesday, June 12, 2012

Hello,

I am trying to stretch out the X axis data of an NLineSeries so that the first point touches the left side of the chart and the last point touches the right (see image 1 for a photoshopped version of what I'm trying to do). By default, the data tick line is at the point, so I change that with

ordinalScaleConfigurator.DisplayDataPointsBetweenTicks = false;

This works OK, but there is still a gap between the axis wall and the beginning of the line (see image 2).

It appears that the flags needed to stretch it out are InflateViewRangeBegin and InflateViewRangeEnd.

ordinalScaleConfigurator.InflateViewRangeBegin = true;
ordinalScaleConfigurator.InflateViewRangeEnd = true;

When I do that, however, the chart gets smaller to make room for a second 0 and an unlabelled last tick (see image 3). This isn't right at all. What do I need to do to accomplish the effect in image 1?

Thanks!
By Nevron Support - Thursday, June 14, 2012

Hi Keith,

By default the oridnal scale on the x axis will inflate the content range by 0.5. In order to show the line exactly at the begin / end of the axis you need to turn off that inflate:

NChart chart = nChartControl1.Charts[0];
NLineSeries line = new NLineSeries();
line.Values.Add(10);
line.Values.Add(20);
line.Values.Add(15);
chart.Series.Add(line);

NOrdinalScaleConfigurator scaleX = chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator as NOrdinalScaleConfigurator;
scaleX.DisplayDataPointsBetweenTicks = false;
scaleX.InflateContentRange = false;

Hope this helps - let us know if you have any questions...