我在jQuery包装器中有一个changeGraph()函数,我需要从外部调用它。我需要从基于jQuery的图形库Flot访问函数setData。

来源看起来像这样:

function changeGraph(){
    // I need to access $.plot.setData somehow
};

var d2 = [[0, 0], [20, 300000]];

$(function () {
    $.plot($("#placeholder"),
    [{color: "#000000", data: d2}],
    {

    series: {
        lines: { show: true, fill:true, fillColor: {colors: [ "#d1ddea","#8e959d"]}},
        points: { show: false }
          }
       }
    );


});

我该怎么做?

最佳答案

var changeGraph;

$(function () {

    changeGraph = function () {
        // Need to access $.plot($("#placeholder") here
    };

});

changeGraph(); // call this when document is ready at least

09-16 10:41