使用AJAX重绘Google饼图

时间:2014-05-19 18:29:07

标签: ajax

我正在使用以下饼图代码从查询中提供数据:

 <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Customers', 'Status'],
          ['Accepted',     <?php echo $rowsaccepted ;?>],
          ['Declined',      <?php echo $rowsdeclined;?>],
          ['Not Reviewed',  <?php echo $rowsnreview;?>]
        ]);

        var options = {
                       'width':200,
                       'height':200,
                       'backgroundColor':'#474747',
                       'legend': 'none',
                       'chartArea':{left:20,top:0,width:250,height:250},
                       colors: ['#ef8200', '#007fc2', '#41cf0f'],
                       fontSize:14,

                   };

        var chart = new google.visualization.PieChart(document.getElementById('piechart'));
        chart.draw(data, options);
      }
    </script>

以及点击按钮后更新我的数据库的以下AJAX调用;因此更新图表数据,但我必须刷新图表的页面以刷新:

<script type="text/javascript">
$(function() {
$(".decline").click(function(){

var element = $(this);
var del_id = element.attr("id1");
var order_id = element.attr("data-order1");
 $.ajax({
   type: "POST",
   url: "decline.php",
   data: {id1:del_id,order_id1:order_id},
   success: function(){cache: false}
});
  $(this).parents(".show").animate({ backgroundColor: "#003" }, "slow")
  .animate({ opacity: "hide" }, "slow");

});
});
</script>

有什么办法可以在我的AJAX函数中添加一个调用来刷新和重绘饼图,而不需要刷新页面?

谢谢!

0 个答案:

没有答案