If you are doing a live trend and you want to keep adding to a dataset, you could add a date dynamic property to the Root Container bound to:now(5000)
That will make the property refresh every 5 seconds. You can then add a Property Change script on the Root Container with the following code:from java.util import Date
if event.propertyName == "date":
chart = event.source.getComponent('Chart')
val1 = system.tag.getTagValue("RAMP/RAMP1")
val2 = system.tag.getTagValue("RAMP/RAMP2")
chart.Data = system.dataset.addRow(chart.Data, [Date(), val1, val2])
If you want to make it a rolling chart do this:[code]from java.util import Date
if event.propertyName == “date”:
chart = event.source.getComponent(‘Chart’)
val1 = system.tag.getTagValue(“RAMP/RAMP1”)
val2 = system.tag.getTagValue(“RAMP/RAMP2”)
if chart.Data.getRowCount() > 60:
chart.Data = system.dataset.deleteRow(chart.Data, 0)
chart.Data = system.dataset.addRow(chart.Data, [Date(), val1, val2])[/code] Here you delete records older then 5 minutes ago.
Note *: The above example assumes your dataset already has these three columns t_stamp as datetime, val1 as float and val2 as float. You can go into the dataset editor to add/edit/remove these columns.
If the number of rows in your dataset is static you can just use the cellUpdate binding to dynamically change a cell’s value. Hope this helps.