mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-07 20:59:08 +02:00
51 lines
1.0 KiB
Markdown
51 lines
1.0 KiB
Markdown
|
# Stepped Line Charts
|
||
|
|
||
|
```js chart-editor
|
||
|
// <block:setup:1>
|
||
|
const data = {
|
||
|
labels: ['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 5', 'Day 6'],
|
||
|
datasets: [
|
||
|
{
|
||
|
label: 'Dataset',
|
||
|
data: Utils.numbers({count: 6, min: -100, max: 100}),
|
||
|
borderColor: Utils.CHART_COLORS.red,
|
||
|
fill: false,
|
||
|
|
||
|
// Change the stepped mode to explore different stepped chart options
|
||
|
// false: no stepping
|
||
|
// true: stepped before interpolation
|
||
|
// 'before': step before interpolation
|
||
|
// 'after': step after interpolation
|
||
|
// 'middle': step middle interpolation
|
||
|
stepped: true,
|
||
|
}
|
||
|
]
|
||
|
};
|
||
|
// </block:setup>
|
||
|
|
||
|
// <block:config:0>
|
||
|
const config = {
|
||
|
type: 'line',
|
||
|
data: data,
|
||
|
options: {
|
||
|
responsive: true,
|
||
|
interaction: {
|
||
|
intersect: false,
|
||
|
axis: 'x'
|
||
|
},
|
||
|
plugins: {
|
||
|
title: {
|
||
|
display: true,
|
||
|
text: (ctx) => 'Step ' + ctx.chart.data.datasets[0].stepped + ' Interpolation',
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
// </block:config>
|
||
|
|
||
|
module.exports = {
|
||
|
actions: [],
|
||
|
config: config,
|
||
|
};
|
||
|
```
|