I'm trying to create a bar chart with an xy chart, the problem is that I want to create a category for each machine with data from the historian tag where the data is kWh which continues to increase in value without resetting. 1 bar represents 1 month of kWh usage so the data is kWh now-kwh prev, is it possible?, I'm still new to ignition
You may want something like this
you have to play with the datasources ans series to get familiar with the xy charts for multiple values
The main thing is to get your data into the right format - with the SQL query if possible. Where's the data coming from and what database engine are you using?
Thank you, that helps, but I've encountered a new problem: if the series is in bar format, and for example, I have three series and three data sources, the bar charts don't appear simultaneously but one by one.
One solution I found was to make the data look like this:
And I found a new problem. how to make the data like that. I used data from the historian tag where the value continues to increase, so I had to do data retrieval like last month = end of last month - beginning of last month
For that you shoule prepare your data before showing it, with a transform script in jython for example. You bind the data to a custom property custom.dataretrieval then inside you do the operation last month = end of last month - beginning of last mont , then you bind the output to the serie you want it into.
from java.util import Calendar
# End of last month
end = Calendar.getInstance()
end.set(Calendar.DAY_OF_MONTH, 1)
end.add(Calendar.DAY_OF_MONTH, -1)
# Beginning of last month
start = Calendar.getInstance()
start.set(Calendar.DAY_OF_MONTH, 1)
start.add(Calendar.MONTH, -1)
# Optional: normalize times
start.set(Calendar.HOUR_OF_DAY, 0)
start.set(Calendar.MINUTE, 0)
start.set(Calendar.SECOND, 0)
end.set(Calendar.HOUR_OF_DAY, 23)
end.set(Calendar.MINUTE, 59)
end.set(Calendar.SECOND, 59)
print start.getTime()
print end.getTime()
or the code that may suit you
Alejandro, why are you recommending a Java library when Ignition scripting has a pretty full set of system.date | Ignition User Manual functions which will be more efficient?
Update: It turns out the query binding method is more useful, just a few adjustments needed. The downside is that I need to know the tag ID I want to query by looking at the dbo.sqlth_te table.
Thanks, @Alejandro_Alaco and @Transistor for your help in solving this.


