gpt4 book ai didi

javascript - 代码仅适用于 jsfiddle

转载 作者:太空宇宙 更新时间:2023-11-03 17:38:05 25 4
gpt4 key购买 nike

我的一些代码有问题。它只在 jsfiddle 中运行,我不知道为什么它不能在 codepen 或文件中运行。

为什么这段代码只能在 jsfiddle 中运行?我在 codepen 和文件中尝试过,但它没有显示任何内容 http://jsfiddle.net/auagufL8/

<script src="http://code.highcharts.com/maps/highmaps.js"></script>
<script src="http://code.highcharts.com/maps/modules/exporting.js"></script>
<script src="http://code.highcharts.com/mapdata/countries/nl/nl-all.js"> </script>

<div id="container"></div>


$(function () {

// Prepare demo data
var data = [
{
"hc-key": "nl-fr",
"value": 0
},
{
"hc-key": "nl-gr",
"value": 1
},
{
"hc-key": "nl-fl",
"value": 2
},
{
"hc-key": "nl-ze",
"value": 3
},
{
"hc-key": "nl-nh",
"value": 4
},
{
"hc-key": "nl-zh",
"value": 5
},
{
"hc-key": "nl-dr",
"value": 6
},
{
"hc-key": "nl-ge",
"value": 7
},
{
"hc-key": "nl-li",
"value": 8
},
{
"hc-key": "nl-ov",
"value": 9
},
{
"hc-key": "nl-nb",
"value": 10
},
{
"hc-key": "nl-ut",
"value": 11
}
];

// Initiate the chart
$('#container').highcharts('Map', {

title : {
text : 'Highmaps basic demo'
},

subtitle : {
text : 'Source map: <a href="http://code.highcharts.com/mapdata/countries/nl/nl-all.js">The Netherlands</a>'
},

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

colorAxis: {
min: 0
},

series : [{
data : data,
mapData: Highcharts.maps['countries/nl/nl-all'],
joinBy: 'hc-key',
name: 'Random data',
states: {
hover: {
color: '#BADA55'
}
},
dataLabels: {
enabled: true,
format: '{point.name}'
}
}]
});
});


#container {
height: 500px;
min-width: 310px;
max-width: 800px;
margin: 0 auto;
}
.loading {
margin-top: 10em;
text-align: center;
color: gray;
}

最佳答案

哦!

此代码无处不在。
要让它在 Codepen 中运行,您需要通过 inside JS panel 的小齿轮添加所有 JS 资源,并检查 Latest version of jQuery被选中。 <script>标签在 HTML 面板中被忽略。

$(function () {

// Prepare demo data
var data = [
{"hc-key": "nl-fr","value": 0},
{"hc-key": "nl-gr","value": 1},
{"hc-key": "nl-fl","value": 2},
{"hc-key": "nl-ze","value": 3},
{"hc-key": "nl-nh","value": 4},
{"hc-key": "nl-zh","value": 5},
{"hc-key": "nl-dr","value": 6},
{"hc-key": "nl-ge","value": 7},
{"hc-key": "nl-li","value": 8},
{"hc-key": "nl-ov","value": 9},
{"hc-key": "nl-nb","value": 10},
{"hc-key": "nl-ut","value": 11}
];

// Initiate the chart
$('#container').highcharts('Map', {
title : {
text : 'Highmaps basic demo'
},
subtitle : {
text : 'Source map: <a href="http://code.highcharts.com/mapdata/countries/nl/nl-all.js">The Netherlands</a>'
},
mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},
colorAxis: {
min: 0
},
series : [{
data : data,
mapData: Highcharts.maps['countries/nl/nl-all'],
joinBy: 'hc-key',
name: 'Random data',
states: {
hover: {
color: '#BADA55'
}
},
dataLabels: {
enabled: true,
format: '{point.name}'
}
}]
});
});
#container {
height: 500px;
min-width: 310px;
max-width: 800px;
margin: 0 auto;
}
.loading {
margin-top: 10em;
text-align: center;
color: gray;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://code.highcharts.com/maps/highmaps.js"></script>
<script src="http://code.highcharts.com/maps/modules/exporting.js"></script>
<script src="http://code.highcharts.com/mapdata/countries/nl/nl-all.js"></script>

<div id="container"></div>

关于javascript - 代码仅适用于 jsfiddle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29534030/

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