Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.
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.convertedValueinstead ofacmain.valueI like the idea of a page setting for the precision!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login