使用php数据数组绘制带有highcharts的piechart
Draw piechart with highcharts using php array of data
我想用JavaScript变量替换PHP数组$os_array
,以使用不同的值发送。与var x =<?php echo $os_array; ?>; drawcharts($x);
一样,当警报var x
结果为['Internet Explorer 7',1],['Internet Explorer 8',1],['Outlook 2007',2]
时
var x="<?php echo $os_array;?>";
drawcharts(x);
function drawcharts(x){
$('#_shared_graphs').highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
backgroundColor: '#f1f1f1'
},
title: {
text: 'OS'
},
tooltip: {
pointFormat: '{point.y} Using <b>{point.name}'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %',
style: {
color: (Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black'
}
}
}
},
series: [{
type: 'pie',
name: 'Sent Messag stat',
data: [x]
}]
});
}
好吧,定义你的js-fkt:
function drawcharts(x) {
$('#_shared_graphs').highcharts({
...
series: [{
...
data: x
}]
});
}
然后
var x =<?php echo json_encode($os_array); ?>;
drawcharts(x);
// reassign x
x = [ .... ];
drawcharts(x);
相关文章:
- 在Web应用程序中使用Highcharts javascript
- 在Highcharts中,我们可以通过任何方式在渲染图表之前获得plotWidth和plotHeight
- HighCharts长标题文本在某些元素上重叠
- Highcharts colorsByPoint与系列中的线性渐变一起使用时不起作用
- Highcharts-如何在自定义格式化程序中获得默认的y轴标签格式化程序
- Highcharts仪表未显示
- Highcharts-图表外的图例定位
- Highcharts动态烛台
- 在highcharts.js中向点弹出窗口动态添加文本
- Highcharts 3d调整zindex错误
- 如何在一页上显示多个Highcharts图表
- Highcharts可以从服务器加载数据,但不能更新
- 如何使用webview在React Native中使用Highcharts
- Highcharts热图上的多个轴
- Highcharts-显示noData覆盖和x轴标签
- highCharts:当数据集的颜色未定义时,切片在piechart中为白色
- Highcharts piechart标记出了父母
- 只有一个分段的HighCharts PieChart没有显示标签
- Highcharts检查是否选择了piechart部分
- 使用php数据数组绘制带有highcharts的piechart