javascript 无法在 Chart.js 中绘制方法,找不到 v2
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32468818/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Unable to draw method in Chart.js, v2 can't be found
提问by Beto
I had previously installed my chart.js current version with bower. For different reasons I have to use chart.js: https://github.com/nnnick/Chart.js/releases/tag/2.0.0-alpha3
我以前用 bower 安装了我的 chart.js 当前版本。由于不同的原因,我必须使用chart.js:https: //github.com/nnnick/Chart.js/releases/tag/2.0.0-alpha3
I changed the name on my bower file to the current version and bower installed. But I keep getting this error.
我将 bower 文件上的名称更改为当前版本并安装了 bower。但我不断收到此错误。
TypeError: (intermediate value).Line is not a function
TypeError: (intermediate value).Line 不是函数
Here is my code:
这是我的代码:
var myNewChart = new Chart(ctx).Line(dat);
回答by Spencer Wieczorek
In Chart.js 2.0.0 Alpha 3 you will need to create your chart like so:
在 Chart.js 2.0.0 Alpha 3 中,您需要像这样创建图表:
var myNewChart = new Chart(ctx , {
type: "line",
data: dat,
});
At least right now it doesn't have new Chart().Line()
like the older version.
至少现在它new Chart().Line()
不像旧版本那样。
What your error basically means is that it was expecting a semi-colon after Chart(ctx)
.
您的错误基本上意味着它在Chart(ctx)
.