Wednesday, 15 August 2012

flot - gFlot get color ..when is it attached to DOM in GWT -



flot - gFlot get color ..when is it attached to DOM in GWT -

since color of plotting fixed after component attached dom..when can phone call method using gwt? handler should implement come @ right time?

edit: actual context (vp verticalpanel):

plot=createplotgraph(); if (plot!=null){ plot.setsize("100%","100%"); vp.add(plot); vp.setcellheight(plot, "100%"); plot.addattachhandler(new attachevent.handler() { @override public void onattachordetach(attachevent event) { plot.getmodel().getseries().get(0).getautogeneratedcolor() system.out.println(plot.getmodel().getseries().length()); system.out.println(plot.getmodel().getseries().get(0).getcolor()); } }); }

and found have 3 (or more) series correctly rendered, see ok on screen, color wrote downwards println null.

other try:

if (plot!=null){ plot.setsize("100%","100%"); plot.addattachhandler(new attachevent.handler() { @override public void onattachordetach(attachevent event) { system.out.println(plot.getmodel().getseries().length()); system.out.println(plot.getmodel().getseries().get(0).getcolor()); } }); vp.add(plot); vp.setcellheight(plot, "100%"); }

same result

update, other try:

plot.setsize("100%","100%"); plot.addattachhandler(new attachevent.handler() { @override public void onattachordetach(attachevent event) { scheduler.get().scheduledeferred(new scheduledcommand() { @override public void execute() { system.out.println(plot.getmodel().getseries().length()); system.out.println(plot.getmodel().getseries().get(0).getcolor()); } }); } });

same result...null

you should add together attachevent.handler widget:

class="lang-java prettyprint-override">widget.addattachhandler(new attachevent.handler() { @override public void onattachordetach(attachevent event) { if (event.isattached()) { // widget got attached dom } else { // detached } } });

if having problems accessing jsni wrappers' values (in case gflot's), helps wrap phone call in scheduledcommand. ensure command executed after browser event loop returns - , that's when wrapper should initialized in dom.

class="lang-java prettyprint-override">scheduler.get().scheduledeferred(new scheduledcommand() { @override public void execute() { system.out.println(plot.getmodel().getseries().length()); system.out.println(plot.getmodel().getseries().get(0).getcolor()); } });

gwt flot

No comments:

Post a Comment