Profile Picture

Chart scrollbar not working

Posted By cho seongho 5 Years Ago

Chart scrollbar not working

Author
Message
cho seongho
Problem Posted 5 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 3 Years Ago
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.



Nevron Support
This post has been flagged as an answer
Posted 5 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,018
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



cho seongho
Posted 5 Years Ago
View Quick Profile
Forum Newbie

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
Last Active: 3 Years Ago
Posts: 15, Visits: 73
I am using your solution well. Thank you.
I have additional questions.
The current method does not work if I use a DateTime with an X axis value.
I want to use DateTime as the X axis value.
I also want to set a specific range when using DateTime like the above answer.

please answer about my question. Thank you.

Nevron Support
Posted 5 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,018
Hi Cho,
The code above will work if the axis is date time - the only difference between handling double and date time is that when you pass date time values to the control you need to convert them to double using the ToOADate() method - for example:
someDateTime.ToOADate();
return the double equivalent of the the date time object, similarly:
DateTime.FromOADate(someDouble);
return the date time equivalent of the passed double value.
Hope this helps - let us know if you meet any problems.

Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic

1 active, 1 guest, 0 members, 0 anonymous.
No members currently viewing this topic!