我正在使用 API highcharts 按国家/地区显示我网站的访问者数量。我通过 mysql 接收数据,我在 php 中有这个表:<?php $data = Array ( [0] => Array ( [name] => DE [y] => 1 ) [1] => Array ( [name] => FR [y] => 3 ) [2] => Array ( [name] => US [y] => 1 ) [3] => Array ( [name] => XX [y] => 1 ) ); ?>然后在我的 php 文件的底部,我放了我的 js:var g_donnes = '<?php echo json_encode($data); ?>';Highcharts.chart('container', { chart: { plotBackgroundColor: null, plotBorderWidth: null, plotShadow: false, type: 'pie' }, title: { text: 'Browser market shares in January, 2018' }, 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: g_donnes }]});所以当我做一个console.log(g_donnes)时,我有这个表[{"name":"DE","y":1},{"name":"FR","y":3},{"name":"US","y":1},{"name":"XX","y":1}],但是在数据级别的代码没有处理g_donnes的缺点:g_donnes
1 回答
- 1 回答
- 0 关注
- 155 浏览
添加回答
举报
0/150
提交
取消