Charts - Directly Display Live Data From SQL Tags

Does anyone know how to directly display the value of a SQL Tag in a chart (bar, graph, or pie) without querying the database?

I have a client that would like to convert an Allen Bradley Panelview Plus project over to a Vision Panel but the one hang up is that the Panelview Plus has a few live trends that operators use for setting up the machine and I don’t see away to do this without have external database.

1 Like

I have used a timer with some scripting to create a dataset that can be charted. However, the data is only temporary - it lives in real-time on the window, so any project updates, window closures, etc. delete the data… Another option is to talk with your sales rep to see if you can get a tag-limited / client-limited Vision module so that you still have DB access without multiple clients.


That’s what I’m looking to do. Can you post a sample of your script?

Inductive Automation Delevopers,

It would be nice to be able to just add the SQL tags to a chart without having to create a script.


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.

I’m sure the others can do it much more eloquently, but here is the actionPerformed script I put into a timer object, and using a chart component. I used the values from the OPC simulator.

#get current time
from java.util import Date
currentDateTime = Date()

#read SQL tag values you want
tagValue1 = system.tag.getTagValue(’[]Overview/Motor 1/Amps’)
tagValue2 = system.tag.getTagValue(’[]Overview/Motor 2/Amps’)

#assemble data into an array
newRow = [currentDateTime,tagValue1,tagValue2]

#read old dataset and append the new row
ds1 = event.source.parent.getComponent(‘Chart’).Data
ds1 = system.dataset.addRow(ds1,newRow)

#pass updated dataset back to the chart
event.source.parent.getComponent(‘Chart’).Data = ds1