【发布时间】:2015-10-23 14:43:57
【问题描述】:
我想在 highchart 系列中使用 javascript 变量,但它似乎不起作用:
function groupBar(n) {
var nu;
nu = parseInt(n);
var series_b_tab = <?php echo json_encode($series_bar)?>;
var series_b = series_b_tab[n];
series_b = series_b.join(",");
$('#bar_project_'+n).highcharts({
chart: {
type: 'column',
height : 300,
width: 500
},
title: {
text: 'Logements connectés'
},
subtitle: {
text: 'Source: Valenciennes Métropole'
},
xAxis: {
categories: [<?php echo join($legend_bar,',') ?>],
title: {
text: null
},
labels: {
rotation: -45,
style: {
fontSize: '9px'
}
}
},
yAxis: [
{
min: 0,
//max: 8000,
labels:{
style :{
color: 'red'
}
},
title: {
text: 'Nombre de connexions par type',
align: 'middle'
},
labels: {
overflow: 'justify'
},
opposite: true
},
// second yAxis
{
min: 0,
//max: 70,
labels:{
style :{
color: 'red'
}
},
title: {
text: 'Pourcentage (%)',
align: 'middle'
},
labels: {
overflow: 'justify'
}
}],
tooltip: {
valueSuffix: ' %'
},
legend: {
layout: 'vertical',
align: 'left',
verticalAlign: 'top',
x: 50,
y: 60,
floating: true,
borderWidth: 1,
backgroundColor: '#FFFFFF',
shadow: true,
itemStyle: {
color: 'black',
fontSize: '9px'
}
},
plotOptions: {
series: {
animation: false
},
},
series: [{series_b}]
});
};
n=1 时的 series_b_tab[n] 示例如下:
{name : 'Commité : 0', type :'column', yAxis : 1 ,data : [2436]},{name : 'Commité: 1', type :'column', yAxis : 1 ,data : [2510,171]}
我不知道如何把 series_b 的内容串联起来。
也许我可以使用 json_parse ?
感谢您的帮助!
【问题讨论】:
标签: javascript json highcharts series