Dynamic bar chart

Good evening. My name is Felipe. I received today from the manager of the company that I work on the task of creating a dynamic bar graph (or something similar to a bar graph), whose goal is to increment a new bar hourly and delete the last bar from the graph. in the image below I used the cylinder tank components to exemplify what I mean. I used the MES Analysis Controller component to generate hourly production information and record the hourly efficiency value in each tank based on the following equation:

({Root Container.RCEfficiency.ACDeco22.data}[6,1]/(60*2000))*100

In the example below, the MES Analysis Controller component generated values ​​until 12:00 and the idea would be that as soon as the hourly production information from 1 pm appears, the 7:00 information from the graph disappears, as well as the time at 2 pm appears. 8 am bar disappeared and so on. I exhausted my attempts and the forum has helped me a lot and I appreciate the help and each one. thank you so much.

I really don’t know if it’s possible, but I appreciate the help of each one

image
image

I suggest to make your bar chart a category chart and use the times as the individual categories.

I may have to backtrack a bit. Does the chart itself work, and you need help in populating the dataset?

to fill the data set I can do it, because the startDate I stayed at 7:00 in the morning and the endDate I put now(600), so that it would provide me with the values ​​in real time since the start of the shift. I set Group By “Hour interval” to provide me with hourly information. The difficulty is that I wanted that when the difference between startDate and endDate was greater than 10 hours, for example 7:00 am and 5:00 pm, when it was 6:00 pm the 7:00 am time of the bar graph would disappear, giving way to bar at 6 pm. when it was 7 at night the 8:00 am time would disappear and so on. I don’t know if I managed to be clear

This function will return the last n rows in a dataset.

def lastNRows(datasetIn, numRows):
	# Check to see if processing is required
	if datasetIn.getRowCount() <= numRows:
		return datasetIn
	else:
		# Convert to pyDataSet
		pyDataSet = system.dataset.toPyDataSet(datasetIn)
		return system.dataset.toDataSet(pyDataSet[-numRows:])

Sample:

# Make sample dataset
headers = ['letter', 'number']
data = [['A', 1],
        ['B', 2],
        ['C', 3],
        ['D', 4],
        ['E', 5],
        ['F', 6],
        ['G', 7],
        ['H', 8],
        ['I', 9],
        ['J', 10],
        ['K', 11],
        ['L', 12],
        ['M', 13],
        ['N', 14],
        ['O', 15],
        ['P', 16]
       ]       
dataSet = system.dataset.toDataSet(headers, data)

# Get last 5 rows
newDataSet = lastNRows(dataSet, 5)

dataSet:

row | letter number
-------------------
 0  | A      1     
 1  | B      2     
 2  | C      3     
 3  | D      4     
 4  | E      5     
 5  | F      6     
 6  | G      7     
 7  | H      8     
 8  | I      9     
 9  | J      10    
 10 | K      11    
 11 | L      12    
 12 | M      13    
 13 | N      14    
 14 | O      15    
 15 | P      16    

newDataSet:

row | letter number
-------------------
 0  | L      12    
 1  | M      13    
 2  | N      14    
 3  | O      15    
 4  | P      16    

Sample when there are less rows than the threshold:

headers = ['letter', 'number']
data = [['A', 1],
        ['B', 2],
        ['C', 3]
       ]       
dataSet = system.dataset.toDataSet(headers, data)

# Get last 5 rows
newDataSet = lastNRows(dataSet, 5)

dataSet:

row | letter number
-------------------
 0  | A      1     
 1  | B      2     
 2  | C      3   

newDataSet:

row | letter number
-------------------
 0  | A      1     
 1  | B      2     
 2  | C      3   
1 Like

what a spectacular job @JordanCClark. Thank you very much for all your help.

It Worked Perfectly

1 Like