Evaluating Time Series with tsEval
Evaluating time series is very useful when debugging. To evaluate time series data with an expression, use a method called TSEvalSpec#tsEval.
The TSEvalSpec#tsEval method is defined on the C3 AI Persistable Type, so any Persistable Type has access to the method through Type inheritance.
Syntax and Definition
The TSEvalSpec#tsEval accepts a set of parameters that are collectively called a spec. You can specify the parameters as follows:
- A
projection. - The actual expression being computed.
- A list of IDs that must be evaluated on.
- The time range.
- The interval (granularity of the computation).
// Enclose the below in c3Grid() or c3Viz() while in static console
TypeToEvaluate.tsEval({
projection: "Projection String",
ids: ['<list of ID values>'], // comma separated list of IDs
start: "2020-06-01",
end: "2020-06-05",
interval: "HOUR" // run c3ShowType(Interval) in static console for all the options
});Projection string
Projections define the actual expression being computed. The following sample expression shows a join specification for how to traverse the Type system to get to where the data are actually stored.
- The keyword
normalized.datadenotes that normalized data will be used. - The keyword
fieldindicates the value to analyze.
All this is wrapped into two aggregation functions: aggregation over time, and across multiple series (aggregation over space).

These projections can get quite complicated. In general, after tuning and verification, the projection saves as a Metric and can be called up by name.
Example
See the following detailed example showing how individual values are aggregated:
First, six 10-minute intervals are rolled up to 2 ½ hour values using the average function.
Next, these values from multiple time series are summed to produce the final time series output (since the outermost aggregation function was specified as sum).
