Mark up a new series on the already presented jquery felt-tip pen chart

I have a float graph that already produces one row of data, i.e.

var plot = $.plot($('#placeholder'), [data1], options);

In later moments, I will receive some new data, which I also want to build on the same graph as a separate data series. Is there a way that I can simply add this new series of data to an existing graph, and do not need to build the entire graph again? That is, I want to avoid having to make another call as follows:

var plot = $.plot($('#placeholder'), [data1, data2], options);

and instead make the call like this:

plot.addSeries([data2], option);

Thank!

+5
source share
2 answers

@ . $.plot(...) (0.7) . , plot.setData(), plot.setupGrid() plot.draw()

setData, setupGrid draw API.txt

+2

ajax, , , . , , , ajax-, , . resetGraph .

var dataview = $("#placeholder");
$.ajax({
    url: "index.php",
    data: "stuff&junk&things",
    method: 'GET',
    dataType: 'json',
    success: function(msg){
        resetGraph(msg.dataview, msg.data, msg.data_ticks, msg.)
    }
});

function resetGraph(dataview, data, data_ticks ){

    plot = $.plot(dataview, data, {
        points: { show: true, radius: 5 },
        xaxis: { ticks: data_ticks, tickSize: 7 },
        yaxis: {labelHeight: 2}
    });

}

, , script, , resetGraph , .

+1

All Articles