Examples of BadDataForChartException


Examples of com.cfinkel.reports.exceptions.BadDataForChartException

        XYSeries series = new XYSeries("Data");
        for (Object obj : data) {
            Map result = (Map)obj;
            if (result.values().size() < 2)
                throw new BadDataForChartException("For chart, must have at least two columns of data");
            Iterator iterator = result.entrySet().iterator();
            Object column1Value = ((Map.Entry)iterator.next()).getValue();
            Object column2Value = ((Map.Entry)iterator.next()).getValue();
            if (!(column1Value instanceof Number) || !(column2Value instanceof Number))
                throw new BadDataForChartException("Data must be decimal or integer.  Can't plot otherwise.");
            series.add((Number)column1Value,
                    (Number)column2Value);
        }

        return new XYSeriesCollection(series);
View Full Code Here

Examples of com.cfinkel.reports.exceptions.BadDataForChartException

        DefaultCategoryDataset dataset = new DefaultCategoryDataset();
        for (Object obj : data) {
            Map result = (Map)obj;
            if (result.values().size() < 2)
                throw new BadDataForChartException("For chart, must have at least two columns of data," +
                        " with the first column having the categories and the other columns having the data ");

            boolean weAreAtTheFirstColumn = true;
            String dataName = "";
            for (Object entryObj : result.entrySet()) {
                Map.Entry entry = (Map.Entry)entryObj;
                Object datum = entry.getValue();
                String columnName = (String)entry.getKey();

                if (weAreAtTheFirstColumn) {
                    if (!(datum instanceof String))
                        throw new BadDataForChartException("First column must be a string, isstead it's " + datum.getClass().toString());
                    dataName = (String)datum;
                    weAreAtTheFirstColumn = false;
                } else {
                    if (!   ((datum instanceof BigDecimal) || (datum instanceof BigInteger)) )
                        throw new BadDataForChartException("Data must be decimal or integer.  Can't plot otherwise.");
                    // add the value to the dataset:
                    dataset.addValue((Number)datum,columnName,dataName);
                }

            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.