gpt4 book ai didi

javascript - 在包含大量 HighCharts 的页面上,一个特定的图表未显示。

转载 作者:行者123 更新时间:2023-11-28 07:09:39 24 4
gpt4 key购买 nike

我对编码非常陌生,但最近一直在努力学习如何使用 HighCharts。我设置了一个 Wordpress 页面,显示 5 或 6 个不同的 HighChart。他们都工作得很好!

除了一个。这个特殊的图表只是在它应该出现的地方留下了一个很大的空白。它可以在 JSFiddle 中工作(因为它应该工作,因为我只是使用 HighChart 的样板代码)。

请参见此处:http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/bar-negative-stack/

当我在图表应该在的 WordPress 页面上运行浏览器错误控制台时,它显示:

TypeError: $(...).highcharts is not a function

并专门指向代码中的这一行:

$('#container6').highcharts({

这是图表的完整实际代码:

<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/highcharts-more.js"></script>
<script src="http://code.highcharts.com/modules/solid-gauge.js"></script>
</head>

<script>
$(function () {
// Age categories
var categories = ['0-4', '5-9', '10-14', '15-19',
'20-24', '25-29', '30-34', '35-39', '40-44',
'45-49', '50-54', '55-59', '60-64', '65-69',
'70-74', '75-79', '80-84', '85-89', '90-94',
'95-99', '100 + '];
$(document).ready(function () {
$('#container6').highcharts({
chart: {
type: 'bar'
},
title: {
text: 'Population pyramid for Germany, 2015'
},
subtitle: {
text: 'Source: <a href="http://populationpyramid.net/germany/2015/">Population Pyramids of the World from 1950 to 2100</a>'
},
xAxis: [{
categories: categories,
reversed: false,
labels: {
step: 1
}
}, { // mirror axis on right side
opposite: true,
reversed: false,
categories: categories,
linkedTo: 0,
labels: {
step: 1
}
}],
yAxis: {
title: {
text: null
},
labels: {
formatter: function () {
return Math.abs(this.value) + '%';
}
}
},

plotOptions: {
series: {
stacking: 'normal'
}
},

tooltip: {
formatter: function () {
return '<b>' + this.series.name + ', age ' + this.point.category + '</b><br/>' +
'Population: ' + Highcharts.numberFormat(Math.abs(this.point.y), 0);
}
},

series: [{
name: 'Male',
data: [-2.2, -2.2, -2.3, -2.5, -2.7, -3.1, -3.2,
-3.0, -3.2, -4.3, -4.4, -3.6, -3.1, -2.4,
-2.5, -2.3, -1.2, -0.6, -0.2, -0.0, -0.0]
}, {
name: 'Female',
data: [2.1, 2.0, 2.2, 2.4, 2.6, 3.0, 3.1, 2.9,
3.1, 4.1, 4.3, 3.6, 3.4, 2.6, 2.9, 2.9,
1.8, 1.2, 0.6, 0.1, 0.0]
}]
});
});

});
</script>
<div id="container6" style="min-width: 310px; max-width: 800px; height: 400px; margin: 0 auto"></div>

我非常感谢我能得到的任何帮助。我已经尝试了所有我能想到的方法,并在 StackOverflow 上搜索类似的问题。但到目前为止还没有任何效果。

最佳答案

尝试使用以下代码代替 $('#container6').Highcharts({...});

var chart = new Highcharts.Charts({
chart:{
renderTo:'container6',
type: 'bar'
},
//other options
});

关于javascript - 在包含大量 HighCharts 的页面上,一个特定的图表未显示。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31418318/

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