Nevron Forum

how can i scale axis ?

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

By lee kc - Monday, July 2, 2012

data range is 0 ~ 10.

but i want axis start 2 ~ end 8

and step = 3;

i want  2, 5, 8

coding) 

NAxis axisx = chart.Axis(StandardAxis.PrimaryX);

 axisx.View = new NRangeAxisView(new NRange1DD(2, 8), true, true);

 NLinearScaleConfigurator scale = axisx.ScaleConfigurator as NLinearScaleConfigurator;
 scale.MajorTickMode = MajorTickMode.CustomStep;
 scale.CustomStep = 3;

result)  3 ,  6

why not start from 2 ? Help me

By Nevron Support - Monday, July 2, 2012

Hi Lee,

When you apply a range view to the axis this will not modify the scale tick origin (0 by default). This is by design. In order modify the tick origin you need to specify a new origin for the ticks - scaleX.Origin = 2:

   NChart chart = nChartControl1.Charts[0];
   NBarSeries bar = new NBarSeries();

   Random rand = new Random ();
   for (int i = 0; i < 10; i++)
   {
    bar.Values.Add(rand.Next(100));
   }

   bar.DataLabelStyle.Visible = false;

   chart.Series.Add(bar);

   NAxis axisX = chart.Axis(StandardAxis.PrimaryX);
   axisX.View = new NRangeAxisView(new NRange1DD(2, 8), true, true);

   NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator();
   axisX.ScaleConfigurator = scaleX;
   scaleX.MajorTickMode = MajorTickMode.CustomStep;
   scaleX.CustomStep = 3;
   scaleX.Origin = 2;

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

 

 

By lee kc - Tuesday, July 3, 2012

Thank you Very Much.