dingshengqin opened a new issue #15366:
URL: https://github.com/apache/echarts/issues/15366


   需求:我想实现当input的时间数据发生变化时,粗发echarts表格的更新
   问题:时间数据变化时console.log没问题,ajax请求没有问题,数据return也没有问题,echarts显示没有数据
   报错:echarts-all.js:9 Uncaught TypeError: Cannot read property 'getAxis' of 
undefined
   麻烦大神指导!感谢!
   
   document.getElementById("end-time").onchange = function(){
                        var myCharts3 = 
echarts.init(document.getElementById('main'));
                        var start_time1 =  
document.getElementById("start-time").value;
                   var end_time1 =  document.getElementById("end-time").value;
                   {#document.write(start-time1)#}
                   {#document.write(end_time1)#}
                        document.cookie="end_time="+end_time1;
                        document.cookie="start_time="+start_time1;
                   myCharts3.setOption({
                       tooltip: {},
                       toolbox: {
                           left: 'center',
                           itemSize: 25,
                           top: 55,
                           feature: {
                               dataZoom: {
                                   yAxisIndex: 'none'
                               },
                               restore: {}
                           }
                       },
                       xAxis: {
                           data: []
                       },
                       yAxis: {},
                       series: [{
                           name: '平均节拍',
                           type: 'bar',
                           data: []
                       }]
                   });
   
                   $.ajax({
                       url:'/get_avg_cycledata',
                       success:function (data){
                               json_data=JSON.parse(data)
                               console.info(json_data['value1'])
                               console.info(json_data['count1'])
                               console.log(json_data['value1'])
                               console.log(json_data['count1'])
   
                          myCharts3.setOption({
                                       xAxis: {
                                           data: json_data['count1']
                                       },
                                       series: [{
                                           name: '平均节拍',
                                           type: 'bar',
                                           data: json_data['value1']
                                       }]
                                   });
   
   
                       },
                    error : function(errorMsg) {
                        //请求失败时执行该函数
                        alert("图表请求数据失败!");
                    }
               })
               }
               // 触发change事件的函数
               function dispatchChange(){
                 var changeEvent = document.createEvent("Events");
                 changeEvent.initEvent("change",true,true);
                 parent.dispatchEvent(changeEvent);
               }
               dispatchChange();


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to