How do I call RGraph.SVG.clear(svg)?

Share RGraph:   To help my Google visibility (it can't get much worse!), if you like and use RGraph I'd appreciate it if you could link to me

« 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 Jan Dirk Zijlstra on 8th December 2016
To redraw my SVG.Bar graph, I want to clear it first.
I think I need to call RGraph.SVG.clear for this, but this needs the svg-element. How do I get to this element, because it is a private property of the SVG.Bar object.

Should I get the first svg-child of the container-div?
Wouldn't it be nicer to be able to pass it in the container-div (or the id of this container-div)?
Posted by Richard on 8th December 2016
Hi there,

It's not a private property - you can access it by doing this:

var svg = myBar.svg

> Should I get the first svg-child of the container-div?

You could do. IIRC the SVG tag is currently the only child of the DIV.

> Wouldn't it be nicer to be able to pass it in the container-div (or the id of this
> container-div)?

Probably both, in addition to the SVG tag. So you'd have three options. I just haven't got "a round tuit" yet.


Richard
Posted by Jan Dirk Zijlstra on 8th December 2016
Indeed, it works like a charm.

var bar = RGraph.SVG.Bar({id: "someId", data: [1,2,3], options: {}});
RGraph.SVG.clear(bar.svg);

Thanks,

Jan Dirk

Add a reply




« Back to message list