custom widget visualization api problem

EDIT: this doesn’t have any problem loading in a GWT application. Attached a simple test.

I’m embedding a
Visualization API
widget in Vaadin.
I attached a basic war with all the libraries minus GWT.

The problem is, when the application loads, the widget doesn’t show, but if i do an attach() - or requestRepaint() later in the time line, from a button action, it does. I can’t do it any other way, as i tried. For example:

as you can see, the visualization starts after the repaintAll, and i suspect this is why it doesn’t show.

when i push the button, with the attach() - or requestRepaint(), this gets sent, and the visualization widget shows:

How to fix this?
11185.war (4.62 MB)
11186.zip (81.2 KB)

My guess was right, the widget was initializing after the first application paint, so it needed another right after the callback returned and initialization got done.

I called a method from the superclass MyWidget that i implemented in the VMyWidget subclass:


public abstract class MyWidget extends Composite {
...
class OnLoadCallback implements Runnable {
		public void run() {
...
repaint();
                }
}
protected abstract void repaint();
...
}
	protected void repaint() {
		// Updating the state to the server can not be done
        // before the server connection is known, i.e., before
        // updateFromUIDL() has been called.
        if (paintableId == null || client == null)
            return;
		client.updateVariable(paintableId, "repaint", true, true);
		
	}

and in the server side:

@Override
	public void changeVariables(Object source, Map<String, Object> variables) {
		// Sets the currently selected color
		if (variables.containsKey("repaint") && !isReadOnly()) {
			// Changing the property of the component will
			// trigger a ValueChangeEvent
			setValue(variables.get("repaint").toString(), false);
		}
	}

Last issue was that it only repainted the first time, all subsequent variables were compared against the first and nothing was done, so this solves it:

public void changeVariables(Object source, Map<String, Object> variables) {
		// Sets the currently selected color
		if (variables.containsKey("repaint")) {
			// Changing the property of the component will
			// trigger a ValueChangeEvent
			this.requestRepaint();
			//setValue(variables.get("repaint").toString(), false);
		}
	}

Additional note:

If you want to patch the addon source itself, you should implement the repaint() method mentioned above in:

org.vaadin.vaadinvisualizations.widgetset.client.ui.VVisualizationWidget

Call the repaint() method from within the run() method of the internal APILoadCallback class located inside the VVisualizationWidget class. I placed the call at the very end of the method.

Finally, find the changeVariables(…) method in

org.vaadin.vaadinvisualizations.VisualizationComponent

At the bottom of the method add the call to requestRepaint()


		if (variables.containsKey("repaint")) {
			// Changing the property of the component will
			// trigger a ValueChangeEvent
			this.requestRepaint();
		}

Recompile the project and you should be good to go. I did notice a strange delay the first time it worked, but it hasn’t done it since.

Hi,

I am using the column chart and line chart of this addon. I have some questions or concerns around it :

  1. When ever select a data point , i get the selection event, but the object returned give “undefined”. How can we get to the exact object that is clicked

  2. Some of the GWT options does not work. For eg, if i try to say : columnChart.setOptions(“hAxis.title”, “ABC”);. This does not changes anything in the graph. But the other options like width, height, legend works.

Please provide me solutions if someone has worked on this before.

Thanks & Regards,
Abhinav

i have the same question with Abhinav.
Please provide me solutions if someone has worked on this before.