VisualizationsForVaadin: set Object options

Dear all,

Google chart API (where VisualizationsForVaadin is build upon) has plenty of options to format the charts, e.g:

Option
hAxis.textStyle Object {color: ‘black’, fontName: , fontSize: }

VisualizationsForVaadin has an setOption for that, but doesn’t seem to support the “object” type for an option. I think there should be a setOption(String name, Map value) method or is there any other way to set complex options?

Regards,
Rudolf

Hey Rudolf

You got a answer or found a own solution for your question?

I have the same problem at the moment. I want to change the color and font-size of for example the titleTextStyle for a LineChart.

Regards

Andreas

Same problem here. Makes the addon not usable for me if there is not solution

Hi all,
I’ve encountered the same problem.And my workaround for the above problem is replacing the convertOptions method of VVisualizationWidget class with below code. It worked for me. Now I can set hAxis and vAxis options as declared in GWT Visualization gallery pages.

hope this helps,
kinds,


/**USAGE**/
LineChart chart = new LineChart();
chart.setOption("legend", "bottom");
chart.setOption("hAxis.title", "Tarih");
chart.setOption("vAxis.title", "Voltaj");

/**REPLACE METHOD AND RECOMPILE**/
protected AbstractDrawOptions convertOptions(String[] opNames, String[]
 opTypes, Object[] opValues) {
		AbstractDrawOptions ops = createOptions();
		if (opNames == null) {
			return ops;
		}
		AbstractDrawOptions temp = null;
		for (int i = 0; i < opNames.length; i++) {
			String name = opNames[i]
;
			String type = opTypes[i]
;
			Object value = opValues[i]
;

			if (name.contains(".")) {
				int index = name.indexOf(".");
				String objName = name.substring(0, index);
				name = name.substring(index + 1);
				try {
					temp = ops.getObject(objName).cast();
				} catch (TypeException e) {
					Window.alert("exception in convertOptions");
				}
				if (temp == null) {
					temp = JavaScriptObject.createObject().cast();
					ops.set(objName, temp);
				}
			} else {
				temp = ops;
			}

			ApplicationConnection.getConsole().log("Name " + name + " Type " + type + " Value " + value);
			if (OPTYPE_BOOLEAN.equals(type)) {
				ApplicationConnection.getConsole().log("BOOL");
				temp.set(name, ((Boolean) value).booleanValue());
			} else if (OPTYPE_INT.equals(type)) {
				ApplicationConnection.getConsole().log("INT " + value.toString());
				temp.set(name, Double.valueOf(value.toString()));
			} else if (OPTYPE_DOUBLE.equals(type)) {
				ApplicationConnection.getConsole().log("DOU");
				temp.set(name, ((Double) value).doubleValue());
			} else {
				ApplicationConnection.getConsole().log("STR " + name + " " + (String) value);

				temp.set(name, (String) value);

			}
		}

		ops.set("width", (double) getElement().getClientWidth());
		ops.set("height", (double) getElement().getClientHeight());
		return ops;
	}