Highcharts 错误:类型错误:未定义不是对象(评估 'chart.yAxis')



在收到ajax调用成功后,我正试图更新图表,但我收到了以下错误:TypeError: undefined is not an object (evaluating 'chart.yAxis')。我确信我调用update方法是正确的。有什么想法吗?图表的范围是否受到影响?它是在我检查时定义的。

var chart = .... chart ....
$('button#glucose_goals').click(function() {
    $.ajax({
        url:'glucose/goals',
        type: 'POST',
        data: $('form#glucose_boundary_form').serialize(),
        success: function(data) {
            chart.yAxis[0].update({ plotBands: [] });
            chart.redraw();
        }
    });
});

您修剪了几行代码。这是一把工作小提琴

 $('#update1').click(function () {
    chart.yAxis[0].update({
plotBands: [{
            color: '#FCFFC5',
            from: 144,
            to: 176,
            id: 'plotband-1'
        }]
    });
});

相关内容

最新更新