gpt4 book ai didi

javascript - Highmaps 出现 'Uncaught TypeError: undefined is not a function ' 并且未加载?

转载 作者:行者123 更新时间:2023-12-03 11:34:49 25 4
gpt4 key购买 nike

我正在尝试将 Highmaps 与 Highchart 一起使用。Highcharts 工作完美,但 Highmaps 不适用于 Highmaps。

Highmaps 未加载 highchart 图形。控制台上出现“未捕获的类型错误:未定义不是函数”错误。我假设它的 javascript 冲突错误。但是我该如何解决此问题?

代码:

<script src="http://code.highcharts.com/maps/highmaps.js"></script>
<script src="http://code.highcharts.com/maps/modules/data.js"></script>
<script src="http://code.highcharts.com/mapdata/custom/world.js"></script>


<div id="container" style="height: 500px; min-width: 310px; max-width: 800px; margin: 0 auto"></div>
<script>
$(function () {

$.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=world-population.json&callback=?', function (data) {

var mapData = Highcharts.geojson(Highcharts.maps['custom/world']);

// Correct UK to GB in data
$.each(data, function () {
if (this.code === 'UK') {
this.code = 'GB';
}
});

$('#container').highcharts('Map', {
chart : {
borderWidth : 1
},

title: {
text: 'World population 2010 by country'
},

subtitle : {
text : 'Demo of Highcharts map with bubbles'
},

legend: {
enabled: false
},

mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},

series : [{
name: 'Countries',
mapData: mapData,
color: '#E0E0E0',
enableMouseTracking: false
}, {
type: 'mapbubble',
mapData: mapData,
name: 'Population 2010',
joinBy: ['iso-a2', 'code'],
data: data,
minSize: 4,
maxSize: '12%',
tooltip: {
pointFormat: '{point.code}: {point.z} thousands'
}
}]
});

});
});
</script>

感谢您的帮助。

最佳答案

您需要在其他highmaps插件之前添加jquery.min.js

$(function () {

$.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=world-population.json&callback=?', function (data) {

var mapData = Highcharts.geojson(Highcharts.maps['custom/world']);

// Correct UK to GB in data
$.each(data, function () {
if (this.code === 'UK') {
this.code = 'GB';
}
});

$('#container').highcharts('Map', {
chart : {
borderWidth : 1
},

title: {
text: 'World population 2010 by country'
},

subtitle : {
text : 'Demo of Highcharts map with bubbles'
},

legend: {
enabled: false
},

mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},

series : [{
name: 'Countries',
mapData: mapData,
color: '#E0E0E0',
enableMouseTracking: false
}, {
type: 'mapbubble',
mapData: mapData,
name: 'Population 2010',
joinBy: ['iso-a2', 'code'],
data: data,
minSize: 4,
maxSize: '12%',
tooltip: {
pointFormat: '{point.code}: {point.z} thousands'
}
}]
});

});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="http://code.highcharts.com/maps/highmaps.js"></script>
<script src="http://code.highcharts.com/maps/modules/data.js"></script>
<script src="http://code.highcharts.com/mapdata/custom/world.js"></script>
<div id="container" style="height: 500px; min-width: 310px; max-width: 800px; margin: 0 auto"></div>

关于javascript - Highmaps 出现 'Uncaught TypeError: undefined is not a function ' 并且未加载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26563552/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com