Adding string value from another tag to Easy Chart X-Trace Label

Hello everyone!
I am working on configuring an Easy Chart to display data for some storage bins. For the Bins I have two tags, both with history enabled. One tag is for the bin level with a float data type and the other tag is for product type with a string data type. Now I know the Easy Chart will not track string data which is kind of where the problem starts. As stated in the title, I am trying to add that string value to the X-Trace Label. I have the script figured out to the point of adding another line to the label, which looks like this now

def getXTraceLabel(self, chart, penName, yValue):
    if self.selectedXValue:
        return "Level: " + str(yValue) + "\n Product: " + str(self.group_Product)

self.group_Product is bound to the realtime tag, but I was wondering if it were possible to pull the historical Product Label tag value into this custom property? As you could probably see I was trying to do that originally with label above the empty template box and the table in the bottom left corner. Ideally the X-Trace label will show what the level was and what product was in the bin at the specified time marked by the X-Trace

I know this could be accomplished by changing the data type in the PLC to an INT, but the integrator for this line is based out of Italy and would have to wait until he is on-site again. Buying a third party module is not an option for me either.
I feel like I am so close but still cant figure this out, any help would be appreciated.

How do you create a custom property on an easy chart in 8.1?

I don't know how you could bind it, but you could probably script a tag history query for the desired value off of the easy chart's property change event handler:
It would look something like:

if event.propertyName == 'selectedXValue':
	tagPath = '[default]Whatever/your/tagPath/is
	tagHistory = system.tag.queryTagHistory([tagPath], system.date.parse(event.source.selectedXValue))
	dataPoint = tagHistory.getValueAt(0,1) if tagHistory.rowCount > 0 else None
	event.source.group_Product = dataPoint

Sorry, that is my bad. I meant Dynamic Group and not custom property. I even got it figured out at the end of the work day yesterday. I'll share the write up in a separate reply.

Happy to say I accomplished what I needed thanks to some IA support. The solution was actually fairly simple with a bit of scripting that was new to me.

First thing to do is make a custom property for the root container that is a dataset. Use a tag history binding on that to populate the data you need using the start and end dates of the Easy Chart on the start and end date properties in the tag history. (Depending on how often the tag is writing to the DB you might run into a problem but we fix that with scripting) That looks like this.

Next thing is scripting of the getXTraceLabel extension function. set to parameters, one to parse the selectedXValue from system.date, and one to convert the dataset that was made earlier to a PyDataSet. then scripting to find the value at the specified time from the PyDataSet. The script looks like this.

def getXTraceLabel(self, chart, penName, yValue):
	date = system.date.parse(self.selectedXValue)
	data = system.dataset.toPyDataSet(self.parent.Product)
	
	for x in range(data.getRowCount()):
		if date >= data[x][0] and date < data[x+1][0]:
			return "Level: " + str(yValue) + "\n Product: " + str(data[x][1])

and then one final script on the Easy Chart mouseMoved event handler so that the X-Trace shows up whenever you move the mouse over chart.

event.source.setMode(4)
1 Like