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 不是函数


- 如何显示带有换行符的文本标签? 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01