Fixed and auto scale axis
A step line on an auto scale x axis and a fixed y axis with hand-picked ticks.
src/main.ts
import 'chartist/styles.css';
import {
lineChart,
autoScaleAxis,
fixedScaleAxis,
Interpolation
} 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
},
axisY: {
type: fixedScaleAxis(),
ticks: [0, 50, 75, 87.5, 100],
low: 0
},
lineSmooth: Interpolation.step(),
showPoint: false
}
);import 'chartist/styles.css';
import {
LineChart,
AutoScaleAxis,
FixedScaleAxis,
Interpolation
} 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
},
axisY: {
type: FixedScaleAxis,
ticks: [0, 50, 75, 87.5, 100],
low: 0
},
lineSmooth: Interpolation.step(),
showPoint: false
}
); 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.