Package org.richfaces.model

Examples of org.richfaces.model.ChartDataModel


            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)) {
                        // if series is empty do not set types
                        chartType = model.getType();
                        keyType = model.getKeyType();
                        valType = model.getValueType();
                    } else {
                        if (chartType == ChartDataModel.ChartType.pie) {
                            throw new IllegalArgumentException(
                                    "Pie chart supports only one series.");
                        }
                    }
                    if (keyType != model.getKeyType()
                            || valType != model.getValueType()) {
                        throw new IllegalArgumentException(
                                "Data model is not valid for this chart type.");
                    }

                    data.put(model.export());
                } catch (IOException ex) {
                    throw new FacesException(ex);
                }

            } else if (target instanceof AbstractChartXAxis) {
View Full Code Here

TOP

Related Classes of org.richfaces.model.ChartDataModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.