Javascript Highchart中未定义的值
我用带有Highcharts的html表格创建了一个饼图。一切正常,唯一的问题是,每当我在图表上悬停时,它都会显示未定义。下面是我当前解决方案的两个屏幕截图及其外观: 用于highchart的Javascript代码:Javascript Highchart中未定义的值,javascript,highcharts,Javascript,Highcharts,我用带有Highcharts的html表格创建了一个饼图。一切正常,唯一的问题是,每当我在图表上悬停时,它都会显示未定义。下面是我当前解决方案的两个屏幕截图及其外观: 用于highchart的Javascript代码: <script> Highcharts.chart('container', { data: { table: 'datatable' }, chart: { type: 'pie' }, ti
<script>
Highcharts.chart('container', {
data: {
table: 'datatable'
},
chart: {
type: 'pie'
},
title: {
text: 'Auswertung Herkunftsbefragung'
},
tooltip: {
formatter: function(){
return '<b>' +this.series.name + '</b><br />'+this.pointy+' '+this.point.name.toLowerCase();
}
}
});
</script>
<table id="datatable" style="border: 1px solid black"><thead><tr>
<th>Country</th>
<th>Counter</th>
</tr></thead><tbody>
<?php
foreach($analysis_data as $row){
echo "<tr>";
foreach(['country', 'counter'] as $attribute){
echo "<td>".$row[$attribute]."</td>";
}
echo "</tr>";
}
?>
</tbody></table>
Highcharts.chart('容器'{
数据:{
表:“数据表”
},
图表:{
键入:“馅饼”
},
标题:{
文字:“Auswertung Herkunftsbefragung”
},
工具提示:{
格式化程序:函数(){
返回'+this.series.name+'
'+this.pointy+''+this.point.name.toLowerCase();
}
}
});
构建HTML表的PHP代码:
<script>
Highcharts.chart('container', {
data: {
table: 'datatable'
},
chart: {
type: 'pie'
},
title: {
text: 'Auswertung Herkunftsbefragung'
},
tooltip: {
formatter: function(){
return '<b>' +this.series.name + '</b><br />'+this.pointy+' '+this.point.name.toLowerCase();
}
}
});
</script>
<table id="datatable" style="border: 1px solid black"><thead><tr>
<th>Country</th>
<th>Counter</th>
</tr></thead><tbody>
<?php
foreach($analysis_data as $row){
echo "<tr>";
foreach(['country', 'counter'] as $attribute){
echo "<td>".$row[$attribute]."</td>";
}
echo "</tr>";
}
?>
</tbody></table>
国家
柜台
有人知道我需要修改什么来归档吗?
<script>
Highcharts.chart('container', {
data: {
table: 'datatable'
},
chart: {
type: 'pie'
},
title: {
text: 'Auswertung Herkunftsbefragung'
},
tooltip: {
formatter: function(){
return '<b>' +this.series.name + '</b><br />'+this.point.y+' '+this.point.name.toLowerCase();
}
}
});
</script>
Highcharts.chart('容器'{
数据:{
表:“数据表”
},
图表:{
键入:“馅饼”
},
标题:{
文字:“Auswertung Herkunftsbefragung”
},
工具提示:{
格式化程序:函数(){
返回'+this.series.name+'
'+this.point.y+''+this.point.name.toLowerCase();
}
}
});
此.point.y
未定义。感谢@Troopers刚才这个.pointy
是未定义的使用这个.point.y
就像在上面的com中一样,你检查了这个.series.name
在你的情况下返回了什么吗?@Troopers:嗯,这样的小错误总是让我花了很多时间去搜索。非常感谢,先生:)