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.

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?