Only whole numbers
Four series between -3 and 3 on a y axis that only labels whole numbers.
src/main.ts
import 'chartist/styles.css';
import { lineChart } from 'chartist';
lineChart(
'#chart',
{
labels: [1, 2, 3, 4, 5, 6, 7, 8],
series: [
[1, 2, 3, 1, -2, 0, 1, 0],
[-2, -1, -2, -1, -3, -1, -2, -1],
[0, 0, 0, 1, 2, 3, 2, 1],
[3, 2, 1, 0.5, 1, 0, -1, -3]
]
},
{
high: 3,
low: -3,
fullWidth: true,
// As this is axis specific we need to tell Chartist to use whole numbers only on the concerned axis
axisY: {
onlyInteger: true,
offset: 20
}
}
);import 'chartist/styles.css';
import { LineChart } from 'chartist';
new LineChart(
'#chart',
{
labels: [1, 2, 3, 4, 5, 6, 7, 8],
series: [
[1, 2, 3, 1, -2, 0, 1, 0],
[-2, -1, -2, -1, -3, -1, -2, -1],
[0, 0, 0, 1, 2, 3, 2, 1],
[3, 2, 1, 0.5, 1, 0, -1, -3]
]
},
{
high: 3,
low: -3,
fullWidth: true,
// As this is axis specific we need to tell Chartist to use whole numbers only on the concerned axis
axisY: {
onlyInteger: true,
offset: 20
}
}
); Live
Open in the playgroundView as MarkdownSwitch to 1.x above the code to see the same chart written with the Chartist 1.x classes.