Created
September 17, 2019 16:08
-
-
Save roseg43/7d86693022436a226d9094e23c8a38fa to your computer and use it in GitHub Desktop.
Allows for custom HTML labels in a ChartistJS chart.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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