C3 AI Documentation Home

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.

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).
JavaScript
// 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.data denotes that normalized data will be used.
  • The keyword field indicates the value to analyze.

All this is wrapped into two aggregation functions: aggregation over time, and across multiple series (aggregation over space).

Aggregation

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).

Aggregation projection

Was this page helpful?