• Recent
    • Tags
    • Popular
    • Register
    • Login

    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.

    Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website Mango 5 Documentation Website

    SVG ng-bind Rounding numbers

    User help
    3
    4
    1.4k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      Gordoe
      last edited by

      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>
      
      
      1 Reply Last reply Reply Quote 0
      • phildunlapP
        phildunlap
        last edited by phildunlap

        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

        1 Reply Last reply Reply Quote 0
        • ThomasEinastoT
          ThomasEinasto
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • phildunlapP
            phildunlap
            last edited by phildunlap

            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 use acmain.convertedValue instead of acmain.value

            I like the idea of a page setting for the precision!

            1 Reply Last reply Reply Quote 0
            • First post
              Last post