Typeerror: Chartist.plugins.legend Is Not A Function
I'm have recently started use Meteor build tool with Chartist to represent my data. I have java script for legend template (source from internet) Template.js function drawBarChart
Solution 1:
duplicate post of mine from stackoverflow issue 40834462
I am not using meteor so your mileage may vary but I am using Angular2 and was getting similar errors. The answer for me was to use the legend plugin to get it initialized first and then use it in the Chartist plugin definition like you have done. This feels hacky but its working...
import * asChartistfrom'chartist';
import * asMyLegendfrom'chartist-plugin-legend';
constructor(){
var tester = newMyLegend(); //without this line, you get 'Chartist.plugins undefined'
}
.... in another method like ngOnInit or something...
newChartist.Bar('.ct-chart', {
labels: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
series: [
[1,2,3,4],
[1,2,3,4],
[1,2,3,4]
]
}, {
plugins: [ Chartist.plugins.legend({
legendNames: ['Blue pill', 'Red pill', 'Purple pill']
}) ]
});
Post a Comment for "Typeerror: Chartist.plugins.legend Is Not A Function"