Skip to content

Instantly share code, notes, and snippets.

@roseg43
Created September 17, 2019 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roseg43/7d86693022436a226d9094e23c8a38fa to your computer and use it in GitHub Desktop.
Save roseg43/7d86693022436a226d9094e23c8a38fa to your computer and use it in GitHub Desktop.
Allows for custom HTML labels in a ChartistJS chart.
// HTML Label plugin
Chartist.plugins = Chartist.plugins || {};
Chartist.plugins.ctHtmlLabels = function(options) {
return function(chart) {
chart.on('draw', function(context) {
if (context.type === 'label') {
// Best to combine with something like sanitize-html
context.element.empty()._node.innerHTML = context.text;
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment