0

我刚刚发现了 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>
4

1 回答 1

0
    var data = {

...

       var myChart = new xChart('bar',datai,'#myChart');

您上面的变量名是“data”而不是“datai”,如下所示

于 2015-03-05T09:21:45.857 回答