Javascript TypeError:ChartList.plugins.legend不是函数

Javascript TypeError:ChartList.plugins.legend不是函数,javascript,meteor,meteor-blaze,chartist.js,Javascript,Meteor,Meteor Blaze,Chartist.js,我很高兴最近开始使用Meteor构建工具和charlist来表示我的数据 我有图例模板的java脚本(来源于互联网) Template.js HTML 我使用了类似的导入语句,它们的工作方式与预期相同 import {ctThreshold} from 'chartist-plugin-threshold'; import {ctBarLabels} from 'chartist-plugin-barlabels'; import {ctPointLabels} from 'chartist-p

我很高兴最近开始使用
Meteor
构建工具和
charlist
来表示我的数据

我有图例模板的java脚本(来源于互联网)

Template.js HTML 我使用了类似的导入语句,它们的工作方式与预期相同

import {ctThreshold} from 'chartist-plugin-threshold';
import {ctBarLabels} from 'chartist-plugin-barlabels';
import {ctPointLabels} from 'chartist-plugin-pointlabels'; 
工具提示插件导入也有类似的错误,如
“TypeError:ChartList.plugins.tooltips不是函数”

我使用的相应NPM语句

meteor npm install --save chartist
meteor npm install --save chartist-plugin-barlabels
meteor npm install --save chartist-plugin-threshold
meteor npm install --save chartist-plugin-pointlabels
meteor npm install --save chartist-plugin-tooltips

有人能帮我解决这个问题吗?

重复我的文章

我没有使用meteor,所以您的里程数可能会有所不同,但我使用的是Angular2,并且出现了类似的错误。对我来说,答案是先使用legend插件将其初始化,然后像您所做的那样在ChartList插件定义中使用它。这感觉很粗糙,但它的工作

import * as Chartist from 'chartist';
import * as MyLegend from 'chartist-plugin-legend';

constructor(){
  var tester = new MyLegend(); //without this line, you get 'Chartist.plugins undefined'
}

.... in another method like ngOnInit or something...
new Chartist.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']
    }) ]

});

我的复信来自

我没有使用meteor,所以您的里程数可能会有所不同,但我使用的是Angular2,并且出现了类似的错误。对我来说,答案是先使用legend插件将其初始化,然后像您所做的那样在ChartList插件定义中使用它。这感觉很粗糙,但它的工作

import * as Chartist from 'chartist';
import * as MyLegend from 'chartist-plugin-legend';

constructor(){
  var tester = new MyLegend(); //without this line, you get 'Chartist.plugins undefined'
}

.... in another method like ngOnInit or something...
new Chartist.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']
    }) ]

});
meteor npm install --save chartist
meteor npm install --save chartist-plugin-barlabels
meteor npm install --save chartist-plugin-threshold
meteor npm install --save chartist-plugin-pointlabels
meteor npm install --save chartist-plugin-tooltips
import * as Chartist from 'chartist';
import * as MyLegend from 'chartist-plugin-legend';

constructor(){
  var tester = new MyLegend(); //without this line, you get 'Chartist.plugins undefined'
}

.... in another method like ngOnInit or something...
new Chartist.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']
    }) ]

});