Setting the axis range


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

By cho seongho - 5 Years Ago

I am using a line chart that uses "XValues". I want to display the specific X-axis range I want whenever data is updated. However, when I enter the data, it appears that the range is set to the value of the input data.
In my opinion, it seems that the range beyond the input value is not set.

I implemented it with reference to your sample code but it does not work.The code is shown below.
For example, in the following cases, the X axis range is set from 0 to 40 on the screen, but I want to set it from 0 to 100.

https://www.nevron.com/forum/uploads/images/d386dd31-d038-4d92-b58d-2713.png



NNumericAxisPagingView pagingView = m_chart.Axis(StandardAxis.PrimaryX).PagingView as NNumericAxisPagingView;

pagingView.Begin = xAxis.ContentRange.Begin;
pagingView.Length = 100;

//m_chart.Axis(StandardAxis.PrimaryX).PagingView.ZoomIn(new NRange1DD(xAxis.ContentRange.Begin, 100), 0.1);   This also does not work

nChartControl1.Refresh();

By Nevron Support - 5 Years Ago
Hi Cho,
You need to set the axis View - for example:
   NChart chart = nChartControl1.Charts[0];

    NLineSeries line = new NLineSeries();
    chart.Series.Add(line);
    Random rand = new Random();

    line.UseXValues = true;
    line.DataLabelStyle.Visible = false;

    for (int i = 0; i < 40; i++)
    {
      line.Values.Add(rand.Next(100));
      line.XValues.Add(i);
    }

    chart.Axis(StandardAxis.PrimaryX).View = new NRangeAxisView(new NRange1DD(0, 100), true, true);
    chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = new NLinearScaleConfigurator();
this will allow you to set a different range than the one that is automatically calculated based on the chart content. Let us know if you have any questions.