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

  • Hello.

    Im working with dashboards and I want to generate point statistics. Everything is working fine, but I have one problem.

    Im using this code from example:

    <ma-point-statistics point="myPoint" from="from" to="to" statistics="statsObj"></ma-point-statistics>
    
    
    
    <div>The average for the period is {{ statsObj.average.value }} at {{ statsObj.average.timestamp | moment:'format':'lll' }}<br>
         The max value for the period is {{ statsObj.maximum.value }}
         <br>
         {{ statsObj.last.value - statsObj.first.value }} L
         <br>
         {{ statsObj.last.value }}
         <br>
         {{ statsObj.first.value }}
    </div>
    

    And the problem is that

    {{ statsObj.last.value - statsObj.first.value }} L
    

    Is not working. It returns the "NaN L".
    L is for unit of my datapoint.

    Other part of script is working. Last and first values are showing corecctly.


  • Hey @C00L3R the reason its not working is because the two values you are subtracting are strings. These are the rendered point values. If you want to do subtraction, add rendered="false" to <ma-point-statistics>.

    You may also want to add first-last="true" to make it faster if you are only interested in the difference between the first and last point values. In this case use {{ statsObj[1].value - statsObj[0].value }} to find the difference.


  • Hey, thanks for your respond,

    But unfortunately its still not working. The same problem. I tried adding rendered="false" to <ma-point-statistics> but it didnt help.

    Below is full code of my script:

    <p>Alternatively use the date and time pickers individually</p>
    <div layout="row">
        <md-input-container flex="">
        <label>From date</label>
        <ma-date-picker ng-model="from"></ma-date-picker>
      </md-input-container>
    </div>
    <div layout="row">
         <md-input-container flex="">
        <label>To date</label>
        <ma-date-picker ng-model="to"></ma-date-picker>
      </md-input-container>
    </div>
    
    <p>
        You have chosen a date range of {{ from | moment:'format':'ll LTS' }} to {{ to | moment:'format':'ll LTS' }}.
    </p>
    
    
    <div layout="row">
        <md-input-container flex="">
            <label>Choose a point</label>
            <ma-point-list limit="700" ng-model="myPoint"></ma-point-list>
        </md-input-container>
    </div>
    
    <ma-point-statistics point="myPoint" from="from" to="to" statistics="statsObj" rendered="false"></ma-point-statistics>
    
    
    
    <div>The average for the period is {{ statsObj.average.value }} at {{ statsObj.average.timestamp | moment:'format':'lll' }}
    <br>
         The max value for the period is {{ statsObj.maximum.value }}
         <br>
         {{ statsObj.last.value - statsObj.first.value }} L
         <br>
         {{ statsObj.last.value }}
         <br>
         {{ statsObj.first.value }}
    </div>
    

  • Hi C00L3R,

    I just attempted to use your code and I observed Jared's suggestion to make the difference between NaN and a value. Is it possible you need to clear your browser's cache? It's a good idea to keep your developer tools open during development, and to check the "Disable cache (while DevTools is open)" in the developer tools' settings.


  • Eh, it didn't help. I disabled cache and even tried on different browser with that Custom Page and there's still the same error.
    Simple viewing values is working but subtraction not.


  • What's interesting:
    I installed Mango 3.0 beta version. And I noticed on example page "Energy Dashboard" that Maximum Demand (kW) and Total Energy (kWh) gauges aren't working corecctly - they have same problem that I have - showing "NaN" value.

    But in this case adding rendered="false" to <ma-point-statistics> solved the problem.

    Why isn't it helping to me? :)


  • I think you're right, it's a bug that's been fixed but not released. I was testing with the latest commit in the 2.8.x branch, not the latest release version. My bad!


  • So maybe I should wait for the next 2.8.X update?


  • @C00L3R I've looked into it and the reason its not working is simply because its a feature that we have added to the upcoming dashboards release for Mango 3.0 and is not in the 2.8.X dashboards release (Dashboards 3.3.1).

    So yeah it's not a bug, its new functionality we have added which isn't available yet. Sorry to lead you on a wild goose chase.

    I do have a work around for you, but you will need to know what suffix is being used in the text renderer. You can use Javascripts String's slice() method to remove the suffix then do the arithmetic on the strings (which are automatically interpreted as a Number when they don't have the suffix).

    So for a point with a 2 character suffix like ' L' you can remove it like so:
    {{statsObj.last.value.slice(0,-2) - statsObj.first.value.slice(0,-2)}}

    edit:
    Thought of a better, more general purpose workaround which will work if you have a space between the number and unit (which you seem to)
    {{statsObj.last.value.split(' ')[0] - statsObj.first.value.split(' ')[0]}}


  • Thanks ! This way works fine.