Scalable Trend Graph in viewON

How do you scale a tag value in the trend component in viewON?

When you select your tag, there is an option to use BASIC Script instead of using an eWON or viewON Tag. I guessed it would be:

a% = tag_val@
a% = a% / 10
viewon! = a%

However this doesn’t even let the form load.

Thanks a lot

@tomcs123

Is the intention to have the value scale globally or solely for the graph? If it is global we can actually just scale it at the tag level but if it is for the graph we will need to definitely do some scripting.

Can you confirm whether this should be global or just for the graph?

Yes it’s solely for the graph. If I do it globally I will lose the decimal point. If I do it within the webpage then I lose the historical data. So I need full resolution but scaled only for the trend graph.

Thanks

@tomcs123

Using the built in trend graph it is going to be somewhat challenging to accomplish. What I would recommend is actually creating a duplicate tag in your eWON and scale that one per your requirements. This would allow you to maintain the existing tag however you will have your scaled revision as well.

Now because this is cross-referencing two tags, you will need a script that will maintain the scaling and assign the tag value. Please take a look at the below example:

Tag Name IOServer Tag Address
MainTag Your IOServer Your address
MainTagDuplicate MEM Blank



Now that we have our tags created we can actually write a very simple script that will detect when MainTag changes and will scale and assign MainTagDuplicate at the same time.

Script Example

INIT Section
ONCHANGE "MainTag", "GOTO DuplicateEdit"

DuplicateEdit Section:
MainTagDuplicate@ = MainTag@ / 10  //I am simply dividing by 10 but you can do any scaling desired. 
END



That is it! You can now import your new duplicate tag into ViewOn and use that tag in your trend.

Does it look like this will work for you?

Thanks,

I did think of this solution, but thought if there was an easy way to do it in the BASIC Editor of the trend graph, it would be more efficient and save processing space.

I actually realised it is easier to just /10 in the tag setup. At first I was loosing a decimal place but I realsied I can just set it to float then this works nicely throughout the whole eWON.

Thanks

@tomcs123

Excellent! Thank you for the follow-up.