Results 1 to 4 of 4

Thread: Rookie Question on Charts

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2014
    Posts
    11

    Rookie Question on Charts

    I'm trying to make some live charts, for a software, used to monitor the current status of Wind Turbines.
    For instance, I'm making a chart that on uptime / downtime.
    How do I make my timer add 1 point to a certain line, per tick?

  2. #2
    Frenzied Member IanRyder's Avatar
    Join Date
    Jan 2013
    Location
    Healing, UK
    Posts
    1,232

    Re: Rookie Question on Charts

    Hi,

    The trick here is to create a New DataPoint for each Tick of the Timer and specify the values for the X and Y axis. Then, using the Chart Series Points Collection of the chart to be modifed, you can then Remove the existing first item in the chart series and finally Add the new DataPoint to the end of the Point collection. This then has the effect of a nicely animated rolling chart in real time. i.e:-

    vb.net Code:
    1. Dim DP As New DataPoint
    2. With DP
    3.   .AxisLabel = Now.ToLongTimeString
    4.   .YValues(0) = YourYValue
    5. End With
    6.  
    7. With Chart1.Series(0).Points
    8.   .RemoveAt(0)
    9.   .Add(DP)
    10. End With

    Hope that helps.

    Cheers,

    Ian

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2014
    Posts
    11

    Re: Rookie Question on Charts

    Quote Originally Posted by IanRyder View Post
    vb.net Code:
    1. Dim DP As New DataPoint With DP End With
    I can't dim as new DataPoint

  4. #4
    Frenzied Member IanRyder's Avatar
    Join Date
    Jan 2013
    Location
    Healing, UK
    Posts
    1,232

    Re: Rookie Question on Charts

    Hi,

    Whenever you get an error with regards to something that it not defined then the first thing to do is to read the Documentation for that object so that you can see if there is something that you may have missed. If you read this:-

    DataPoint Class

    You will then know that you need to add a Reference to the System.Windows.Forms.DataVisualization Assembly and then you need to Import the Namespace System.Windows.Forms.DataVisualization.Charting.

    Once you have done that you are good to go.

    Cheers,

    Ian
    NB. As an additional note you also need to remember to tell us what your errors are rather than making us guess. Your next issue will then be that With Block at the end of your variable declaration.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width