java - Resize Canvas in GWT having a d3 svg in the div -
i drawing 4 d3 line charts in canvas category layer , have canvas , div list categories below
private arraylist<canvas> catcanvaslist; private arraylist<element> catdivlist; private int categorycount = 0; vlayout categorylayer; catcanvaslist = new arraylist<canvas>(); catdivlist = new arraylist<element>(); categorycount = data.getcategories().size(); (int = 0; < categorycount; i++) { canvas cat = new canvas(); cat.setwidth100(); cat.setheight100(); categorylayer.addmember(cat); catcanvaslist.add(cat); } int a= 0; for( final string key: data.getcategories()){ final canvas c = catcanvaslist.get(a); final element div = dom.creatediv(); catdivlist.add(div); created3vis(div,key,data); a++ }
on window resize redarw d3 vis in following way
categorylayer.addresizedhandler(new resizedhandler() { @override public void onresized(resizedevent event) { if (!catdivlist.isempty() && !catcanvaslist.isempty()) { (element div : catdivlist) { div.removefromparent(); } catdivlist.clear(); for(final canvas c:catcanvaslist){ c.getdom().removeallchildren(); } } int a= 0; for( final string key: data.getcategories()){ final canvas c = catcanvaslist.get(a); final element div = dom.creatediv(); catdivlist.add(div); created3vis(div,key,data); a++ } } });
but above mentioned way not work on resize , not remove div elemets properly.
i want resize canvas on window resize , redraw d3 vis new height , width.
can point me i'm going wrong.
Comments
Post a Comment