c3Viz() for RollupMetrics


#1

I want to visualize a rollup metric in console.
The following RollupMetric returns a Map. If I replace the function with .evalMetrics and remove the rollupFunc , the command works as expected.
Is there a way to graph this using c3Viz()?

c3Viz( Warehouse.rollupMetrics({ids: ["wh1", "wh0"], expressions: ["FailureCost"], start: "2018-01-01T00:00:00Z", end: "2018-10-01T01:00:00Z", interval: "MONTH", rollupFunc: "SUM"}));

C3.typesys.Map {FailureCost: C3.t…s.Obj, _type: {…}}
FailureCost: C3.typesys.Obj
m_data: Array(10)
0: 28
1: 370
2: 216
3: 57
4: 386
5: 318
6: 98
7: 681
8: 0
9: 0
length: 10
_type: {_kind: "arry", _init: {…}, _keyType: {…}, _elementType: {…}}
__proto__: Array
m_end: DateTime {_ms: 1541030400000, _offsetMinutes: undefined, _setMonth: undefined, _pad: undefined, _formatOffset: undefined, …}
m_estimates: [_empty: true, _type: {…}]
m_interval: "MONTH"
m_missing: (10) [0, 0, 0, 0, 0, 0, 0, 32, 100, 100, _type: {…}]
m_sourceInfo: C3.typesys.Obj {source: {…}, expr: "FailureCost"}

cc @TimSchultz


#2

Result of a rollUpMetrics is a Timeseries object:

rollupMetric(spec): Timeseries

while c3Viz() received as input a EvalMetricsResult object:

evalMetrics(spec): EvalMetricsResult

In order to visualize result of a rollUpMetrics, you should first convert it to an EvalMetricResult object. Looking at documentation on EvalMetricsResult, it has a result field, and the result field is a map, where key is the id of the source object & value is a map where key is the name of the metric & value is a Timeseries

result: map<string, map<string, Timeseries>>

You can use a snippet like below to do so:

        ids: ['CD602FY160', 'CD602FY159', 'CD602FY158'],
        start: "2018-12-10T00:00:00",
        end: "2019-01-01T00:10:00",
        expressions: ["HotTagMeasurements"],
        interval: "HOUR",
        rollupFunc: "AVG", 
      });
c3Viz(rollUpMetricsResult)

new_result = EvalMetricsResult.make({
      result: {"id1":rollUpMetricsResult}
    });
c3Viz(new_result)