I always have issues with bar charts on vision and getting them to setup properly as the coding behind them is so over complicated. I have the following data table from a named query I would like to display all the values. For some reason any repeat values from the table number column will only display one of them. Any ideas on how I can display all of them as individual bars?
Here is the query:
SELECT TOP 10
TableNum,
schedOverTimemins
FROM Tables_Data_East_V2
WHERE t_stamp BETWEEN (:StartDate) AND (:EndDate)
ORDER BY schedOverTimemins DESC
Column names must be unique. I would add a rank to the table name. The method may differ depending on the database you're using.
TableNum | schedOverTimemins
1-11 | 275
2-15 | 205
3-9 | 185
4-8 | 163
5-10 | 153
6-15 | 145
7-7 | 144
8-9 | 143
9-8 | 130
10-15 | 129
This data is being pulled from a large SQL table that automatically is being filled by transaction groups and other queries are also referencing so I do not have the ability to add a rank to every input for table numbers in the SQL table. Maybe this can be done in the named query? The bar chart will also need to auto update when a new number enters the top 10. Is there is no way to just simply display the data table exactly as is? (I guess this is why I avoid bar charts in ignition at all costs)
The rank would be part of the named query.
Alternatively:
- Add a custom property called rawData
- Bind rawData to the named query
- add a propertyChanged script
if event.propertyName == 'rawData':
rawData = event.source.rawData
headers = list(rawData.getColumnNames())
data = []
for i in range(rawData.getRowCount()):
data.append(['{}-{}'.format(i+1, rawData.getValueAt(i,0)), rawData.getValueAt(i,1)])
event.source.data = system.dataset.toDataSet(headers, data)

Thank you very much the custom property worked. I always forget about those.