weixin_33699914 2017-03-08 17:19 采纳率: 0%
浏览 43

用ajax动态的anychart

I have some problems when I using anychart with ajax. Because data of anychart is dependent on the check_box users select, I have to ajax the data. the basic form of chart is fine, but selected data do not work on the chart

Here is my code.

<body>
 <div>
  <input type='checkbox' name='question_id' value='1'>
  <input type='checkbox' name='question_id' value='2'>
  <input type='checkbox' name='question_id' value='3'>
  <input type='checkbox' name='question_id' value='4'>
  <input type='checkbox' name='question_id' value='5'>
  <input type='checkbox' name='question_id' value='6'>
 <div>
 <button id='report'>report</button>
 <div id='container'></div>

</body>

and my ajax and anychart setting is as below

<script>
  $(function() {
   $('#report').click(function() {
     $.ajax({
       type: 'POST',
       data: {
        ids: $("input[name='question_id']:checked").map(function () {
        return $(this).val();
        }).get()
       },



     });

   });
  });

  anychart.onDocumentReady(function() {
   var dataSet = anychart.data.set(<%= select_data %>);
   var chart = anychart.column();
   ......
   ......
   chart.container('container');
   chart.draw();

  });
</script>

I am thinking that I have to rerender the anychart so the ajax data could be loaded, but I have no idea how to make it work

  • 写回答

2条回答 默认 最新

  • weixin_33724570 2017-03-09 11:13
    关注

    It seems you don't apply changes to data.

    When you receive the new data you should apply it to a chart, it can be done like this:

    dataSet = anychart.data.set(newData);

    or

    chart.data(newData);

    Also, in your code chart and data variables are local within onDocumentReady function.

    评论

报告相同问题?

悬赏问题

  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。