Chart scrollbar not working


Author
Message
cho seongho
cho seongho
Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)Forum Newbie (9 reputation)
Group: Forum Members
Posts: 15, Visits: 73

I'm implementing a real-time chart, and I'd like to control the scrollbar to show the latest input values.

However, if you use "PagingView" to set the range shown on the screen, and keep typing the value, the scroll bar will always be in the initial position. So I added the code below but it does not do anything.
Chart is set to NumericAxisPagingView.


 private void Timer_Tick(object sender, EventArgs e)
        {
            double y1 = random.NextDouble();
            m_lineSeries.XValues.Add(x);
            m_lineSeries.Values.Add(y1);

            x += 1.0;

            nChartControl1.Charts[0].Axis(StandardAxis.PrimaryX).View = new NRangeAxisView(new Nevron.GraphicsCore.NRange1DD(x - 10, x), true, true); //Not work
            nChartControl1.Charts[0].Axis(StandardAxis.PrimaryX).PagingView.ViewRange = new Nevron.GraphicsCore.NRange1DD(x - 10, x); //Not Work
            nChartControl1.Charts[0].Axis(StandardAxis.PrimaryX).Pagi ngView.SetRange(new Nevron.GraphicsCore.NRange1DD(x - 10, x), false); //Not Work

            nChartControl1.Charts[0].Axis(StandardAxis.PrimaryX).PagingView.ScrollToValue(x - 10); //Not Work

            nChartControl1.Charts[0].Axis(StandardAxis.PrimaryX).UpdateScale();
            nChartControl1.Charts[0].Refresh();

            nChartControl1.Refresh();
        }


I want sample code that can control the scrollbar position with code.


Reply
Nevron Support
Nevron Support
Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)Supreme Being (4.5K reputation)
Group: Administrators
Posts: 3.1K, Visits: 4.2K
Hi Cho,
Thank you for your interest in Nevron Chart for .NET.
The following code shows how create a realtime chart has a scrollbar positioned at the end of the range:
  Random m_Rand = new Random();

   private void Form1_Load(object sender, EventArgs e)
   {
    NChart chart = nChartControl1.Charts[0];

    NBarSeries bar = new NBarSeries();
    bar.DataLabelStyle.Visible = false;
    chart.Series.Add(bar);

    chart.Axis(StandardAxis.PrimaryX).PagingView = new NNumericAxisPagingView();

    nChartControl1.Controller.Tools.Add(new NPanelSelectorTool());
    nChartControl1.Controller.Tools.Add(new NAxisScrollTool());

    timer1.Start();
   }

   private void timer1_Tick(object sender, EventArgs e)
   {
    NChart chart = nChartControl1.Charts[0];

    NBarSeries bar = chart.Series[0] as NBarSeries;

    bar.Values.Add(m_Rand.Next(100));

    if (bar.Values.Count > 10)
    {
      while (bar.Values.Count > 100)
      {
       bar.Values.RemoveAt(0);
      }

      nChartControl1.RecalcLayout();

      NAxis xAxis = chart.Axis(StandardAxis.PrimaryX);
      chart.Axis(StandardAxis.PrimaryX).ScrollBar.Visible = true;
      chart.Axis(StandardAxis.PrimaryX).PagingView.ZoomIn(new NRange1DD(xAxis.ContentRange.End - 10, xAxis.ContentRange.End), 0.1);
    }

In this example the scrollbar will appear when the number of data points is above 10. Also keep in mind that it is a good idea to remove data points after a certain threshold to reduce computations.
Please let us know if you have any questions or meet any problems.



Best Regards,
Nevron Support Team


GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...





Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search