我最近开始使用Meteor
构建工具Chartist
来表示我的数据。
我有图例模板的java脚本(来自互联网)
模板.js
function drawBarChart() {
new Chartist.Bar('.legendChart1', {
labels: ['First quarter of the year', 'Second quarter of the year', 'Third quarter of the year', 'Fourth quarter of the year'],
series: [
{ "name": "Money A", "data": [60000, 40000, 80000, 70000] },
{ "name": "Money B", "data": [40000, 30000, 70000, 65000] }
]
}, {
plugins: [
Chartist.plugins.legend()
]
});
};
Template.legendTemplate.rendered = function(){
drawBarChart();
}
HTML
<template name="legendTemplate">
<div class="legendChart1">
</div>
</template>
以及相应的导入语句为
import {legend} from 'chartist-plugin-legend';
我使用了类似的导入语句,它们按预期工作。
import {ctThreshold} from 'chartist-plugin-threshold';
import {ctBarLabels} from 'chartist-plugin-barlabels';
import {ctPointLabels} from 'chartist-plugin-pointlabels';
工具提示插件导入也有类似的错误"TypeError: Chartist.plugins.tooltips is not a function"
。
我使用过的相应 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
谁能帮我解决这个问题?