本文介绍了C3JS - 无法读取未定义的属性'category10'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从jsfiddle()试过了这个c3.js代码,但它没有似乎在我的本地主机。
我使用uniserver作为我的服务器。我复制粘贴所有内容,但不起作用。
< html>
< head>
<! - CSS - >
< link href =css / c3.css =stylesheettype =text / css/>
< script src =js / d3.min.jstype =text / javascript>< / script>
< script src =js / c3.jstype =text / javascript>< / script>
< script type =text / javascript>
window.onload = function(){
var chart = c3.generate({
data:{
columns:[
['data1',300,350
['data2',130,100,140,200,150,50]
],
类型:{
data1:300,0,0,0] 'area',
data2:'area-spline'
}
},
axis:{
y:{
padding:{bottom:0} ,
分钟:0
},
x:{
padding:{left:0},
分钟:0,
显示:false
}
}
});
}
< / script>
< / head>
< body>
< div id =chart>< / div>
< / body>
< / html>
当我检查Developer Tools的控制台时,得到的是:
c3.js:5783 Uncaught TypeError:无法读取未定义的属性'category10'
我尝试了c3.js的不同版本,但没有任何结果。这很奇怪,因为它在jsfiddle中工作,而不是在我的本地工作。解决方案
我通过降级解决了另一个项目上完全相同的JavaScript错误从D3.js v4(4.1.1)到v3(3.5.17)。
事实证明,C3.js,截至2016年7月,:
I tried this c3.js code from jsfiddle (https://jsfiddle.net/varunoberoi/mcd6ucge) but it doesn't seem to work in my localhost.
I'm using uniserver as my server. I copy-paste everything but it's not working.
<html>
<head>
<!-- CSS -->
<link href="css/c3.css" rel="stylesheet" type="text/css" />
<!-- JAVASCRIPT -->
<script src="js/d3.min.js" type="text/javascript"></script>
<script src="js/c3.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload=function(){
var chart = c3.generate({
data: {
columns: [
['data1', 300, 350, 300, 0, 0, 0],
['data2', 130, 100, 140, 200, 150, 50]
],
types: {
data1: 'area',
data2: 'area-spline'
}
},
axis: {
y: {
padding: {bottom: 0},
min: 0
},
x: {
padding: {left: 0},
min: 0,
show: false
}
}
});
}
</script>
</head>
<body>
<div id="chart"></div>
</body>
</html>
What I got when I check the Developer Tools' console is this:
c3.js:5783 Uncaught TypeError: Cannot read property 'category10' of undefined
I tried different versions of c3.js but nothing. It's weird because it's working in jsfiddle and not in my local.
解决方案
I solved the exact same JavaScript error on another project by downgrading from D3.js v4 (4.1.1) to v3 (3.5.17).
It turns out that C3.js, as of July 2016, does not support D3.js v4:
这篇关于C3JS - 无法读取未定义的属性'category10'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!