public VisitResult visit(VisitContext context, UIComponent target) {
if (target instanceof AbstractChartLegend) {
copyAttrs(target, chart, "", asList("position", "sorting"));
} else if (target instanceof AbstractChartSeries) {
AbstractChartSeries s = (AbstractChartSeries) target;
ChartDataModel model = s.getData();
particularSeriesListeners.add(s.getPlotClickListener());
// Collect Series specific handlers
Map<String, Object> optMap = new HashMap<String, Object>();
RenderKitUtils.Attributes seriesEvents = attributes().generic(
"onplothover", "onplothover", "plothover").generic(
"onplotclick", "onplotclick", "plotclick");
addToScriptHash(optMap, context.getFacesContext(), target,
seriesEvents,
RenderKitUtils.ScriptHashVariableWrapper.eventHandler);
if (optMap.get("onplotclick") != null) {
plotClickHandlers.put(new RawJSONString(optMap.get(
"onplotclick").toString()));
} else {
plotClickHandlers.put(s.getOnplotclick());
}
if (optMap.get("onplothover") != null) {
plothoverHandlers.put(new RawJSONString(optMap.get(
"onplothover").toString()));
} else {
plothoverHandlers.put(s.getOnplothover());
}
// end collect series specific handler
if (model == null) {
/**
* data model priority: if there is data model passed
* through data attribute use it. Otherwise nested point
* tags are expected.
*/
VisitSeries seriesCallback = new VisitSeries(s.getType());
s.visitTree(VisitContext.createVisitContext(FacesContext
.getCurrentInstance()), seriesCallback);
model = seriesCallback.getModel();
// if series has no data create empty model
if (model == null) {
switch (s.getType()) {
case line:
model = new NumberChartDataModel(ChartType.line);
break;
case bar:
model = new NumberChartDataModel(ChartType.bar);
break;
case pie:
model = new StringChartDataModel(ChartType.pie);
break;
default:
break;
}
} else {
nodata = false;
}
} else {
nodata = false;
}
model.setAttributes(s.getAttributes());
try {
// Check model/series compatibility
if (chartType == null && (!nodata)) {