Auto scale axis
A halving series on an auto scale x axis that only uses whole numbers.
src/main.ts
import 'chartist/styles.css';
import { lineChart, autoScaleAxis } from 'chartist';
lineChart(
'#chart',
{
series: [
[
{ x: 1, y: 100 },
{ x: 2, y: 50 },
{ x: 3, y: 25 },
{ x: 5, y: 12.5 },
{ x: 8, y: 6.25 }
]
]
},
{
axisX: {
type: autoScaleAxis(),
onlyInteger: true
}
}
);import 'chartist/styles.css';
import { LineChart, AutoScaleAxis } from 'chartist';
new LineChart(
'#chart',
{
series: [
[
{ x: 1, y: 100 },
{ x: 2, y: 50 },
{ x: 3, y: 25 },
{ x: 5, y: 12.5 },
{ x: 8, y: 6.25 }
]
]
},
{
axisX: {
type: AutoScaleAxis,
onlyInteger: true
}
}
); 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.