I return about the new metric evaluate interval week.

I can add in Facility.c3typ a func:

*…*

*evaluateWeek: function(*

_ aggregator: string enum(‘SUM’,‘AVG’,‘MIN’,‘MAX’)_

_ metric: MetricId,_

_ …_

_ ): string js server_

*and in Facility.js:*

*function evaluateWeek(aggregator,metric, …) {*

*…*

*var expression = “DayOfWeek==1 ? window(aggregator,metric,1,7): (DayOfWeek==2 ? window(aggregator,metric,0,1) +window(aggregator,metric,1,6) : (DayOfWeek==3 ? window(aggregator,metric,-1,2)+window(aggregator,metric,1,5):(DayOfWeek==4 ? window(aggregator,metric,-2,3)+window(aggregator,metric,1,4) :(DayOfWeek==5 ? window(aggregator,metric,-3,4) +window(aggregator,metric,1,3):(DayOfWeek==6 ? window(aggregator,metric,-4,5) +window(aggregator,metric,1,2):(DayOfWeek==7 ? window(aggregator,metric,-5,6) +window(aggregator,metric,1,1) :0.0))))))”*

*…*

*}*

etc etc

Here an example exp:

*c3Viz(Facility.evalMetrics({start:‘2015-11-16T00:00:00.000Z’,end:‘2016-11-13T21:59:59.999Z’,ids:[‘15’], expressions:[“DayOfWeek==1 ? window(‘SUM’,energySpend,1,7): (DayOfWeek==2 ? window(‘SUM’,energySpend,0,1) +window(‘SUM’,energySpend,1,6) : (DayOfWeek==3 ? window(‘SUM’,energySpend,-1,2)+window(‘SUM’,energySpend,1,5):(DayOfWeek==4 ? window(‘SUM’,energySpend,-2,3)+window(‘SUM’,energySpend,1,4) :(DayOfWeek==5 ? window(‘SUM’,energySpend,-3,4) +window(‘SUM’,energySpend,1,3):(DayOfWeek==6 ? window(‘SUM’,energySpend,-4,5) +window(‘SUM’,energySpend,1,2):(DayOfWeek==7 ? window(‘SUM’,energySpend,-5,6) +window(‘SUM’,energySpend,1,1) :0.0))))))”], interval:‘DAY’}))*

The question is:

I don’t have the var called aggregator because when i pass Comp Metric to my evalMetrics it depends by the simple associated. **Is there a “sure”, scientific mode to extract automatically the time operator from metric?**

For example for my EnergySpend is right to aggregate the days by SUM but if i have, for example, a metric based on Temperature i must to aggregate for AVG not for SUM. I talk about time aggregator.

Another solution can be to build a new table with a mapping between name metric and a string as aggreator.

New c3typ

string: metricname

string: enum(‘SUM’,‘AVG’,‘MIN’,‘MAX’)

Thanks a lot