Javascript 在有许多高图表的页面上,一个特定的图表未显示。
我对编码非常陌生,但最近一直在努力学习如何使用HighCharts。我有一个Wordpress页面,显示5或6个不同的Highchart。他们都很好 除了一个。这个特殊的图表只是在它应该出现的地方留下了一个很大的空白。它在JSFIDLE中工作(应该如此,因为我只是使用HighChart的样板代码) 请参见此处: 当我在wordpress页面上运行我的浏览器错误控制台时,它显示: TypeError:$(…)。highcharts不是函数 并明确指出代码中的这一行: $('#container6')。高图({ 以下是图表的完整实际代码:Javascript 在有许多高图表的页面上,一个特定的图表未显示。,javascript,wordpress,highcharts,Javascript,Wordpress,Highcharts,我对编码非常陌生,但最近一直在努力学习如何使用HighCharts。我有一个Wordpress页面,显示5或6个不同的Highchart。他们都很好 除了一个。这个特殊的图表只是在它应该出现的地方留下了一个很大的空白。它在JSFIDLE中工作(应该如此,因为我只是使用HighChart的样板代码) 请参见此处: 当我在wordpress页面上运行我的浏览器错误控制台时,它显示: TypeError:$(…)。highcharts不是函数 并明确指出代码中的这一行: $('#container6'
<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>
$(函数(){
//年龄类别
变量类别=['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 + '];
$(文档).ready(函数(){
$('#container6')。高图({
图表:{
类型:'bar'
},
标题:{
正文:“2015年德国人口金字塔”
},
副标题:{
文本:“来源:”
},
xAxis:[{
类别:类别,,
相反:错,
标签:{
步骤:1
}
},{//右侧的镜像轴
相反:是的,
相反:错,
类别:类别,,
链接到:0,
标签:{
步骤:1
}
}],
亚克斯:{
标题:{
文本:空
},
标签:{
格式化程序:函数(){
返回Math.abs(this.value)+'%';
}
}
},
打印选项:{
系列:{
堆叠:“正常”
}
},
工具提示:{
格式化程序:函数(){
返回“+this.series.name+”,age“+this.point.category+”
+
'人口:'+Highcharts.numberFormat(Math.abs(this.point.y),0);
}
},
系列:[{
姓名:'男',
数据:[-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]
}, {
姓名:'女',
数据:[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]
}]
});
});
});
我非常感谢我能得到的任何帮助。我已经尝试了我能想到的一切,并搜索了StackOverflow以寻找类似的问题。但到目前为止没有任何效果。尝试使用以下代码,而不是$('#container6')。Highcharts({…})
尝试使用以下代码而不是$('#container6')。Highcharts({…}) 删除行:
$(document).ready(function () {
并在container6中删除相应的JavaScript代码图后
});
在这之后,一切都应该正常工作:
请参阅第443行和第505行。删除行:
$(document).ready(function () {
并在container6中删除相应的JavaScript代码图后
});
在这之后,一切都应该正常工作:
请参阅第443行和第505行。配置看起来很正确,您是否有一个未工作图表的实时演示?这里是一个实时演示:您会注意到页面下方约1/3处,前两个图表下方有一个很大的空白。这就是图表应该显示的位置。配置看起来很正确,您有未工作图表的实时演示吗hart?这是一个实时演示:你会注意到在页面的1/3处,在前两个图表的下方,有一个很大的空白。这就是图表应该出现的地方。请原谅,因为我是新手-我了解jquery脚本文件是什么,但我的“highchart库”是什么?通过“Highcharts库”,我指的是Highchart脚本文件。请原谅,因为我是新手-我了解什么是jquery脚本文件,但什么是我的“Highchart库”?我指的是Highchart脚本文件。