manuelluis / jsrrdgraph

javascript rrdgraph
61 stars 12 forks source link

Add async method for getting the rrd files #7

Closed Feandil closed 10 years ago

Feandil commented 10 years ago

Adding some async methods required to make CGP more responsive (see https://github.com/pommi/CGP/pull/37)

No modification to the existing API, I'm just adding stuff ,) I tried to re-use as much existing code as possible, as you can see in the "splitting" commits.

I'm not good at javascript, thus do not hesitate to make comments

manuelluis commented 10 years ago

Thanks for the patch.

Feandil commented 10 years ago

Thanks :)

I just realised that '"async_paint" is probably not the best choice for a function name. The async part of this function is the fetch. The painting part will not be async, it's still using graph_paint_draw() (sorry)

manuelluis commented 10 years ago

maybe a single function like this?

RrdGraph.prototype.graph_paint = function (async_fetch)
{
        this.graph_paint_init()
        if (async_fetch === undefined || !async_fetch) {
                if (this.data_fetch() === -1)
                        return -1;
                return this.graph_paint_draw()
        } else {
                this.data_fetch_async()
        }
};