Charts Documentation

Charts display timeline-aligned numerical data. Use them to configure line and area charts, define chart data and styles, and manage charts at runtime.

Chart Schema new

A chart object renders one timeline-aligned line or area chart with one y-scale and one or more series. Chart points use the same date input shape as articles and time bands.

At a glance: Required fields — id. Each visible line or area needs at least one series with finite point values.

Schema
// Chart Schema (clickable)
{
  id: /* required: number|string */,
  type: /* optional: 'line' | 'area'; default: 'line' */,
  title: /* optional: string */,
  lane: /* optional: number|string */,
  visibility: /* optional: 'visible' (default) | 'hidden' | function(Chart): 'visible' | 'hidden' */,

  series: [
    {
      id: /* optional: number|string */,
      title: /* optional: string */,
      points: [
        {
          date: /* required: DateInput */,
          value: /* required: number|null */
        }
      ],
      style: /* optional: ChartSeriesStyle */
    }
  ],

  scale: {
    source: /* optional: 'data' | 'viewport'; default: 'data' */,
    includeZero: /* optional: boolean; default: false */,
    padding: /* optional: number; default: 0.05 */,
    min: /* optional: number */,
    max: /* optional: number */,
    tickMode: /* optional: 'round' | 'exact'; default: 'round' */,
    tickTarget: /* optional: number; default: 5 */
  },

  typeOptions: {
    area: {
      stacking: {
        active: /* optional: boolean; default: true */,
        interpolation: /* optional: 'linear' | 'step' | 'none'; default: 'linear' */
      }
    }
  },

  area: /* optional: { up?: AreaValue, down?: AreaValue } */,
  style: /* optional: ChartStyle */
};

Chart data is visual-only: it does not participate in article stacking, article selection, article drag handling, or getStatusForSave().

Chart Options new

Control visibility, geometry, grid-line defaults, default data, default styling, and initial data for timeline-aligned line and area charts.

These options live under options.chart.*. The values shown below are the defaults.

JavaScript
// Chart options (defaults)
{
  visible: true,
  area: { up: 'edge', down: 0 },
  gridLine: { /* global grid-line defaults */ },
  defaultData: {},
  defaultStyle: { /* see Chart Style */ },
  data: [ /* see Chart Schema */ ]
};

Chart Style new

Customize chart padding, x/y grid lines, axes, legends, default line styling, area fills, and point markers. Per-chart and per-series overrides merge deeply with this default object.

chart.defaultStyle in the Chart Options object.

JavaScript
// Chart defaultStyle
{
  padding: {
    top: 8,
    right: 12,
    bottom: 8,
    left: 48
  },
  backgroundColor: 'rgba(255, 255, 255, 0)',
  gridLine: {
    x: {
      major: { visible: true, color: 'rgba(0, 0, 0, 0.08)', thickness: 1 },
      minor: { visible: true, color: 'rgba(0, 0, 0, 0.035)', thickness: 2, minimumSpacing: 20 }
    },
    y: {
      major: { visible: true, color: 'rgba(120, 120, 120, 0.24)', thickness: 1 }
    }
  },
  axis: {
    visible: true,
    color: 'rgba(80, 80, 80, 0.45)',
    lineWidth: 1
  },
  yAxis: {
    visible: true,
    font: 'normal 11px Calibri',
    color: '#555',
    margin: 6,
    thousandsSeparator: ',',
    formatter: null
  },
  legend: {
    visible: 'auto',
    position: 'top-left',
    font: 'normal 12px Calibri',
    color: '#333',
    markerSize: 10,
    markerGap: 4,
    itemGap: 12,
    inset: { x: 8, y: 8 }
  },
  series: {
    color: '#2563eb',
    lineWidth: 2,
    lineDash: [],
    area: {
      fillColor: null,
      opacity: 0.2
    },
    point: {
      visible: false,
      radius: 2.5,
      fillColor: null,
      strokeColor: null,
      lineWidth: 1
    }
  }
};

Per-chart and per-series overrides: call chart.setStyle, set ChartData.style, or set ChartSeriesData.style with a sparse object. Fields you omit fall back to the defaults above.

Chart Methods new

Load, remove, inspect, and update charts after your timeline is initialized.

Tip: Loaded charts are stored as Chart instances in timeline.charts. Retrieve one with timeline.getChartById(id) before calling the instance methods below.

timeline.loadCharts(charts)

Data

Add one or more new charts and redraw the timeline.

Parameters

charts ChartData[]

Array of Chart objects. Each entry follows the Chart Schema.

Returns

void – Adds new charts and redraws.

Charts without ids, charts whose ids are already loaded, and repeated ids in the same batch are skipped with a warning. Charts omitted from later calls remain loaded until removed or cleared.

timeline.loadCharts([
  {
    id: 'population',
    scale: { includeZero: true },
    series: [
      {
        id: 'world',
        title: 'World',
        points: [
          { date: { year: 1990 }, value: 5.3 },
          { date: { year: 2000 }, value: 6.1 },
          { date: { year: 2010 }, value: 6.9 },
          { date: { year: 2020 }, value: 7.8 }
        ]
      }
    ]
  }
]);

timeline.loadLaneCharts(laneId, charts)

Data

Stamp a lane id onto a batch of charts and load them onto the timeline.

Parameters

laneId string | number

Lane identifier to assign to every chart in the batch.

charts ChartData[]

Chart objects. Existing conflicting lane values are overwritten by laneId.

Returns

void – Adds new lane-scoped charts and redraws.

timeline.loadLaneCharts('metrics', [
  {
    id: 'temperature',
    series: [
      {
        id: 'average',
        points: [
          { date: { year: 1900 }, value: 13.7 },
          { date: { year: 1950 }, value: 13.9 },
          { date: { year: 2000 }, value: 14.4 }
        ]
      }
    ]
  }
]);

chart.addSeries(series)

Data

Add one series to a loaded chart, re-resolve chart data, and redraw.

Parameters

series ChartSeriesData

Series object with optional id, title, points, and style.

Returns

void.

const chart = timeline.getChartById('population');

chart?.addSeries({
  id: 'projection',
  title: 'Projection',
  points: [
    { date: { year: 2030 }, value: 8.5 },
    { date: { year: 2040 }, value: 9.1 }
  ]
});

chart.removeSeriesById(id)

Data

Remove one series by id, re-resolve the chart, and redraw when found.

Parameters

id string | number

Series id to remove.

Returns

booleantrue when a series was removed; otherwise false.

chart.removeSeriesById('projection');

chart.getSeriesById(id)

Lookup

Return the normalized runtime series with the matching id.

Returns

ChartSeries | undefined.

const series = chart.getSeriesById('projection');
console.log(series?.points.length);

timeline.removeChart(id)

Data

Remove one loaded chart by id.

Parameters

id string | number

Chart id to remove.

Returns

booleantrue when a chart was removed; otherwise false.

const removed = timeline.removeChart('population');

timeline.clearCharts()

Data

Remove all loaded charts and redraw the timeline.

Returns

void.

timeline.clearCharts();

timeline.getChartById(id)

Lookup

Return a loaded Chart instance by id.

Parameters

id string | number

Chart id to retrieve.

Returns

Chart | undefined.

const chart = timeline.getChartById('population');
chart?.setStyle('series.lineWidth', 3);

chart.setOption(option, value?)

Configuration

Update chart data fields using objects or dot-notation paths.

Parameters

option string | object

Partial chart object for batch updates, or a dot-notation path such as 'scale.includeZero'.

value any

New value when using a string path. Omit this argument to read the current value.

Returns

any when called as a getter; otherwise void.

const chart = timeline.getChartById('population');

chart.setOption('visibility', 'hidden');
chart.setOption({
  scale: { source: 'viewport', padding: 0.1 }
});

chart.setStyle(option, value?)

Styling

Override chart styles or query an override value.

Parameters

option string | object

Partial style object or dot-notation path such as 'gridLine.y.major.visible'.

value any

New value when using a string path. Omit to read the current override.

Returns

any when reading; otherwise void.

const chart = timeline.getChartById('population');

chart.setStyle('gridLine.y.major.visible', false);
chart.setStyle({
  gridLine: {
    x: {
      minor: { visible: true, minimumSpacing: 48 }
    }
  },
  series: {
    lineWidth: 3,
    point: { visible: true }
  }
});

chart.getScaleDomain(drawCycleContext?)

Inspection

Resolve the active y-domain for a chart.

Parameters

drawCycleContext RedrawCycleContext

Optional render context. Only needed for scale.source: 'viewport'.

Returns

{ min: number, max: number }.

timeline.on('timeline-render-end', ({ drawCycleContext }) => {
  const chart = timeline.getChartById('population');
  console.log(chart?.getScaleDomain(drawCycleContext));
});

Need More Help?

If you can't find what you're looking for, browse the examples or contact us.