Chart of sum data points
-
hi !
I have 10 data points and i need to make a chart showing only one line with the sum of these 10 data points
In the following code i get the 10 different lines but cannot combine them into 1 with the sum of them
I get though the live value of the sum {{points | maSum:'value'}} but cant figure out how to pass this sum value into the chart
By using the stack-type ="regular" though i see the sum of all these 10 lines (and its the same as my {{points | maSum:'value'}} output but i need only one line (without stack-type) so i can see in my chart the total sum in watts of all the 10 datapoints in one line, during the hours of the day where the sun is up and the solar panels are working.Also im wondering if there is a way on hover each line to get not only the value but also the name of the data point (for another chart that i have those 10 disctinct lines) so i can remove the legend and just discover the data point name by hovering the mouse over each individual line
And according to this topic https://forum.infiniteautomation.com/topic/2680/adding-guides-to-charts/5t i would like to know if instead of showing the guide of average if i can have a guide on the chart of the max value during the day or the timeframe set. And that this guide would be dynamically moving if there is a new higher value
Thank you very much
<b>Power Out : {{points | maSum:'value'}} Watts</b> <div layout="row" layout-fill flex> <ma-now update-interval="10 minutes" output="to"></ma-now> <ma-calc input="to | maMoment:'set':{'hour': 5, 'minute': 0}" output="from"></ma-calc> <ma-calc input="to | maMoment:'set':{'hour': 21, 'minute': 0}" output="to"></ma-calc> <ma-point-query query="{name:'Power out'}" limit="10" points="points"></ma-point-query> <ma-get-point-value points="points"></ma-get-point-value> <ma-point-values points="points" values="combined" from="from" to="to" rollup="{{dateBar.rollupType}}" rollup-interval="{{dateBar.rollupIntervals}} {{dateBar.rollupIntervalPeriod}}"> </ma-point-values> <ma-serial-chart style="height: 600px; width: 100%" values="combined" points="points" legend="true" stack-type ="regular" series-X-type="line"> </ma-serial-chart> </div>
-
Hi alexzer,
This is definitely the right time to use a meta point to calculate that sum, then to include the meta point in the chart. You may consider something like a meta point on cron pattern
0 0/5 * * * ?
doing this....var averageSum = 0; for( var point in CONTEXT_POINTS ) { if( point === "my" ) continue; //skip the meta point itself, which is also in context averageSum += this[point].past(MINUTE, 5).average; } return averageSum;
to get compute the sum of the averages of the previous five minutes over the points added to te meta point's context.
Also im wondering if there is a way on hover each line to get not only the value but also the name of the data point (for another chart that i have those 10 disctinct lines) so i can remove the legend and just discover the data point name by hovering the mouse over each individual line
If you explicitly tie in the values with
series-N-values=
like we were in the other thread, you could explicitly set theseries-N-balloon-text=
but unfortunately there is not currently something like a function to supply to compute the balloon text, so it isn't possible if the chart is driven through a "points" array. You would have to modify the directive to get that functionality. Fox modified the gauge chart in this thread, for instance: https://forum.infiniteautomation.com/topic/3467/gauges-function-amcharts -
Hi Philp, thanks for the example. Where would the cron pattern go?
-
As the update event of the meta data point.