最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - HighCharts - JQuery - Simple example not working - Stack Overflow

programmeradmin1浏览0评论

This simple example from the highcharts website is not working for me (.7.2/highslide-software/highcharts/tree/master/samples/highcharts/demo/pie-basic/).

Here is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ".dtd">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script type="text/javascript" src=".3.2/jquery.min.js"></script>
<script type="text/javascript" src=".js"></script>

<script type="text/javascript">

    $(function () {
        $('#container').highcharts({
            chart: {
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false
            },
            title: {
                text: 'Browser market shares at a specific website, 2010'
            },
            tooltip: {
                pointFormat: '{series.name}: <b>{point.percentage}%</b>',
                percentageDecimals: 1
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                        color: '#000000',
                        connectorColor: '#000000',
                        formatter: function() {
                            return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
                        }
                    }
                }
            },
            series: [{
                type: 'pie',
                name: 'Browser share',
                data: [
                    ['Firefox',   45.0],
                    ['IE',       26.8],
                    {
                        name: 'Chrome',
                        y: 12.8,
                        sliced: true,
                        selected: true
                    },
                    ['Safari',    8.5],
                    ['Opera',     6.2],
                    ['Others',   0.7]
                ]
            }]
        });
    });
</script>
</head>

<body>
    <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</body>
</html>

I have just copied it over from the jsfiddle so have no idea why it isn't working!

Thanks

This simple example from the highcharts website is not working for me (http://jsfiddle/gh/get/jquery/1.7.2/highslide-software/highcharts./tree/master/samples/highcharts/demo/pie-basic/).

Here is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<script type="text/javascript" src="http://ajax.googleapis./ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://www.highcharts./js/highcharts.js"></script>

<script type="text/javascript">

    $(function () {
        $('#container').highcharts({
            chart: {
                plotBackgroundColor: null,
                plotBorderWidth: null,
                plotShadow: false
            },
            title: {
                text: 'Browser market shares at a specific website, 2010'
            },
            tooltip: {
                pointFormat: '{series.name}: <b>{point.percentage}%</b>',
                percentageDecimals: 1
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: true,
                        color: '#000000',
                        connectorColor: '#000000',
                        formatter: function() {
                            return '<b>'+ this.point.name +'</b>: '+ this.percentage +' %';
                        }
                    }
                }
            },
            series: [{
                type: 'pie',
                name: 'Browser share',
                data: [
                    ['Firefox',   45.0],
                    ['IE',       26.8],
                    {
                        name: 'Chrome',
                        y: 12.8,
                        sliced: true,
                        selected: true
                    },
                    ['Safari',    8.5],
                    ['Opera',     6.2],
                    ['Others',   0.7]
                ]
            }]
        });
    });
</script>
</head>

<body>
    <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</body>
</html>

I have just copied it over from the jsfiddle so have no idea why it isn't working!

Thanks

Share Improve this question asked Apr 8, 2013 at 21:12 New_programmerNew_programmer 2853 gold badges7 silver badges16 bronze badges 11
  • Seems to be working fine. What specifically isn't working for you. – Ben Felda Commented Apr 8, 2013 at 21:14
  • Sorry - to clarify the JSFiddle is taken from the highcharts website, and I'm trying to copy that to get it working on my server but am just getting a blank page. – New_programmer Commented Apr 8, 2013 at 21:15
  • 1 Your fiddle is referencing a newer version of JQuery. – Ben Felda Commented Apr 8, 2013 at 21:18
  • @New_programmer And of course, as the JSFiddle, you added jQuery before highchart.js ? – Shikiryu Commented Apr 8, 2013 at 21:18
  • Have changed to newer version of JQuery (as below) and still no luck, and yes Shikiryu I have – New_programmer Commented Apr 8, 2013 at 21:22
 |  Show 6 more ments

2 Answers 2

Reset to default 2

I couldn't get the HighCharts demos to work locally, but found this answer to another question...

problem is .highchart. Use

var chart = new Highcharts.Chart({
chart: {
    //alignTicks: false,
    type: 'line',
    renderTo: 'container'
},
...

}

See this page: JSFiddle API examples are broken

The fiddle is actually using the highcharts code from http://code.highcharts./highcharts.js.. I tested this link in your code and it seems to be working. I was getting a console error that highcharts method is undefined... with the link you show.

发布评论

评论列表(0)

  1. 暂无评论