我刚刚发现了xCharts,并试图从官方网页的文档中自己学习。我已经为基本节目应用了以下代码,因此我可以稍后使用此图表,但图表根本没有显示在图中。有任何想法吗?感谢。
我的代码:
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<figure style="width: 300px; height: 300px" id="myChart"></figure>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="js/d3.js"></script>
<script src="js/xcharts.css"></script>
<script src="js/xcharts.js">
var data = {
"xScale": "ordinal",
"yScale": "linear",
"type": "bar",
"main": [
{
"className": ".pizza",
"data": [
{
"x": "Pepperoni",
"y": 12
},
{
"x": "Cheese",
"y": 8
}
]
}
],
"comp": [
{
"className": ".pizza",
"type": "line-dotted",
"data": [
{
"x": "Pepperoni",
"y": 10
},
{
"x": "Cheese",
"y": 4
}
]
}
]
};
var myChart = new xChart('bar',datai,'#myChart');
</script>
<?php
// put your code here
?>
</body> </html>
答案 0 :(得分:0)
var data = {
...
var myChart = new xChart('bar',datai,'#myChart');
上面的变量名是&#34;数据&#34;不是&#34; datai&#34;如下所示