JsArray<GwtSeriesDataOptions> seriesDataArr = JavaScriptObject
.createArray().cast();
// Process each series data
for (int cnt = 0; cnt < uidl.getChildCount(); cnt++) {
GwtSeriesDataOptions seriesData = GwtSeriesDataOptions.create();
UIDL seriesUIDL = uidl.getChildUIDL(cnt);
String seriesName = seriesUIDL.getStringAttribute("name");
if (seriesName != null && namesOfSeriesToAdd != null) {
if (!doesArrayContainSeriesName(namesOfSeriesToAdd, seriesName)) {
continue;
}
}
// From charts series data retrieve only those series data
// whose names are specified in the second argument
if (seriesUIDL.hasAttribute("name")) {
// Setting name automatically sets series id which can later be
// used to retrieve using chart.get(id);
seriesData.setName(seriesName);
}
if (seriesUIDL.hasAttribute("stack")) {
seriesData.setStack(seriesUIDL.getStringAttribute("stack"));
}
// FIXME - fallback on chart options type if series doesn't have a
// type
String seriesType = "line";
if (seriesUIDL.hasAttribute("type")) {
seriesType = seriesUIDL.getStringAttribute("type");
seriesData.setType(seriesType);
}
if (seriesUIDL.hasAttribute("xAxis")) {
seriesData.setXAxis(seriesUIDL.getIntAttribute("xAxis"));
}
if (seriesUIDL.hasAttribute("yAxis")) {
seriesData.setYAxis(seriesUIDL.getIntAttribute("yAxis"));
}
// Get data/points
seriesData.setDataAsPointOptions(getSeriesPoints(seriesUIDL
.getChildUIDL(1)));
// Get series options
GwtSeriesGeneralOptions seriesOptions = getSeriesOptions(
seriesType, seriesUIDL.getChildUIDL(0));
if (seriesOptions != null) {
seriesData.setSeriesOptions(seriesOptions);
}
seriesDataArr.push(seriesData);
}