Chart.js t.ticks.map is not a function(Chart.js t.ticks.map 不是函数)
问题描述
结果和标签都来自服务器,但它们看起来没问题.当我运行此代码时,我没有得到任何图形.我正在使用 CDN 中的 chart.js.
Both results and labels come from the server but they seem alright. When I run this code I don't get any graphics. I'm using the chart.js from the CDN.
澄清一下,结果和数据都来自代码.它们没有像示例中那样进行硬编码.
Clarification, both results and data come from the code. They are not hardcoded as they look in the example.
我得到的错误说:
t.ticks.map 不是函数
t.ticks.map is not a function
无法获取未定义或空引用的属性跳过"
Unable to get property 'skip' of undefined or null reference
代码:
<canvas id="myChart" width="400" height="400"></canvas>
var ctx = document.getElementById("myChart").getContext("2d");
var result = [0, 0, 0];
var lbls = ['A', 'B', 'C'];
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: lbls.split(','),
datasets: [{
label: '# of Votes',
data: result
}]
}
});
也欢迎任何关于其他图表实用程序的建议.
Any suggestion about another chart utility is welcome too.
推荐答案
标签需要一个数组变量,但是 var lbls = $('#lbls').html()
返回一个字符串,所以用 ',' 分开就可以了
The labels requires a array variable but the var lbls = $('#lbls').html()
returns a string so splitting it with ',' will do the job
var myChart = new Chart(ctx, {
type: 'line',
data: {
labels: lbls.split(','),
datasets: [{
label: '# of Votes',
data: [20, 10]
}]
}
});
这篇关于Chart.js t.ticks.map 不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Chart.js t.ticks.map 不是函数


基础教程推荐
- fetch 是否支持原生多文件上传? 2022-01-01
- npm start 错误与 create-react-app 2022-01-01
- Fabric JS绘制具有活动形状的多边形 2022-01-01
- 在 contenteditable 中精确拖放 2022-01-01
- 检查 HTML5 拖放文件类型 2022-01-01
- Bootstrap 模态出现在背景下 2022-01-01
- 即使用户允许,Gmail 也会隐藏外部电子邮件图片 2022-01-01
- 如何添加到目前为止的天数? 2022-01-01
- Bokeh Div文本对齐 2022-01-01
- 原生拖动事件后如何获取 mouseup 事件? 2022-01-01