Skip to content

Cannot read property 'getAxis' of undefined #15367

@dingshengqin

Description

@dingshengqin

Version

3.5.1

Steps to reproduce

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();

What is expected?

when time data changed, I want to trigger the updata of echarts.
我想实现当input的时间数据发生变化时,触发echarts表格的更新

What is actually happening?

when time data changed, the ajax request is ok, data return is ok ,but echats has no data and no result.
时间数据变化时console.log没问题,ajax请求没有问题,数据return也没有问题,echarts显示没有数据

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugenThis issue is in Englishmissing-demoThe author should provide a demo.pendingWe are not sure about whether this is a bug/new feature.staleInactive for a long time. Will be closed in 7 days.waiting-for: author

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions