私は管理ダッシュボードの円グラフを使って、ユーザーに関するデータを表示しています。私はPHPファイルからの応答を正しく取得しており、以下のコードを参照できるように変数result_from_PHP
に格納します。私の問題は、この変数result_from_PHP
をコードy: result_from_PHP
のseries
に渡す方法がわかりません。誰でも助けてくれますか?どのようにJavaScript配列に値を渡すのですか?
<script type="text/javascript">
$.getJSON("PHP_trader_behav.php", function(data){
$.each(data.result,function(){
var result_from_PHP = this['visitors_count'];
alert(result_from_PHP);
$(function() {
alert(result_from_PHP);
$('#container').highcharts({
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Browser market shares January, 2015 to May, 2015'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
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: [{
name: 'Brands',
colorByPoint: true,
data: [{
name: 'Microsoft Internet Explorer',
y: result_from_PHP
}, {
name: 'Chrome',
y: 5000,
sliced: true,
selected: true
}, {
name: 'Firefox',
y: 1000
}, {
name: 'Safari',
y:1000
}, {
name: 'Opera',
y: 4000
}, {
name: 'Proprietary or Undetectable',
y:3000
}]
}]
});
});
});
});
</script>
js – aldrin27
の '(Yourdata).push()'を使用してください私に例を挙げてもらえますか? @ aldrin27 – Ali
Read:https://www.webmasterworld.com/javascript/4611333.htm – aldrin27