Nevron Forum

Problem plotting cordinates on x and y axis

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

By Radhika Palakurthi - Wednesday, August 1, 2012

Hi,

I am new to nevron charts I am trying to plot a graph with x-axis values starting from 1 to 53 and y-axis values starting from some min value to max value based on the business logic with custom step set to 50, but it always starts with 0. Also the x-axis is not able to accommodate all values from 1 to 53 , it pics randomly from 5, 10,15 and so on.., I have posted the code below. Any help would be highly appreciated.

NchartCtrl.Clear();
this.ColorDef();
string[] menuvalues = Getmenuselectedvalue();

this.CustomDivisionId = int.Parse(menuvalues[0]);
this.RegionId = int.Parse(menuvalues[3]);
this.AccountId = int.Parse(menuvalues[2]);

DataSet ds = this.LoadDS(this.CustomDivisionId, this.RegionId, this.AccountId);

// set a chart title
NLabel title = NchartCtrl.Labels.AddHeader("PAP -Initial View");
title.TextStyle.FontStyle = new NFontStyle("Times New Roman", 14, FontStyle.Italic);
title.TextStyle.ShadowStyle.Type = ShadowType.LinearBlur;

NchartCtrl.BackgroundStyle.FrameStyle.Visible = false;
NChart chart = NchartCtrl.Charts[0];
chart.BoundsMode = BoundsMode.Stretch;
NchartCtrl.Legends.Clear();


NAxis axis = chart.Axis(StandardAxis.PrimaryY);
NLinearScaleConfigurator scale = axis.ScaleConfigurator as NLinearScaleConfigurator;

int cnt = 50;
axis.View = new NRangeAxisView(new NRange1DD(0, 200), true, true);
scale.RoundToTickMax = false;
scale.RoundToTickMin = false;
scale.MajorTickMode = MajorTickMode.CustomStep;
scale.CustomStep = cnt;



NAxis axis1 = chart.Axis(StandardAxis.PrimaryX);
NLinearScaleConfigurator scale1 = axis.ScaleConfigurator as NLinearScaleConfigurator;

axis1.View = new NRangeAxisView(new NRange1DD(1, 52), true, true);
scale1.RoundToTickMax = false;
scale1.RoundToTickMin = false;
scale1.MajorTickMode = MajorTickMode.CustomStep;
scale1.CustomStep = 1;

chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true;
chart.Axis(StandardAxis.PrimaryY).ScrollBar.Visible = true;
By Nevron Support - Friday, August 3, 2012

Hi,

We modified the code a little, please give it a try and let us know if it works as you expect. Please note that the Y axis range is set to [100, 200] instead of the original [0, 200] that was specified in your code. This is only to demonstrate that it doesn't need to always start from 0.

   NAxis axisY = chart.Axis(StandardAxis.PrimaryY);
   NAxis axisX = chart.Axis(StandardAxis.PrimaryX);

   NLinearScaleConfigurator scaleY = axisY.ScaleConfigurator as NLinearScaleConfigurator;
   scaleY.RoundToTickMax = false;
   scaleY.RoundToTickMin = false;
   scaleY.MajorTickMode = MajorTickMode.CustomStep;
   scaleY.CustomStep = 50;

   NLinearScaleConfigurator scaleX = new NLinearScaleConfigurator();
   scaleX.RoundToTickMax = false;
   scaleX.RoundToTickMin = false;
   scaleX.MajorTickMode = MajorTickMode.CustomStep;
   scaleX.CustomStep = 1;

   axisX.ScaleConfigurator = scaleX;

   axisX.View = new NRangeAxisView(new NRange1DD(1, 52), true, true);
   axisY.View = new NRangeAxisView(new NRange1DD(100, 200), true, true);

   axisX.ScrollBar.Visible = true;
   axisY.ScrollBar.Visible = true;