我已经设法完成了基本的 xChart 工作。虽然,它返回一些黑屏而不是我想要的图形。我已经包含了所有要求,例如 d3.js 和所有 xCharts 的 JS。我的代码和输出如下:
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<figure style="width: 400px; 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"></script>
<script type="text/javascript">
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', data, '#myChart');
</script>
<?php
// put your code here
?>
</body>
</html>
有人对此有任何想法以及如何解决吗?