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.
// 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 */
};
// Minimal chart
{
id: "population",
series: [
{
id: "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 }
]
}
]
}
// Full chart example
{
id: "energy-mix",
type: "area",
title: "Electricity generation",
lane: "metrics",
visibility: (chart) => chart.owner.getZoom() >= 30 ? "visible" : "hidden",
scale: {
source: "data",
includeZero: true,
padding: 0.08,
tickMode: "round",
tickTarget: 6
},
typeOptions: {
area: {
stacking: { active: true, interpolation: "linear" }
}
},
series: [
{
id: "renewables",
title: "Renewables",
points: [
{ date: { year: 1990 }, value: 19 },
{ date: { year: 2000 }, value: 20 },
{ date: { year: 2010 }, value: 21 },
{ date: { year: 2020 }, value: 29 }
],
style: { color: "#16a34a", area: { opacity: 0.28 } }
},
{
id: "gas",
title: "Gas",
points: [
{ date: { year: 1990 }, value: 15 },
{ date: { year: 2000 }, value: 18 },
{ date: { year: 2010 }, value: null },
{ date: { year: 2020 }, value: 23 }
],
style: { color: "#ea580c", lineDash: [6, 4], area: { opacity: 0.2 } }
}
],
style: {
legend: { visible: true },
series: { point: { visible: true, radius: 3 } }
}
}
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.
// 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.
// 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)
DataAdd one or more new charts and redraw the timeline.
Parameters
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)
DataStamp 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)
DataAdd 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)
DataRemove one series by id, re-resolve the chart, and redraw when found.
Parameters
id string | number
Series id to remove.
Returns
boolean – true when a series was removed; otherwise false.
chart.removeSeriesById('projection');
chart.getSeriesById(id)
LookupReturn the normalized runtime series with the matching id.
Returns
ChartSeries | undefined.
const series = chart.getSeriesById('projection');
console.log(series?.points.length);
timeline.removeChart(id)
DataRemove one loaded chart by id.
Parameters
id string | number
Chart id to remove.
Returns
boolean – true when a chart was removed; otherwise false.
const removed = timeline.removeChart('population');
timeline.clearCharts()
DataRemove all loaded charts and redraw the timeline.
Returns
void.
timeline.clearCharts();
timeline.getChartById(id)
LookupReturn 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?)
ConfigurationUpdate 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?)
StylingOverride 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?)
InspectionResolve 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.