Axis title
API v0.xGlobal: reads the global Chartist, for backwards compatibilityNo SSRchartist-plugin-axistitle@0.0.7Adds a title to the X and Y axes, with an offset and text anchor of your choice.
- Author
- Alex Stanbury
- License
- MIT
- Downloads
- 45,483 a month (October 14, 2026)
- Last release
- 2019
- Charts
- Line, Bar
See it run
src/main.ts
import 'chartist/styles.css';
import './style.css';
import { lineChart } from 'chartist';
import { fromLegacyPlugin } from 'chartist/compat';
// Plugin scripts register on the global `Chartist`.
const { plugins } = Chartist;
lineChart(
'#chart',
{
labels: [0, 15, 30, 45, 60, 75, 90],
series: [[0, 1, 1, 2, 2, 3, 4]]
},
{
// Room for the titles.
chartPadding: { top: 20, right: 10, bottom: 30, left: 20 },
axisY: { onlyInteger: true },
plugins: [
fromLegacyPlugin(
plugins.ctAxisTitle({
axisX: {
axisTitle: 'Time (mins)',
axisClass: 'ct-axis-title',
offset: { x: 0, y: 50 },
textAnchor: 'middle'
},
axisY: {
axisTitle: 'Goals',
axisClass: 'ct-axis-title',
offset: { x: 0, y: -1 },
flipTitle: false
}
})
)
]
}
); Live
Use it on your site
Runs on v2 with chartist/compat. A script: load it after importing chartist/compat, which sets up the global it reads. With the UMD build or a bundler
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/chartist@2.0.0-rc.2/dist/index.min.css">
<script type="module">
import 'https://cdn.jsdelivr.net/npm/chartist@2.0.0-rc.2/dist/compat.min.js';
</script>
<script defer src="https://cdn.jsdelivr.net/npm/chartist-plugin-axistitle@0.0.7/dist/chartist-plugin-axistitle.js"></script>
<script type="module">
import { lineChart } from 'https://cdn.jsdelivr.net/npm/chartist@2.0.0-rc.2/dist/index.min.js';
import { fromLegacyPlugin } from 'https://cdn.jsdelivr.net/npm/chartist@2.0.0-rc.2/dist/compat.min.js';
lineChart('#chart', data, {
plugins: [fromLegacyPlugin(Chartist.plugins.ctAxisTitle())]
});
</script>