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

javascript - HighCharts TypeError: ha is not a function - Stack Overflow

programmeradmin1浏览0评论

I'm having trouble using the HighChart into my php codes.

Originally I created a graph.php and manage to get it up and running on its own.

However when I integrated it into another php (adminlist.php), the graph fails to appear and upon debugging, the error shows "TypeError: ha is not a function" and TypeError: $(...).highcharts is not a function (sorry new here unable to attach pictures)

My code in adminlist.php is as follows :

<ul class="nav nav-pills nav-stacked">
<li <?php if($_GET['function'] == 'graph'){echo 'class="active"';}?>><a href="adminlist.php?function=graph">Analyzer</a></li>
</ul>
                        if ($_GET['function'] == 'graph'){
                    include('graph.php');

                    }

My code in graph.php (it works if i call graph.php directly but not when i include it in adminlist.php). Source code is as follows :

<div id="mostpopular" style="height: 400px"></div>
<script src="bootstrap-3.2.0-dist/js/jquery.min.js"></script>
<script src="bootstrap-3.2.0-dist/js/bootstrap.min.js"></script>
<script src="bootstrap-3.2.0-dist/js/bootstrap-markdown.js"></script>
<script src="bootstrap-3.2.0-dist/js/jquery.hotkeys.js"></script>
<script src="Highcharts-4.0.4/js/highcharts.js"></script>
<script src="Highcharts-4.0.4/js/highcharts-3d.js"></script>
<script src="Highcharts-4.0.4/js/modules/exporting.js"></script>

<script type="text/javascript">

$(function () {
    $('#mostpopular').highcharts({
        chart: {
            type: 'column',
            margin: 75,
            options3d: {

                alpha: 10,
                beta: 25,
                depth: 70
            }
        },
        title: {
            text: 'Sale transaction volume'
        },
        subtitle: {
            text: 'List of total sales by food category'
        },
        plotOptions: {
            column: {
                depth: 25
            }
        },
        xAxis: {
            categories: ['<?php echo $foodnamearr[0]; ?>', '<?php echo $foodnamearr[1]; ?>','<?php echo $foodnamearr[2]; ?>','<?php echo $foodnamearr[3]; ?>','<?php echo $foodnamearr[4]; ?>','<?php echo $foodnamearr[5]; ?>','<?php echo $foodnamearr[6]; ?>','<?php echo $foodnamearr[7]; ?>']
        },
        yAxis: {
            opposite: true
        },
        series: [{
            name: 'Sales',
            data: [<?php echo $qty[0]; ?>,<?php echo $qty[1]; ?>, <?php echo $qty[2]; ?>, <?php echo $qty[3]; ?>, <?php echo $qty[4]; ?>, <?php echo $qty[5]; ?>, <?php echo $qty[6]; ?>, <?php echo $qty[7]; ?>]
        }]
    });
});
        </script>

I'm having trouble using the HighChart into my php codes.

Originally I created a graph.php and manage to get it up and running on its own.

However when I integrated it into another php (adminlist.php), the graph fails to appear and upon debugging, the error shows "TypeError: ha is not a function" and TypeError: $(...).highcharts is not a function (sorry new here unable to attach pictures)

My code in adminlist.php is as follows :

<ul class="nav nav-pills nav-stacked">
<li <?php if($_GET['function'] == 'graph'){echo 'class="active"';}?>><a href="adminlist.php?function=graph">Analyzer</a></li>
</ul>
                        if ($_GET['function'] == 'graph'){
                    include('graph.php');

                    }

My code in graph.php (it works if i call graph.php directly but not when i include it in adminlist.php). Source code is as follows :

<div id="mostpopular" style="height: 400px"></div>
<script src="bootstrap-3.2.0-dist/js/jquery.min.js"></script>
<script src="bootstrap-3.2.0-dist/js/bootstrap.min.js"></script>
<script src="bootstrap-3.2.0-dist/js/bootstrap-markdown.js"></script>
<script src="bootstrap-3.2.0-dist/js/jquery.hotkeys.js"></script>
<script src="Highcharts-4.0.4/js/highcharts.js"></script>
<script src="Highcharts-4.0.4/js/highcharts-3d.js"></script>
<script src="Highcharts-4.0.4/js/modules/exporting.js"></script>

<script type="text/javascript">

$(function () {
    $('#mostpopular').highcharts({
        chart: {
            type: 'column',
            margin: 75,
            options3d: {

                alpha: 10,
                beta: 25,
                depth: 70
            }
        },
        title: {
            text: 'Sale transaction volume'
        },
        subtitle: {
            text: 'List of total sales by food category'
        },
        plotOptions: {
            column: {
                depth: 25
            }
        },
        xAxis: {
            categories: ['<?php echo $foodnamearr[0]; ?>', '<?php echo $foodnamearr[1]; ?>','<?php echo $foodnamearr[2]; ?>','<?php echo $foodnamearr[3]; ?>','<?php echo $foodnamearr[4]; ?>','<?php echo $foodnamearr[5]; ?>','<?php echo $foodnamearr[6]; ?>','<?php echo $foodnamearr[7]; ?>']
        },
        yAxis: {
            opposite: true
        },
        series: [{
            name: 'Sales',
            data: [<?php echo $qty[0]; ?>,<?php echo $qty[1]; ?>, <?php echo $qty[2]; ?>, <?php echo $qty[3]; ?>, <?php echo $qty[4]; ?>, <?php echo $qty[5]; ?>, <?php echo $qty[6]; ?>, <?php echo $qty[7]; ?>]
        }]
    });
});
        </script>
Share Improve this question asked Nov 22, 2014 at 14:42 Nicholas LimNicholas Lim 1373 silver badges15 bronze badges 1
  • Ensure that your value $qty[0]; is float not string. – Sebastian Bochan Commented Nov 24, 2014 at 10:51
Add a ment  | 

2 Answers 2

Reset to default 7

Old question, but if anybody finds themselves searching:

As of 4.0.4, ha is the minified version of the error method. The one time in the script where error is called before it is defined is at line 106 where it's checking for a dirty Highcharts namespace:

if (win.Highcharts) {
  error(16, true);
} else {
  Highcharts = win.Highcharts = {};
}

You don't get the actual error because of the bug. Intended output is:

uncaught exception: Highcharts error #16: www.highcharts./errors/16

Note: Of course, depending on your version of Highcharts, the code could have changed.

Check you are not importing the same highcharts javascript files in the template you are working in, and the template you are including.

In my case it solved the problem.

发布评论

评论列表(0)

  1. 暂无评论