我遇到了ajax调用的更新高亮图问题。每当ajax调用运行时,它都会破坏整个饼图。
我的计划
$('#container').highcharts({
chart: {
type: 'pie'
},
title: {
text: 'Browser market shares. January, 2015 to May, 2015'
},
subtitle: {
text: 'Click the slices to view versions. Source: netmarketshare.com.'
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
format: '{point.name}: {point.y:.1f}%'
}
}
},
tooltip: {
headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
},
series: [{
name: 'Brands',
colorByPoint: true,
data: [<?php echo $cok; ?>]
}]
});
$cok
变量的值为{ name: 'No Answer', y: 10, drilldown: 'No Answer' },{ name: 'No Answer', y: 20, drilldown: 'No Answer' }
。但是当我使用ajax调用在Piechart中更新这些值时,它会破坏整个饼图。
我的Ajax电话:
setInterval(function(){
$.ajax({
type: "POST",
url: 'callexport.php',
data: {pie_ajax_campaign:'<?php echo $_SESSION['scampaign']; ?>',pie_ajax_date:$("#daterange").val() },
cache: false,
success: function(piedata)
{
$('#container').highcharts({
chart: {
type: 'pie'
},
title: {
text: 'Browser market shares. January, 2015 to May, 2015'
},
subtitle: {
text: 'Click the slices to view versions. Source: netmarketshare.com.'
},
plotOptions: {
series: {
dataLabels: {
enabled: true,
format: '{point.name}: {point.y:.1f}%'
}
}
},
tooltip: {
headerFormat: '<span style="font-size:11px">{series.name}</span><br>',
pointFormat: '<span style="color:{point.color}">{point.name}</span>: <b>{point.y:.2f}%</b> of total<br/>'
},
series: [{
name: 'Brands',
colorByPoint: true,
data: [piedata]
}]
});
return false;
}});
},20000);