demo D279
A trend line and a forecast
Draw a least-squares trend straight through the points and carry it on as a dashed forecast, with a vertical event marker flagging the day a change went live
trend: { method: 'linear', forecast: 8 }
Loading a live grid…
The configuration
'chart-trend-forecast': () => ({
rows: [], config: {},
foot: [
'the top chart fits a least-squares trend straight through the points and carries it on past the last day as a dashed forecast',
'the bottom chart takes the same series and marks the day a change went live with a vertical event flag, above a mean line read from the data',
'the data is one clean, sorted point per day, which is what a fit needs to draw a line and project it',
'both read the grid’s filtered rows, so narrowing the grid refits the trend and moves the mean',
],
mount: mountGridCharts({
rows: trendRows(), columns: trendCols, columnsPer: 1, chartHeight: 280, height: 760,
charts: [
{
type: 'line', x: 'day', y: 'active', full: true, paneHeight: 280,
trend: { method: 'linear', forecast: 8 },
title: 'The trend, projected ahead',
},
{
type: 'line', x: 'day', y: 'active', full: true, paneHeight: 280,
annotations: [
{ kind: 'event', value: 22, label: 'Feature launch' },
{ kind: 'line', compute: 'mean', label: 'Average', axis: 'left' },
],
title: 'The same series, with the launch marked',
},
],
}),
}),