Javascript 无法显示每个元素的highchart
我从数据库中获取了一个用户,他们都有评论分数。 我使用while语句用highchart显示每个用户和评论分数 问题是我只得到一个图表,而不是每个用户都得到一个 这是密码 PHP: Javascript:Javascript 无法显示每个元素的highchart,javascript,php,mysql,highcharts,Javascript,Php,Mysql,Highcharts,我从数据库中获取了一个用户,他们都有评论分数。 我使用while语句用highchart显示每个用户和评论分数 问题是我只得到一个图表,而不是每个用户都得到一个 这是密码 PHP: Javascript: <script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script> <script src="http://code.highcharts.com/highch
<script src="http://code.jquery.com/jquery-1.9.1.js" type="text/javascript"></script>
<script src="http://code.highcharts.com/highcharts.js" type="text/javascript"></script>
<script>
$(document).ready(function () {
var x="<?php echo $point;?>";
var chart = new Highcharts.Chart({
chart: {
type: 'bar',
renderTo: 'Scores',
marginRight: 50,
events: {
//load: loadRed
}
},
title: {
text: '',
style: {
color: 'black',
fontWeight: '700',
fontFamily: 'Arial',
fontSize: 20
}
},
xAxis: {
categories: ['Review Score'],
title: {
text: null
},
gridLineWidth: 0,
minorGridLineWidth: 0,
labels: {
style: {
color: 'black',
fontWeight: '700',
fontFamily: 'Arial',
fontSize: 11,
width: 90
}
}
},
yAxis: {
min: 0,
max: 100,
gridLineWidth: 0,
minorGridLineWidth: 0,
labels: {
enabled: false
},
title: {
text: null
}
},
tooltip: {
valueSuffix: ' /100'
},
plotOptions: {
series: {
stacking: 'percent'
},
bar: {
grouping: false,
dataLabels: {
enabled: false
}
}
},
legend: {
enabled: false,
align: 'right',
x: -40,
y: 100,
floating: false,
borderWidth: 0,
backgroundColor: '#FFFFFF',
shadow: false
},
credits: {
enabled: false
},
series: [
{
name: 'null',
data: [x],
borderWidth: 0,
color: "rgba(0,0,0,0)"
}, {
name: 'Score',
data: [x],
borderWidth: 0,
stack: 1,
animation: false,
color: "gray"
}, {
name: 'Score',
data: [x],
color: "green",
borderWidth: 0,
borderRadius: 5
}
]
});
});
</script>
非常感谢您的帮助您应该通过添加不同的id和循环javascript代码为许多用户创建许多highcahrt实例 换衣服
<div id='Scores' ....
到
问题是x变量是字符串,但应该是数组。因此,考虑用PHPJSON JSONYNECOND打印,然后用函数$.GETJSON.</P>在JavaScript中进行浏览。
<div id='Scores' ....
<div id='Scores_".$reviewee_id."' ....
$show_review.="<br><div ......
renderTo: 'Scores',
renderTo: 'Scores_<?php echo $reviewee_id>',