[Bug-702]8.1.0-rc2 Sparkline not displaying data values

We just upgraded from 8.0.12 to 8.1.0-rc2. Our Perspective project with Sparklines worked great prior to the upgrade. The sparkline displays machine speeds from tag history for current to 12 hours prior. Now, I get a red shade with green line and no data points on the Sparkline. The data table is 2 columns and 100 entries. Any idea why it doesn’t draw the sparkline anymore?
sparkline_fail


Anyone else seeing the same problem?

I see that as well. I’ve opened an internal ticket to get this fixed.

Good news: We already completed and tested a fix which was merged into 8.1.0 and will be part of the stable release. You won’t see this in the nightly releases, but as I said it WILL be in 8.1.0 stable.

One thing you can do in the meantime is apply a transform to your data:

	points = []
	for i in range(0, len(value)):
		points.append({'x': i, 'y': value[i]['<your_Marquip_N_column_name>']})
	return points
1 Like

I created the transform as advised and I receive the Error_ScriptEval.

Post the code via the </> button so we can help edit it. :smiley:

However I would say that you should change

'<Marquip_Net_Sheets_Per_Hour>'

to

'Marquip_Net_Sheets_Per_Hour'
def transform(self, value, quality, timestamp):
	"""
	Transform the incoming value and return a result.

	Arguments:
		self: A reference to the component this binding is configured on.
		value: The incoming value from the binding or the previous transform.
		quality: The quality code of the incoming value.
		timestamp: The timestamp of the incoming value as a java.util.Date
	"""
	points = []
	for i in range(0,len(value)):
			points.append({'x': i, 'y': value[i]['Marquip_Net_Sheets_Per_Hour']})
	return points

same result

If you hover over the error what does it say?

image

Your data format is dataset. Try changing it to JSON. There is no len() for a dataset.

The dataset is from the Tag Historian. I’m not sure how to convert it to a JSON…

Changing value type from DataSet to Document and making the coding change you suggested seems to work. Thank you for your help!

Awesome!

Yeah I don’t have 8.1 yet. Should probably grab it.

The value format is handy to know about. Some controls want datasets, others JSON/DOCUMENT.

Hey guys,

I’m having an issue getting this to work with some indirection I am using. I have a sparkline template that I am passing the parameters to in order to pull the tag history.

I tried to manipulate the script to make it pull the tag .name value, which should by default be used as the column name but it is just returning a ScriptEval error.

Any ideas?

	points = []
	tagPath = self.view.params.key[0].path + ".name" 
	tagName = system.tag.read(tagPath)
	
	for i in range(0, len(value)):
				points.append({'x': i, 'y': value[i][tagName]})
	return points

image

Don’t do this. This tag read is going to loop and read that value for EVERY time the binding updates.

The reason you’re getting a recursion error is because you’re attempting to shoehorn in a Qualified Value instead of a simple value. The following change to your code will result in the code working, but you’re going to have a huge performance hit in larger views if you continue to look up the tag value in the transform:

    # make sure you double-check the line indentations - your posted code has too many tabs in the for loop
    for i in range(0, len(value)):
		points.append({'x': i, 'y': value[i][tagName.value]})
	return points
1 Like

for some reason this works about 50% of the time. If i am currently displaying the page in a browser and I save the project i get some values but not all. If I navigate away from the page and go back, the components are faulted again with the same fault.

I take it there’s probably not a better work around for now in my situation?

What works for you 50% of the time?

Can you share your code as it is right now?

	points = []
	tagPath = self.view.params.key[0].path + ".name" 
	tagName = system.tag.read(tagPath)
 
	for i in range(0, len(value)):
		points.append({'x': i, 'y': value[i][tagName.value]})
	return points

If I update project while on the page the sparklines are located I get:
screenshot.296

If I navigate away from the page and come back I get:
image

Oh, it’s because you’re using the params of the View. What is the param value being specified? Are you defaulting back to a static value?

try inserting

system.perspective.print(tagName.value)

just before your for loop. Then look in the Browser console to see what values you’re actually getting during the scenario you’re describing.

  1. Right-click your view in a session, and select “Inspect”.
  2. In the resulting window, click the “Console” tab, and then run through your scenario.

Thank you, that helped.

For some reason I had the param set up as I/O instead of just input.

Thanks!

There was a known performance issues with the Sparkline component in RC1 and RC2. A side effect of the work we’ve been doing to improve performance overall. The issue has since been addressed in RC3, along with several other important changes. I’d highly recommend upgrading. Thank you.