Вопрос

I currently tried to just implement the example from highcharts just to get a feel for it and play around, but it doesn't seem to be working. I tried loading their standalone framework, different versions of jQuery, but the chart will not render. Here is my code:

<!DOCTYPE html>
<html>
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script src="http://code.highcharts.com/highcharts.js"></script>
    </head>
<body>
<script type="text/javascript">
var chart = new Highcharts.Chart({
chart: {
    //alignTicks: false,
    type: 'line',
    renderTo: 'container'
},
        $(function () { 
    $('#container').highcharts({
        chart: {
            type: 'bar'
        },
        title: {
            text: 'Fruit Consumption'
        },
        xAxis: {
            categories: ['Apples', 'Bananas', 'Oranges']
        },
        yAxis: {
            title: {
                text: 'Fruit eaten'
            }
        },
        series: [{
            name: 'Jane',
            data: [1, 0, 4]
        }, {
            name: 'John',
            data: [5, 7, 3]
        }]
    });
});
    </script>
<div id="container" style="width:100%; height:400px;"></div>
</body>
</html>

Thanks in advance.

Это было полезно?

Решение

http://jsfiddle.net/rjreddy78/hgCPa/

<!DOCTYPE html>
<html>
<head>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script src="http://code.highcharts.com/highcharts.js"></script>
    </head>
<body>
<script type="text/javascript">
        $(function () { 
    $('#container').highcharts({
        chart: {
            type: 'bar'
        },
        title: {
            text: 'Fruit Consumption'
        },
        xAxis: {
            categories: ['Apples', 'Bananas', 'Oranges']
        },
        yAxis: {
            title: {
                text: 'Fruit eaten'
            }
        },
        series: [{
            name: 'Jane',
            data: [1, 0, 4]
        }, {
            name: 'John',
            data: [5, 7, 3]
        }]
    });
});
    </script>
<div id="container" style="width:100%; height:400px;"></div>
</body>
</html>

Другие советы

You need to add

 $(function () { 
   //chart code
 });

or

$(document).ready(function(){
  //chart code
});
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top