Created
May 13, 2016 16:14
-
-
Save AllenJB/d0febe4912c3d8e84d9962cbf67a8ead to your computer and use it in GitHub Desktop.
Chart.js: Pre-parse time values into moment objects
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
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