Resetting and clearing the chart?

Share RGraph:   Share or Like RGraph on Facebook!

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Dave on 4th August 2014
I currently have 1 canvas which I use to display 3 different data in separate time and I want it to erase all the data within the graph when I click different buttons and display a new one in same canvas.


I tried to use.Reset and .Clear, but it displays on top of the canvas and I am not too sure what to do from here to fix this.

Any help?

Posted by Richard on 4th August 2014
RGraph.reset(obj.canvas) is the function that you want. There's an example of it being used to clear the canvas for new charts here:

www.rgraph.net/demos/basic-clear.html




Richard
Posted by Dave on 4th August 2014
Is it possible to make it in such way that it performs both resetting and plotting at once?
I tried to use reset but it is not working for me for some reason.

Here is my code for resetting/drawing

var bar2 = new RGraph.Bar('linebarcanvas', barData)
                 .set('background.grid.vlines', false)

                 .set('gutter.left', 30)

                 .set('hmargin',2)
                 .set('ylabels.count', 4)
                 .set('colors', ['Gradient(#FEFCFF:#FFE5B4:#F9966B:#F75D59:#F62817)'])
                 .set('labels', t)
                 .set('ylabels.count', 4)
                 .set('text.color', '#837E7C')

                 .set('numxticks', 0)
                 .set('numyticks', 0)
                 .set('axis.color', '#B6B6B4')
                 .set('tickdirection', 1)
                 .set('shadow',true)
                 .set('shadow.color', '#B6B6B4' )
                 .set('shadow.blur', 2)
                 .set('shadow.offsetx', 2)
                 .set('shadow.offsety', -2)
                 .set('strokestyle', 'transparent')

                 var lineData = [421,347,375,348,314,326,475,554,642,712,657,526,421,451,451,365,524,514];

                     var line2 = new RGraph.Line('linebarcanvas',lineData )
                         .set('colors', ['#00ff00'])
                         .set('linewidth', 2)
                         .set('shadow',true)
                         .set('shadow.color', '#B6B6B4' )
                         .set('shadow.blur', 2)
                         .set('shadow.offsetx', 1)
                         .set('shadow.offsety', 1)
                         .set('tickmarks', 'null')

                 combo = new RGraph.CombinedChart(bar2, line2);
                 var canv = document.getElementById('linebarcanvas');
                 RGraph.Reset(canv);
                 lines2.draw();
Posted by Richard on 4th August 2014
Move this:

RGraph.Reset(canv);

So that its the first thing that you do - before you create any charts. Currently you're creating charts and then removing them from the canvas.





Richard
Posted by Dave on 5th August 2014
it works like a charm thank you very much!

Add a reply




« Back to message list