SVG ng-bind Rounding numbers
-
I'm wondering if there is a simple way to round the numbers that are being bound to the SVG ID's
Any assistance would be greatly appreciated! Thanks<ma-svg ng-include="'/rest/v2/file-stores/default/BuildingA.svg'"> <!-- Mains --> <div ma-selector="#amainac tspan" ng-bind="acmain.renderedValue"></div> </ma-svg> <!-- AC Power --> <ma-get-point-value point-xid="DP_797e71a8-87e8-4b30-984f-4dcdbdd0d80e" point="acmain"></ma-get-point-value>
-
Hi Gordoe,
Have you tried the AngularJS number filter? https://docs.angularjs.org/api/ng/filter/number
I would also expect that because you're using the rendered value, you could have set the desired number of decimals in the analog renderer's format string. Also note that you may need to slice off the units text as occurred here: https://forum.infiniteautomation.com/topic/3686/problem-with-pie-chart
-
Several options are available like @phildunlap said.
Following way is more functional by using ng-init to define units and rounding and then using .value on the filter... This way you do not need to slice off the units on the text...
<ma-svg ng-init="units='kW'; rounding=3" ng-include="'/rest/v2/file-stores/default/BuildingA.svg'"> <!-- Mains --> <div ma-selector="#amainac tspan" ng-bind="(acmain.value | number:rounding) + units"></div> </ma-svg> <!-- AC Power --> <ma-get-point-value point-xid="DP_797e71a8-87e8-4b30-984f-4dcdbdd0d80e" point="acmain"></ma-get-point-value>
Thomas
-
Interesting suggestion Thomas!
For that matter, one could use
acmain.units
(or perhaps you would get it from the text renderer suffix if it's set up that way) and avoid having to keep the markup's units matching the points'. And should one have a converting unit, one could useacmain.convertedValue
instead ofacmain.value
I like the idea of a page setting for the precision!