Time Series Charts

Overview

Time series charts are used to visualize continuous time series data over a recorded period.

You can add one or more time series charts to the timeline. Time series charts share the timeline's scale, aligning the data points with the events displayed in the timeline. This lets you identify interesting points or patterns in the data and investigate the particular events that may be related to them.

This example uses a sample of the Gridwatch dataset, which tracks the sources of energy production in the UK.

To add time series charts to your timeline, pass them in the timeSeriesCharts data object:

To add time series charts to your timeline, pass them in the timeSeriesCharts prop:

const data = {
  events : {},
  entities: {},
  timeSeriesCharts: {
    nuclear: {
      color: "#f48c06",
      data: [
        // ... //
      ]
    },
    gas: {
      color: "#b8d0eb",
      data: [
        // ... //
      ]
    },
    wind: {
      color: "#c77dff",
      data: [
        // ... //
      ]
    },
    hydro: {
      color: "#00b4d8",
      data: [
        // ... //
      ]
    },
    solar: {
      color: "#ffcc00",
      data: [
        // ... //
      ]
    },
  }},
<Timeline
events={events}
entities={entities}
timeSeriesCharts={
  nuclear: {
    color: "#f48c06",
    data: [
      // ... //
    ]
  },
  gas: {
    color: "#b8d0eb",
    data: [
      // ... //
    ]
  },
  wind: {
    color: "#c77dff",
    data: [...
    ]
  },
  hydro: {
    color: "#00b4d8",
    data: [
      // ... //
    ]
  },
  solar: {
    color: "#ffcc00",
    data: [
      // ... //
    ]
  },
}
/>;

Set the size and position of the timeline in the timeSeriesCharts options:

timeline.options({
  timeSeriesCharts: {
    sizePercent: 100,
    position: 'bottom',
  },
});
options={{
  timeSeriesCharts: {
    sizePercent: 100,
    position: 'bottom'
  },
}}

Note that if scale wrapping is applied or the scale mode is set to 'nonlinear', time series charts will be hidden.

Styling

Time series charts can be styled and customized using the properties in the TimeSeriesChart Object.

Tsc Styling Example

Log in to view live examples
const timeSeriesCharts = {
  'Default Chart Style': {
    data: [
      // ... //
    ],
  },
  'Custom Chart Style': {
    data: [
      // ... //
    ],
    color: '#c9477b',
    labelColor: '#ffd88f',
    fillAreaAlpha: 0.5,
    lineStyle: 'dashed',
  },
},

Take a look at how the styles can be applied in the Time Series Charts story.

Stacks

If you have more than one time series dataset, the charts can be added to a time series chart stack. This allows you to compare two related time series datasets or save space on the timeline. In this example, the energy types are grouped into 'Renewable' and 'Non-Renewable'.

To stack your time series charts add the timeSeriesChartStack object to your timeline data. Include the chartIds you want to see in each stack.

const data = {
  events: {},
  entities: {},
  timeSeriesChartStacks: {
    Renewable: {
      chartIds: [
        "wind",
        "hydro",
        "solar"
      ]
    },
    Non-Renewable: {
      chartIds: [
        "nuclear",
        "gas"
      ]
    }
  },
  timeSeriesCharts: {
    nuclear: {
      color: "#f48c06",
      data: [
        // ... //
      ]
    },
    gas: {
      color: "#b8d0eb",
      data: [
        // ... //
      ]
    },
    wind: {
      color: "#c77dff",
      data: [
        // ... //
      ]
    },
    hydro: {
      color: "#00b4d8",
      data: [
        // ... //
      ]
    },
    solar: {
      color: "#ffcc00",
      data: [
        // ... //
      ]
    },
  },
}
<Timeline
events={events}
entities={entities}
timeSeriesChartStacks={
  Renewable: {
      chartIds: [
        "wind",
        "hydro",
        "solar"
      ]
    },
    Non-Renewable: {
      chartIds: [
        "nuclear",
        "gas"
      ]
    }
}
timeSeriesCharts={
  nuclear: {
    color: "#f48c06",
    data: [
      // ... //
    ]
  },
  gas: {
    color: "#b8d0eb",
    data: [
      // ... //
    ]
  },
  wind: {
    color: "#c77dff",
    data: [
      // ... //
    ]
  },
  hydro: {
    color: "#00b4d8",
    data: [
      // ... //
    ]
  },
  solar: {
    color: "#ffcc00",
    data: [
      // ... //
    ]
  },
},
}
/>;

When charts are stacked only the label of the stack is shown. The labels for the individual charts are not shown.

Data Points

The properties of time series chart data points are available via the subItem object. When the targetType is 'timeSeriesChart', the subItem object will be returned with the values for that data point.

timeline.on('click', (pointerEvent) => {
  if (pointerEvent.targetType === 'timeSeriesChart') {
    const {index, subId, time, value, x, y} = pointerEvent.subItem;
    alert([
      `Data point at x = ${x}, y = ${y}`,
      `   Time: ${time}`,
      `   Index: ${index}`,
      `   subID: ${subId}`,
      `   Value: ${value}`,
    ].join('\n'));
  }
});
const handleClick = (pointerEvent) => {
  if (pointerEvent.targetType === 'timeSeriesChart') {
    const {index, subId, time, value, x, y} = pointerEvent.subItem;
    alert([
      `Data point at x = ${x}, y = ${y}`,
      `   Time: ${time}`,
      `   Index: ${index}`,
      `   subID: ${subId}`,
      `   Value: ${value}`,
    ].join('\n'));
  }
}
<Timeline
entities={entities}
events={events}
onTimelineClick={handleClick}
/>

The subId will return a string in the form chartId-index.

Data points don't have a width or height, so these parameters will return undefined.

See the Time Series Chart Tooltips story for an example.

Terms of use

These terms do not alter or supersede any existing agreements between you (or your employer) and us.

By accessing or using any Content you agree to be bound by these Terms of Use. Please review these terms carefully before using the website.

The contents of this website, including but not limited to any text, code samples, API references, schemas, interactive tools, and other materials (collectively, the 'Content'), are made available for informational and internal evaluation purposes only. All intellectual property rights in the Content are reserved. No licence is granted to use the Content for any commercial purpose, or to copy, distribute, modify, reverse-engineer, or incorporate any part of the Content into any product or service, without our prior written consent.

This Content is provided “as is” and “as available,” without any representations, warranties, or guarantees of any kind, whether express or implied, including but not limited to implied warranties of merchantability, fitness for a particular purpose, non-infringement, or accuracy. To the fullest extent permitted by applicable law, we expressly exclude and disclaim all implied warranties, conditions, and other terms that might otherwise be implied.

We disclaim all liability for any loss or damage, whether direct, indirect, incidental, consequential, or otherwise, arising from any reliance placed on the Content or from your use of it, to the fullest extent permitted by applicable law. By continuing to access or use the Content, you acknowledge and agree to these terms.