“我使用了简单的jquery饼图代码。在刷新显示饼图的页面后,这个饼图没有显示第一个请求。”下面是我的代码。
<?php
$total_advanced = 0;
$total_proficient = 0;
$total_basic = 0;
$total_belowbasic = 0;
$total_farbelow = 0;
$total_noscore = 0;
?>
<div id="proficiency_pie<?php echo $widget->id;?>" style="width: auto; min-width: 150px; height: 150px;"></div>
<script>
var data = <?php echo json_encode(array(
array( 'label'=>"Advanced", 'data'=>$total_advanced, 'color'=>'#007F5B'),
array( 'label'=>"Proficient", 'data'=>$total_proficient, 'color'=>'#00CB95'),
array( 'label'=>"Basic", 'data'=>$total_basic, 'color'=>'#FFB800'),
array( 'label'=>"Below Basic", 'data'=>$total_belowbasic, 'color'=>'#F9CF60'),
array( 'label'=>"Far Below", 'data'=>$total_farbelow, 'color'=>'#F17F71'),
array( 'label'=>"No Score", 'data'=>$total_noscore, 'color'=>'#EEEEEE'),
)); ?>;
$(function(){
try {
$.plot($("#proficiency_pie<?php echo $widget->id;?>"), data,
{
series: {
pie: {
show: true
}
}
});
} catch ($e) {}
});
</script>