我需要在Highcharts中从数组中设置一些Xaxis值。
print_r($monthName);
我有阵列:Array ( [0] => August [1] => September [2] => October [3] => November [4] => December [5] => January )
。
我的代码是:
<script>
$(function () {
var monthNameData = [];
monthNameData.push({
data: ['<?php echo join ($monthName, ',') ?>']
});
$('#iw').highcharts({
chart: {
...
xAxis: {
categories: monthNameData[0].data
},
series: ...
});
});
我的结果是:
谢谢
答案 0 :(得分:0)
如下所示纠正
<强>要么强>
monthNameData.push({
data: <?php echo json_encode($monthName); ?>
});
或强>
monthNameData.push({
data: [<?php echo "'".join($monthName, "','")."'"; ?>]
});