Apex Chart problem with tag history formatting

Good morning guys,
I’m having problem showing data in a chart (line or area) using Apex Chart… after some try and some help I figure out that the exactly structure to show data is this (with “0” as t_stamp and “1” as value) and it work
chart 1

The problem is that I can’t make it work with tag history, I bind the “data” property of the series and I select the tag and I set as in picture (I even tried to change “Value format” from Dataset to Document )

and the result is that the structure could be correct, but instead of “0” as t_stamp and “1” as value, I have the names saved in the database.

What do I wrong guys?

You could change the format of the data with a script transform. I got it to work with this:

return [[row['t_stamp'], row['tag_name']] for row in value]

Keep the return type as document and replace tag_name with the name of your tag (or give the tag an alias of tag_name).

1 Like

Great! This is working perfectly, thanks a lot for the help.

Is strange that it must be done with a transformation like this the data loading. Anyway thanks again, this is very helpful

You can also just populate the ‘alias’ column in your screenshot to avoid the spaces, which is the cause of the “error” in the properties.

1 Like

I made some test but if I populate the alias column I just change the Y values, or is there a way to alias both X and Y?

You don’t need to alias the X values. The “error” you are seeing is from the spaces that are in your tag name. That is why only those values have the read highlight.

Actually I’ve just make a try and even if I show a tag with no spaces, it’s not showed …

Are any of those values greater than 0?

Yes sorry for the screenshot, the arrays after the [4] index are populated with actual temperature

What does the trend look like?

The chart shows NaN if I try to x-trace it

Is there an easy way to bind Apex Chart to Tag History?
When adding script transform, values are still not shown.

1 Like