Dynamically adding data with a preset xaxis range

3 posts, 0 answers
  1. Brett Robichaud
    Brett Robichaud avatar
    24 posts
    Member since:
    Feb 2009

    Posted 12 Feb 2012 Link to this post

    I am trying to create a line chart that will be filled in real-time over a 2hr time period. It will be something like PerfMon in that I will start with just 1 data point and each minute I will add a new one until I reach 2hrs, at which time the first data point is removed, and from then on I show the last 2hrs of data with the line data scrolling each minute.

    I have made this work by simply adding to the list the chart is data bound to. But the xaxis changes every minute to accommodate the new data point, up until 2hrs. I'd like to preset the xaxis to show 2hrs in 1min increments even though I don't have data yet. Is this possible?

    I thought about prefilling the databound list with values of 0, but then the line chart looks odd because it goes to zero for all future points. How else could I accomplish this?
  2. Petar Marchev
    Admin
    Petar Marchev avatar
    968 posts

    Posted 15 Feb 2012 Link to this post

    Hello,

    Is it possible to set the AutoScale property of the XAxis to false initially with appropriate minimum and maximum? Then when the data gets populated with 2 hours, you can set it to true again.

    Kind regards,
    Petar Marchev
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Brett Robichaud
    Brett Robichaud avatar
    24 posts
    Member since:
    Feb 2009

    Posted 15 Feb 2012 Link to this post

    I actually decided on another approach that seems to work well enough. I preloaded the list my chart is bound to with empty values for the full 120 increments. Then I add to the end of the list as I get new data. This eliminates the problem I was seeing when I then added to the front of the list (the chart going to zero). The side effect of course is that the initial data slides in from the right hand side, but I am ok with that effect.

    Thanks for the help.
Back to Top