-
-
Save anianweber/0b3241b41866434ecb7755fa85f43fb2 to your computer and use it in GitHub Desktop.
Chart.js: Pre-parse time values into moment objects
This file contains hidden or 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
| var preparsePlugin = Chart.PluginBase.extend({ | |
| beforeInit: function(chartCtrlr) { | |
| var chart = chartCtrlr.chart; | |
| var labels = chartCtrlr.data.labels; | |
| var momentLabels = []; | |
| labels.forEach(function(v) { | |
| momentLabels.push(moment(v, moment.ISO_8601)); | |
| }); | |
| chartCtrlr.data.labels = momentLabels; | |
| }, | |
| }); | |
| Chart.pluginService.register(new preparsePlugin()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment