[英]Highchart / Use global option into an external JS file
我想將動態信息放入我的php頁面中,並將我的全局選項保留在外部JS文件中,但“選項”似乎未定義:
外部檔案:
$(function () {
var options = {
chart: {
rendedTo: 'barchart',
type: 'column',
width: 765
},
xAxis: {
labels: {
rotation: -45,
align: 'right'
}
},
yAxis: {
min: 0,
title: {
text: 'Nombre de sous-titres postés ce mois'
}
},
legend: {
enabled: false
},
tooltip: {
formatter: function() {
var s = (this.y > 1) ? 's' : '';
return '<b>'+ this.x +'</b><br/>'+
this.y+' sous-titre'+s+' posté'+s;
}
},
series: [{
name: 'Nombre d\'upload'
}]
}
});
然后我將建築線條放在我的頭標簽上:
<script type="text/javascript">
$(document).ready(function(){
$.getJSON('include/ajax/statistiquesMembreMensuel.json.php?id=1', function(data) {
options.xAxis.categories = data[0];
options.series[0].data = data[0];
options.chart.title = "Nombre d\'upload mensuel effectués par le membre '.stripslashes($row['pseudo']).'";
var chart = new Highcharts.Chart(options);
});
});
</script>
如果我將$_GET['id']
信息放入.js文件,該如何將其發送到getJSON
網址?
加載圖表后如何編輯圖表標題?
1)刪除var
以創建全局變量,或者更好的是刪除$(function () { ... });
包裝options
。
2)要設置標題,請參見本 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.