How do I redraw an RGraph SVG line plot?

吃可爱长大的小学妹 提交于 2021-02-17 06:51:06

问题


I have a simple web server embedded on a microcontroller. One of the web pages allows the user to plot captured data (in CSV format). The page first loads all of the data and presents it to the user, but then I want to allow the user to do things like select and deselect data (columns), change line colors and change data scales. When I naively call RGraph.SVG.Line a second time, it simply redraws the modified chart over top of the already existing image. How do I get RGraph to delete the previous image and start over?

I've tried the following (separately):

RGraph.Clear(document.getElementById("plotDiv"));
RGraph.ObjectRegistry.Clear();
document.getElementById("plotDiv").innerHTML="";

"RGraph.Clear" and "Graph.ObjectRegistry.Clear" don't appear to be available in the SVG version of the library. When I delete the div's "innerHTML", the div is cleared, but then RGraph.SVG.Line doesn't draw anything at all when it's called again.

Is there anything else that I can try?


回答1:


You should call the clear function for SVG - not the canvas version:

RGraph.SVG.clear(myChart.svg);

To clear the registry (you may also need to do this):

RGraph.SVG.OR.objects = [];

You should then be able to draw a new chart on the SVG tag.



来源:https://stackoverflow.com/questions/58043375/how-do-i-redraw-an-rgraph-svg-line-plot

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!