0

I've managed to get a basic xChart work. Although, It returns some black screen instead of the graph I want. I've included all requirements such as d3.js and all xCharts's JS. My code and ouput below :

<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>

enter image description here

Anybody has any ideas about this and how to fix it?

1 Answers1

-2

I think you have simply forgotten to reference the CSS library. Something like:

<link href="xcharts.css" rel="stylesheet">

pointing to where you have stashed the file might do the trick.

Vojtěch Dohnal
  • 7,867
  • 3
  • 43
  • 105