Highcharts工具提示格式化器返回函数抛出未捕获的TypeError: j.i call不是函数

Highcharts tooltips formatter return function throwing Uncaught TypeError: j.call is not a function

本文关键字:函数 TypeError call 格式化 工具提示 返回 Highcharts      更新时间:2023-09-26

我们在其中一个模块中使用了Highcharts,我们希望在指针移动到饼图切片上时显示工具提示。

$(function () {
$('#container').highcharts({
    chart: {
        renderTo: 'container',
        type: 'pie'
    },
    colors: [
        '#ff6600',
        '#333300',
        '#660000'],
    credits: {
        enabled: false
    },
    title: {
        text: ''
    },
    yAxis: {
        title: {
            text: 'Total percent market share'
        }
    },
    plotOptions: {
        series: {
            states: {
                hover: {
                    enabled: false
                }
            }
        }
    },
    tooltip: {
        formatter:function () {return '<b>' + this.point.name + '<'/b>';},
shared:true,
headerFormat:"<span style='"padding:0'">{point.key}: <b{point.percentage:.1f}%<'/b><'/span><br>",
valueDecimals:2,
useHTML:true,
pointFormat:"<span style='"padding:0'">Count : <b>{point.y:.0f}<'/b>",
enabled:true,
footerFormat:"<'/span>"
        },
        series: [{
            name: 'Time',
            data: [
                ["sleep", 10],
                ["work", 30],
                ["play", 10]
            ],
            dataLabels: {
                enabled: false
            }
        }]
    });
});

但是控制台抛出Uncaught TypeError: j.call is not a function错误。如果我们在http://jsfiddle.net/中运行相同的代码,那么它会像预期的那样工作。

尝试使用

var chart = new Highcharts.Chart({
不是

$('#container').highcharts({

示例:http://jsfiddle.net/gh/get/jquery/1.7.2/hililide-software/highcharts.com/tree/master/samples/highcharts/chart/renderto-object/