Example usage for org.jfree.chart.plot XYPlot setOrientation

List of usage examples for org.jfree.chart.plot XYPlot setOrientation

Introduction

In this page you can find the example usage for org.jfree.chart.plot XYPlot setOrientation.

Prototype

public void setOrientation(PlotOrientation orientation) 

Source Link

Document

Sets the orientation for the plot and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:probe.com.view.body.quantdatasetsoverview.quantproteinstabsheet.studies.ProteinStudyComparisonScatterPlotLayout.java

/**
 * Creates a sample jFreeChart./*from www.  j  a va 2  s. co  m*/
 *
 * @param dataset the dataset.
 *
 * @return The jFreeChart.
 */
private void generateScatterplotchart(DiseaseGroupsComparisonsProteinLayout cp, int w, int h) {

    final XYSeriesCollection dataset = new XYSeriesCollection();
    XYSeries downSer = new XYSeries(0);
    XYSeries stableSer = new XYSeries(1);
    XYSeries upSer = new XYSeries(2);

    XYSeries novalueProvidedSer = new XYSeries(3);

    XYSeries downSerII = new XYSeries(4);
    XYSeries stableSerII = new XYSeries(5);
    XYSeries upSerII = new XYSeries(6);
    XYSeries novalueProvidedSerII = new XYSeries(7);

    //        XYSeries plusSeries = new XYSeries(6);
    double downCounter = 1;
    double stableCounter = 3;
    double upCounter = 5;
    double novalueProvidedCounter = 3;

    patientGroupsNumToDsIdMap.clear();

    final Map<Integer, int[]> paTGrNumbtrendMap = new HashMap<Integer, int[]>();
    double maxPatNumber = -1.0;
    for (String protTrend : cp.getPatientsNumToTrindMap().keySet()) {
        List<Integer> patNums = cp.getPatientsNumToTrindMap().get(protTrend);
        int coun = 0;
        for (int i : patNums) {
            if (i > maxPatNumber) {
                maxPatNumber = i;
            }
            if (!patientGroupsNumToDsIdMap.containsKey(i)) {
                ComparisonDetailsBean pGr = new ComparisonDetailsBean();
                patientGroupsNumToDsIdMap.put(i, pGr);

            }
            if (!paTGrNumbtrendMap.containsKey(i)) {
                int[] values = new int[4];
                paTGrNumbtrendMap.put(i, values);
            }

            int[] values = paTGrNumbtrendMap.get(i);
            ComparisonDetailsBean pGr = patientGroupsNumToDsIdMap.get(i);
            if (protTrend.equalsIgnoreCase("noValueProvided")) {
                values[3] = values[3] + 1;
                pGr.addNovalueProvided(cp.getDSID(3, coun));

            } else if (protTrend.equalsIgnoreCase("up")) {
                values[2] = values[2] + 1;

                pGr.addUpRegulated(cp.getDSID(0, coun));

            } else if (protTrend.equalsIgnoreCase("down")) {
                values[0] = values[0] + 1;
                pGr.addDownRegulated(cp.getDSID(2, coun));
            } else {
                values[1] = values[1] + 1;
                pGr.addNotRegulated(cp.getDSID(1, coun));
            }
            paTGrNumbtrendMap.put(i, values);
            patientGroupsNumToDsIdMap.put(i, pGr);
            coun++;
        }

    }

    for (int i : paTGrNumbtrendMap.keySet()) {
        int[] values = paTGrNumbtrendMap.get(i);
        if ((values[2] > 1)) {
            upSer.add(upCounter, i);
            upSerII.add(upCounter, i);
        } else if ((values[2] == 1)) {
            upSer.add(upCounter, i);
        }
        if ((values[1] == 1)) {
            stableSer.add(stableCounter, i);
        } else if ((values[1] > 1)) {
            stableSer.add(stableCounter, i);
            stableSerII.add(stableCounter, i);
        }

        if ((values[0] > 1)) {
            downSer.add(downCounter, i);
            downSerII.add(downCounter, i);
        } else if ((values[0] == 1)) {
            downSer.add(downCounter, i);
        }
        if ((values[3] == 1)) {
            novalueProvidedSer.add(novalueProvidedCounter, i);
        } else if ((values[3] > 1)) {
            novalueProvidedSer.add(stableCounter, i);
            novalueProvidedSerII.add(stableCounter, i);
        }

    }

    dataset.addSeries(downSer);
    dataset.addSeries(stableSer);
    dataset.addSeries(upSer);
    dataset.addSeries(novalueProvidedSer);
    dataset.addSeries(downSerII);
    dataset.addSeries(stableSerII);
    dataset.addSeries(upSerII);
    dataset.addSeries(novalueProvidedSerII);
    //        if((downSerII.getItemCount()+stableSerII.getItemCount()+upSerII.getItemCount()+downSer.getItemCount()+stableSer.getItemCount()+upSer.getItemCount())==0)
    //            return;
    //        dataset.addSeries(plusSeries);
    final String[] labels = new String[] { " ", ("Decreased (" + cp.getSignificantDown() + ")"), " ",
            ("Equal (" + cp.getStable() + ")"), " ", ("Increased (" + cp.getSignificantUp() + ")"), "" };
    final Color[] labelsColor = new Color[] { Color.LIGHT_GRAY, new Color(80, 183, 71), Color.LIGHT_GRAY,
            new Color(1, 141, 244), Color.LIGHT_GRAY, Color.RED, Color.LIGHT_GRAY };
    final SymbolAxis domainAxis = new SymbolAxis("X", labels) {

        @Override
        protected void drawGridBandsVertical(Graphics2D g2, Rectangle2D drawArea, Rectangle2D plotArea,
                boolean firstGridBandIsDark, List ticks) {
            List udatedTicksList = new ArrayList();

            for (Object tick : ticks) {
                if (tick.toString().equalsIgnoreCase(labels[custTrend + 1])) {
                    udatedTicksList.add(tick);
                }
            }
            //                System.out.println("at ticks is "+ticks);
            //                 System.out.println("at udatedTicksList is "+udatedTicksList);
            //                int factor = (int) ((plotArea.getHeight() / 5) * 0.25);
            //
            //                Rectangle2D up = new Rectangle((int) drawArea.getX(), (int) drawArea.getY() - factor, (int) drawArea.getWidth(), (int) drawArea.getHeight());
            //                Rectangle2D pa = new Rectangle((int) plotArea.getX(), (int) plotArea.getY() - factor, (int) plotArea.getWidth(), (int) plotArea.getHeight());

            super.drawGridBandsVertical(g2, drawArea, plotArea, firstGridBandIsDark, udatedTicksList); //To change body of generated methods, choose Tools | Templates.
        }

        int x = 0;

        @Override
        public Paint getTickLabelPaint() {
            if (x >= labels.length) {
                x = 0;
            }
            return labelsColor[x++];
        }

    };
    domainAxis.setAutoRangeIncludesZero(false);
    Font f = new Font("Verdana", Font.PLAIN, 11);
    domainAxis.setTickLabelFont(f);
    domainAxis.setAutoRange(false);
    domainAxis.setLabel(null);

    //        domainAxis.setGridBandsVisible(false);
    String xTile = "#Patients";

    JFreeChart jFreeChart = ChartFactory.createScatterPlot(null, null, // domain axis label
            null, // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            false, // include legend
            false, // tooltips?
            false // URLs?
    );
    XYPlot plot1 = (XYPlot) jFreeChart.getPlot();
    XYPlot xyplot = new XYPlot(dataset, plot1.getDomainAxis(), plot1.getRangeAxis(), plot1.getRenderer()) {

        @Override
        public void drawDomainTickBands(Graphics2D g2, Rectangle2D dataArea, List ticks) {

            if (custTrend == -1) {
                super.drawDomainTickBands(g2, dataArea, ticks);
                return;

            }
            List udatedTicksList = new ArrayList();
            for (Object tick : ticks) {
                if (tick.toString().equalsIgnoreCase(labels[custTrend + 1])) {
                    udatedTicksList.add(tick);
                }
            }
            Rectangle2D up;
            int factor = (int) ((dataArea.getHeight() / 5) * 0.5);
            if (custTrend == 4) {
                up = new Rectangle((int) dataArea.getX(), (int) dataArea.getY() + factor,
                        (int) dataArea.getWidth(), (int) dataArea.getHeight());

            } else if (custTrend == 2) {
                up = new Rectangle((int) dataArea.getX(), (int) dataArea.getY() - factor,
                        (int) dataArea.getWidth(), (int) dataArea.getHeight());

            } else {
                up = new Rectangle((int) dataArea.getX(), (int) dataArea.getY() - factor,
                        (int) dataArea.getWidth(), (int) dataArea.getHeight());
            }

            super.drawDomainTickBands(g2, up, udatedTicksList); //To change body of generated methods, choose Tools | Templates.
        }

        @Override
        protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea, List ticks) {
            super.drawDomainGridlines(g2, dataArea, ticks); //To change body of generated methods, choose Tools | Templates.
        }

        private int x = 0;

        @Override
        public Paint getDomainGridlinePaint() {
            if (x >= labels.length) {
                x = 0;
            }
            if (x == 1 || x == 3 || x == 5) {
                x++;
                return Color.WHITE;
            } else {
                x++;
                return super.getDomainGridlinePaint(); //To change body of generated methods, choose Tools | Templates.
            }
        }
    };
    if (custTrend != -1) {
        domainAxis.setGridBandsVisible(true);
        if (custTrend == 4) {
            domainAxis.setGridBandPaint(Color.decode("#ffe5e5"));
            xyplot.setDomainTickBandPaint(Color.decode("#ffe5e5"));
            domainAxis.setGridBandAlternatePaint(Color.decode("#ffe5e5"));
        } else if (custTrend == 0) {
            domainAxis.setGridBandPaint(Color.decode("#e5ffe5"));
            xyplot.setDomainTickBandPaint(Color.white);
        } else if (custTrend == 2) {
            domainAxis.setGridBandPaint(Color.decode("#e6f4ff"));
            xyplot.setDomainTickBandPaint(Color.white);
        }

    } else {
        domainAxis.setGridBandsVisible(false);
    }
    xyplot.setOrientation(PlotOrientation.HORIZONTAL);
    JFreeChart tempScatterPlot = new JFreeChart(xyplot);
    tempScatterPlot.setBackgroundPaint(Color.WHITE);
    tempScatterPlot.getLegend().setVisible(false);
    Color c = new Color(242, 242, 242);
    xyplot.setDomainAxis(domainAxis);
    xyplot.setDomainGridlinePaint(Color.GRAY);
    xyplot.setDomainGridlinesVisible(true);
    xyplot.setRangeGridlinesVisible(true);
    xyplot.setRangeGridlinePaint(Color.GRAY);
    xyplot.setOutlinePaint(Color.GRAY);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyplot.getRenderer();
    ValueAxis va = xyplot.getDomainAxis();
    va.setAutoRange(false);
    va.setMinorTickCount(0);
    va.setVisible(true);
    maxPatNumber = Math.ceil(maxPatNumber / 100.0) * 100;
    xyplot.getRangeAxis().setRange(0, maxPatNumber);
    NumberAxis rangeAxis = (NumberAxis) xyplot.getRangeAxis();
    rangeAxis.setTickUnit(new NumberTickUnit(10));
    rangeAxis.setLabel(xTile);
    rangeAxis.setLabelFont(f);
    rangeAxis.setLabelPaint(Color.GRAY);

    va.setRange(0, 6);
    xyplot.setBackgroundPaint(Color.WHITE);
    renderer.setUseOutlinePaint(true);

    Color c0 = new Color(80, 183, 71);
    renderer.setSeriesPaint(0, c0);
    renderer.setSeriesOutlinePaint(0, Color.WHITE);

    Color c1 = new Color(1, 141, 244);
    renderer.setSeriesPaint(1, c1);
    renderer.setSeriesOutlinePaint(1, Color.WHITE);

    Color c2 = new Color(204, 0, 0);
    renderer.setSeriesPaint(2, c2);
    renderer.setSeriesOutlinePaint(2, Color.WHITE);

    renderer.setSeriesPaint(3, Color.decode("#b5babb"));
    renderer.setSeriesOutlinePaint(3, Color.WHITE);

    renderer.setSeriesPaint(4, new Color(150, 212, 145));
    renderer.setSeriesOutlinePaint(4, new Color(150, 212, 145));

    renderer.setSeriesPaint(5, new Color(103, 187, 248));
    renderer.setSeriesOutlinePaint(5, new Color(103, 187, 248));

    renderer.setSeriesPaint(6, new Color(224, 102, 102));
    renderer.setSeriesOutlinePaint(6, new Color(224, 102, 102));

    renderer.setSeriesPaint(7, Color.decode("#b5babb"));
    renderer.setSeriesOutlinePaint(7, Color.GRAY);

    //        renderer.setSeriesPaint(6, Color.BLACK);
    //        renderer.setSeriesOutlinePaint(6, Color.BLACK);
    Shape downArr = ShapeUtilities.createDownTriangle(7f);
    Shape notRShape = ShapeUtilities.createDiamond(7f);
    Shape upArr = ShapeUtilities.createUpTriangle(7);

    Shape downArrII = ShapeUtilities.createTranslatedShape(ShapeUtilities.createDownTriangle(6f), 5, -5);
    Shape notRShapeII = ShapeUtilities.createTranslatedShape(ShapeUtilities.createDiamond(6f), 0, -7);
    Shape upArrII = ShapeUtilities.createTranslatedShape(ShapeUtilities.createUpTriangle(6f), 4, -4);

    //        Shape plus = ShapeUtilities.createTranslatedShape(ShapeUtilities.createRegularCross(3f, 0.4f), 11, -7);
    renderer.setSeriesShape(0, downArr);
    renderer.setSeriesShape(1, notRShape);
    renderer.setSeriesShape(2, upArr);

    renderer.setSeriesShape(3, notRShape);

    renderer.setSeriesShape(4, downArrII);
    renderer.setSeriesShape(5, notRShapeII);
    renderer.setSeriesShape(6, upArrII);

    renderer.setSeriesShape(7, notRShapeII);
    //       renderer.setSeriesShape(6, plus);

    renderer.setBaseItemLabelsVisible(true);
    renderer.setBaseItemLabelGenerator(new SymbolicXYItemLabelGenerator() {
        private final int[] indexer = new int[] { 0, 1, 2, 3, 0, 1, 2, 3 };

        @Override
        public String generateLabel(XYDataset dataset, int series, int category) {
            if (series > 3) {
                int patNumber = (int) dataset.getYValue(series, category);
                //                    int trend = (int) dataset.getXValue(series, category);
                if (series == 7 || series == 5) {
                    return "\t  " + paTGrNumbtrendMap.get(patNumber)[indexer[series]];
                } else {
                    return "\t   " + paTGrNumbtrendMap.get(patNumber)[indexer[series]];
                }

            }

            return ""; //To change body of generated methods, choose Tools | Templates.
        }

    });
    ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT,
            TextAnchor.TOP_LEFT, 0.0);

    renderer.setSeriesPositiveItemLabelPosition(4, position);
    renderer.setSeriesPositiveItemLabelPosition(5, position);
    renderer.setSeriesPositiveItemLabelPosition(6, position);
    renderer.setSeriesPositiveItemLabelPosition(7, position);

    renderer.setBaseItemLabelFont(f);

    tempScatterPlot.setBorderVisible(false);

    xyplot.setSeriesRenderingOrder(SeriesRenderingOrder.REVERSE);

    heighlightedScatterPlottImgUrl = saveToFile(tempScatterPlot, w, h, defaultScatterPlotRenderingInfo);

    xyplot.setBackgroundPaint(Color.WHITE);
    defaultScatterPlottImgUrl = saveToFile(tempScatterPlot, w, h, defaultScatterPlotRenderingInfo);

    //        xyplot.setBackgroundPaint(c);

    if (custTrend != -1) {
        domainAxis.setGridBandsVisible(true);
        if (custTrend == 4) {
            domainAxis.setGridBandPaint(Color.decode("#ffe5e5"));
            xyplot.setDomainTickBandPaint(Color.decode("#ffe5e5"));
            domainAxis.setGridBandAlternatePaint(Color.decode("#ffe5e5"));
        } else if (custTrend == 0) {
            domainAxis.setGridBandPaint(Color.decode("#e5ffe5"));
            xyplot.setDomainTickBandPaint(c);
        } else if (custTrend == 2) {
            domainAxis.setGridBandPaint(Color.decode("#e6f4ff"));
            xyplot.setDomainTickBandPaint(c);
        }

    }

    String textTitle = comparisonTitle.getValue().split("bold;'>")[1].replace("</font>", "");
    TextTitle title = new TextTitle(textTitle, f);

    scatterPlot = new JFreeChart(xyplot);
    scatterPlot.setTitle(title);

    scatterPlot.setBorderVisible(false);
    scatterPlot.setBackgroundPaint(Color.WHITE);
    scatterPlot.getLegend().setVisible(false);
    dsKeyDatasetMap.clear();
    for (int i = 0; i < defaultScatterPlotRenderingInfo.getEntityCollection().getEntityCount(); i++) {
        final ChartEntity entity = defaultScatterPlotRenderingInfo.getEntityCollection().getEntity(i);
        if (entity instanceof XYItemEntity) {

            int x = ((XYItemEntity) entity).getSeriesIndex();
            int y = ((XYItemEntity) entity).getItem();

            if (((XYItemEntity) entity).getDataset().getYValue(x,
                    y) > (int) ((XYItemEntity) entity).getDataset().getYValue(x, y)) {
                continue;
            }
            if (((XYItemEntity) entity).getSeriesIndex() > 3) {

                continue;
            }

            String[] arr = ((XYItemEntity) entity).getShapeCoords().split(",");
            int xSer = Integer.valueOf(arr[0]);
            int ySer = Integer.valueOf(arr[1]);
            int ySerEnd = Integer.valueOf(arr[3]);
            int patGrNumber = (int) ((XYItemEntity) entity).getDataset().getYValue(x, y);
            int trend = Integer.valueOf(((XYItemEntity) entity).getDataset()
                    .getSeriesKey(((XYItemEntity) entity).getSeriesIndex()).toString());

            ComparisonDetailsBean cpDetails = patientGroupsNumToDsIdMap.get(patGrNumber);
            List<Integer> dsList = cpDetails.getRegulatedList(trend);
            StringBuilder sb = new StringBuilder();

            for (int dsId : dsList) {
                QuantDatasetObject ds;

                sb.append("<h4>").append((Quant_Central_Manager.getFullQuantDatasetMap().get(dsId)).getAuthor())
                        .append(" ")
                        .append((Quant_Central_Manager.getFullQuantDatasetMap().get(dsId)).getYear())
                        .append("<h4/>");
                sb.append("<p></p>");
                ds = Quant_Central_Manager.getFullQuantDatasetMap().get(dsId);

                dsKeyDatasetMap.put("_-_" + dsId + "_-_" + comparisonProtein.getProteinAccssionNumber() + "_-_",
                        ds);
            }
            String tooltip = sb.toString().substring(0, sb.toString().length() - 7);
            SquaredDot square = new SquaredDot("squared");
            if (paTGrNumbtrendMap.get(patGrNumber)[trend] > 1) {
                square.setWidth(20 + "px");
                square.setHeight(15 + "px");
            } else {
                square.setWidth(10 + "px");
                square.setHeight(10 + "px");
            }
            square.setDescription(tooltip);
            square.setParam("trend", trend);
            square.setParam("pGrNumber", patGrNumber);
            int top = (ySer - 4);
            if (ySer > ySerEnd) {
                top = ySerEnd - 3;
            }
            defaultChartLayout.addComponent(square, "left: " + (xSer - 5) + "px; top: " + top + "px;");
        }
    }

}

From source file:org.talend.dataprofiler.chart.util.TopChartFactory.java

/**
 * Creates a bubble chart with default settings. The chart is composed of an {@link XYPlot}, with a {@link NumberAxis} for the
 * domain axis, a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer} to draw the data items.
 * //from   ww w.  j av  a  2s .c o m
 * This method is copied from
 * {@link org.jfree.chart.ChartFactory#createBubbleChart(String, String, String, XYZDataset, PlotOrientation, boolean, boolean, boolean)}
 * 
 * @param title the chart title (<code>null</code> permitted).
 * @param xAxisLabel a label for the X-axis (<code>null</code> permitted).
 * @param yAxisLabel a label for the Y-axis (<code>null</code> permitted).
 * @param dataset the dataset for the chart (<code>null</code> permitted).
 * @param orientation the orientation (horizontal or vertical) (<code>null</code> NOT permitted).
 * @param legend a flag specifying whether or not a legend is required.
 * @param tooltips configure chart to generate tool tips?
 * @param urls configure chart to generate URLs?
 * 
 * @return A bubble chart.
 */
public static JFreeChart createBubbleChart(String title, String xAxisLabel, String yAxisLabel,
        XYZDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException(Messages.getString("TopChartFactory.argument")); //$NON-NLS-1$
    }
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);

    XYItemRenderer renderer = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS) {

        @Override
        public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea,
                PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis,
                XYDataset dataset, int series, int item, CrosshairState crosshairState, int pass) {

            // return straight away if the item is not visible
            if (!getItemVisible(series, item)) {
                return;
            }

            PlotOrientation orientation = plot.getOrientation();

            // get the data point...
            double x = dataset.getXValue(series, item);
            double y = dataset.getYValue(series, item);
            double z = Double.NaN;
            if (dataset instanceof XYZDataset) {
                XYZDataset xyzData = (XYZDataset) dataset;
                z = xyzData.getZValue(series, item);
            }
            if (!Double.isNaN(z)) {
                RectangleEdge domainAxisLocation = plot.getDomainAxisEdge();
                RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge();
                double transX = domainAxis.valueToJava2D(x, dataArea, domainAxisLocation);
                double transY = rangeAxis.valueToJava2D(y, dataArea, rangeAxisLocation);

                double transDomain = 0.0;
                double transRange = 0.0;
                double zero;

                // MOD scorreia +2L avoid points: minimal size of circle must be 1
                // z = z * transX + 1;

                // ADD xqliu 2009-07-06 bug 8035
                double zSize = getBubbleSize(z); // calculate the multiple of bubble's default size
                z = 0; // use bubble's default size
                // ~

                switch (getScaleType()) {
                case SCALE_ON_DOMAIN_AXIS:
                    zero = domainAxis.valueToJava2D(0.0, dataArea, domainAxisLocation);
                    transDomain = domainAxis.valueToJava2D(z, dataArea, domainAxisLocation) - zero;
                    transRange = transDomain;
                    break;
                case SCALE_ON_RANGE_AXIS:
                    zero = rangeAxis.valueToJava2D(0.0, dataArea, rangeAxisLocation);
                    transRange = zero - rangeAxis.valueToJava2D(z, dataArea, rangeAxisLocation);
                    transDomain = transRange;
                    break;
                default:
                    double zero1 = domainAxis.valueToJava2D(0.0, dataArea, domainAxisLocation);
                    double zero2 = rangeAxis.valueToJava2D(0.0, dataArea, rangeAxisLocation);
                    transDomain = domainAxis.valueToJava2D(z, dataArea, domainAxisLocation) - zero1;
                    transRange = zero2 - rangeAxis.valueToJava2D(z, dataArea, rangeAxisLocation);
                }
                transDomain = Math.abs(transDomain);
                transRange = Math.abs(transRange);

                // MODSCA 2008-11-27 enlarge ellipse by diag% of the total diagonal
                double diag = Math.sqrt(dataArea.getHeight() * dataArea.getHeight()
                        + dataArea.getWidth() * dataArea.getWidth());
                transDomain += diag / 100;
                transRange += diag / 100;

                Ellipse2D circle = null;

                // ADD xqliu 2009-07-06 bug 8035
                transDomain *= zSize;
                transRange *= zSize;
                // ~

                if (orientation == PlotOrientation.VERTICAL) {
                    circle = new Ellipse2D.Double(transX - transDomain / 2.0, transY - transRange / 2.0,
                            transDomain, transRange);
                } else if (orientation == PlotOrientation.HORIZONTAL) {
                    circle = new Ellipse2D.Double(transY - transRange / 2.0, transX - transDomain / 2.0,
                            transRange, transDomain);
                }
                g2.setPaint(getItemPaint(series, item));
                g2.fill(circle);
                g2.setStroke(getItemOutlineStroke(series, item));
                g2.setPaint(getItemOutlinePaint(series, item));
                g2.draw(circle);

                if (isItemLabelVisible(series, item)) {
                    if (orientation == PlotOrientation.VERTICAL) {
                        drawItemLabel(g2, orientation, dataset, series, item, transX, transY, false);
                    } else if (orientation == PlotOrientation.HORIZONTAL) {
                        drawItemLabel(g2, orientation, dataset, series, item, transY, transX, false);
                    }
                }

                // add an entity if this info is being collected
                EntityCollection entities = null;
                if (info != null) {
                    entities = info.getOwner().getEntityCollection();
                    if (entities != null && circle.intersects(dataArea)) {
                        addEntity(entities, circle, dataset, series, item, circle.getCenterX(),
                                circle.getCenterY());
                    }
                }

                int domainAxisIndex = plot.getDomainAxisIndex(domainAxis);
                int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis);
                updateCrosshairValues(crosshairState, x, y, domainAxisIndex, rangeAxisIndex, transX, transY,
                        orientation);
            }

        }

        /**
         * DOC xqliu : calculate the size of bubble. for bug 8035 2009-07-06.
         * 
         * @param z multiple of bubble's default size
         * @return
         */
        private double getBubbleSize(double z) {
            if (z > 0 && z <= 10) {
                return 2;
            } else if (z > 10 && z <= 100) {
                return 3;
            } else if (z > 100) {
                return 4;
            }
            return 1;
        }

    };
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYZURLGenerator());
    }
    plot.setRenderer(renderer);
    plot.setOrientation(orientation);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

    return chart;

}

From source file:com.naryx.tagfusion.cfm.tag.awt.cfCHART.java

private XYPlot getXYPlot(List<cfCHARTSERIESData> series, String xAxisTitle, String yAxisTitle,
        String labelFormat, boolean bShowMarkers, int markerSize, boolean bShow3D, String tipStyle,
        String drillDownUrl, int xOffset, int yOffset, int yAxisUnits, String seriesPlacement, int height,
        int gridLines) throws cfmRunTimeException {
    // Create an XY plot
    XYPlot plot = new XYPlot();
    ValueAxis domainAxis;//from  www .  java 2s.com

    if (series.get(0).getSeriesDataType() == cfCHARTSERIESData.XY_NUMERIC_SERIES) {
        if (bShow3D)
            domainAxis = new NumberAxis3D(xAxisTitle);
        else
            domainAxis = new NumberAxis(xAxisTitle);
    } else {
        domainAxis = new DateAxis(xAxisTitle);
    }
    plot.setDomainAxis(domainAxis);

    ValueAxis valueAxis;
    DateFormat dateFormat = null;
    NumberFormat numberFormat = null;
    if (labelFormat.equals("date")) {
        valueAxis = new DateAxis(yAxisTitle);
        dateFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
        ((DateAxis) valueAxis).setDateFormatOverride(dateFormat);
    } else {
        if (bShow3D)
            valueAxis = new NumberAxis3D(yAxisTitle);
        else
            valueAxis = new NumberAxis(yAxisTitle);
        if (labelFormat.equals("currency")) {
            ((NumberAxis) valueAxis).setNumberFormatOverride(NumberFormat.getCurrencyInstance());
            numberFormat = NumberFormat.getCurrencyInstance();
        } else if (labelFormat.equals("percent")) {
            numberFormat = NumberFormat.getPercentInstance();
            numberFormat.setMaximumFractionDigits(3); // without this change .11443
                                                      // would be displayed as 11%
                                                      // instead of 11.443%
            ((NumberAxis) valueAxis).setNumberFormatOverride(numberFormat);
        } else {
            numberFormat = NumberFormat.getInstance();
        }

        if (yAxisUnits != 0)
            ((NumberAxis) valueAxis).setTickUnit(new NumberTickUnit(yAxisUnits));
    }
    plot.setRangeAxis(valueAxis);

    // Add a dataset and renderer for each series
    int barChartDatasetIndex = -1;
    int hBarChartDatasetIndex = -1;
    int num = 0;
    MinMaxData minMax = new MinMaxData();
    for (int i = 0; i < series.size(); i++) {
        cfCHARTSERIESData seriesData = series.get(i);
        XYSeriesCollection dataset;
        if ((barChartDatasetIndex != -1) && (seriesData.getType().equals("bar"))) {
            dataset = (XYSeriesCollection) plot.getDataset(barChartDatasetIndex);

            addSeriesDataToDataset(seriesData, dataset, minMax);

            // Set the paint style for this series
            setPaintStyle(seriesData.getPaintStyle(), plot.getRenderer(barChartDatasetIndex),
                    dataset.getSeriesCount() - 1, height);

            // Add the color list for this series to the custom color renderer
            CustomColorRenderer cr = (CustomColorRenderer) plot.getRenderer(barChartDatasetIndex);
            cr.addColors(getColorList(seriesData));

            continue;
        } else if ((hBarChartDatasetIndex != -1) && (seriesData.getType().equals("horizontalbar"))) {
            dataset = (XYSeriesCollection) plot.getDataset(hBarChartDatasetIndex);

            addSeriesDataToDataset(seriesData, dataset, minMax);

            // Set the paint style for this series
            setPaintStyle(seriesData.getPaintStyle(), plot.getRenderer(hBarChartDatasetIndex),
                    dataset.getSeriesCount() - 1, height);

            // Add the color list for this series to the custom color renderer
            CustomColorRenderer cr = (CustomColorRenderer) plot.getRenderer(hBarChartDatasetIndex);
            cr.addColors(getColorList(seriesData));

            continue;
        } else {
            dataset = new XYSeriesCollection();

            addSeriesDataToDataset(seriesData, dataset, minMax);
        }

        plot.setDataset(num, dataset);

        XYItemRenderer renderer = null;
        if (seriesData.getType().equals("bar")) {
            plot.setOrientation(PlotOrientation.VERTICAL);
            renderer = getXYBarRenderer(seriesPlacement, bShow3D, xOffset, yOffset, getColorList(seriesData));
            ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                    TextAnchor.BOTTOM_CENTER);
            renderer.setPositiveItemLabelPosition(position1);
            ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6,
                    TextAnchor.TOP_CENTER);
            renderer.setNegativeItemLabelPosition(position2);
            ((XYBarRenderer) renderer).setMargin(0.2); // The margin between each
                                                       // category

            barChartDatasetIndex = num;
        } else if (seriesData.getType().equals("horizontalbar")) {
            plot.setOrientation(PlotOrientation.HORIZONTAL);
            plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
            renderer = getXYBarRenderer(seriesPlacement, bShow3D, xOffset, yOffset, getColorList(seriesData));
            ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3,
                    TextAnchor.CENTER_LEFT);
            renderer.setPositiveItemLabelPosition(position1);
            ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE9,
                    TextAnchor.CENTER_RIGHT);
            renderer.setNegativeItemLabelPosition(position2);
            ((XYBarRenderer) renderer).setMargin(0.2); // The margin between each
                                                       // category

            hBarChartDatasetIndex = num;
        } else if (seriesData.getType().equals("line")) {
            renderer = new XYLineAndShapeRenderer(true, false);

            // Enable/Disable displaying of markers
            ((XYLineAndShapeRenderer) renderer).setShapesVisible(bShowMarkers);

            // Set the shape of the markers based on the markerSize value
            ((XYLineAndShapeRenderer) renderer).setShape(getMarker(seriesData.getMarkerStyle(), markerSize));
        } else if (seriesData.getType().equals("area")) {
            renderer = new CustomXYAreaRenderer();
        } else if (seriesData.getType().equals("step")) {
            renderer = new CustomXYStepRenderer();
        } else if (seriesData.getType().equals("scatter")) {
            renderer = new XYLineAndShapeRenderer(false, true);

            // Set the shape of the markers based on the markerSize value
            ((XYLineAndShapeRenderer) renderer).setShape(getMarker(seriesData.getMarkerStyle(), markerSize));
        }

        if (!tipStyle.equals("none")) {
            if (series.get(0).getSeriesDataType() == cfCHARTSERIESData.XY_DATE_SERIES) {
                renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: {1}",
                        DateFormat.getInstance(), DateFormat.getInstance()));
            } else {
                if (dateFormat != null)
                    renderer.setBaseToolTipGenerator(
                            new StandardXYToolTipGenerator("{0}: {2}", dateFormat, dateFormat));
                else
                    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})",
                            numberFormat, NumberFormat.getInstance()));
            }
        }

        if (drillDownUrl != null) {
            if (dateFormat != null)
                renderer.setURLGenerator(
                        new com.newatlanta.bluedragon.XYURLGenerator(drillDownUrl, dateFormat));
            else
                renderer.setURLGenerator(
                        new com.newatlanta.bluedragon.XYURLGenerator(drillDownUrl, numberFormat));
        }

        if (seriesData.getSeriesColor() != null)
            renderer.setSeriesPaint(0, convertStringToColor(seriesData.getSeriesColor()));

        String dataLabelStyle = seriesData.getDataLabelStyle();
        if (labelFormat.equals("date")) {
            if (dataLabelStyle.equals("none")) {
                renderer.setItemLabelsVisible(false);
            } else {
                setXYItemLabelsData(renderer, seriesData);
                if (dataLabelStyle.equals("value"))
                    renderer.setItemLabelGenerator(
                            new StandardXYItemLabelGenerator("{2}", dateFormat, dateFormat));
                else if (dataLabelStyle.equals("rowlabel"))
                    renderer.setItemLabelGenerator(new StandardXYItemLabelGenerator("{0}",
                            NumberFormat.getInstance(), NumberFormat.getInstance()));
                else if (dataLabelStyle.equals("columnlabel"))
                    renderer.setItemLabelGenerator(new StandardXYItemLabelGenerator("{1}",
                            NumberFormat.getInstance(), NumberFormat.getInstance()));
                else if (dataLabelStyle.equals("pattern"))
                    renderer.setItemLabelGenerator(new XYItemLabelGenerator("{2}", dateFormat, dateFormat));
                else
                    renderer.setItemLabelGenerator(
                            new XYItemLabelGenerator(dataLabelStyle, dateFormat, dateFormat));
            }
        } else {
            if (dataLabelStyle.equals("none")) {
                renderer.setItemLabelsVisible(false);
            } else {
                setXYItemLabelsData(renderer, seriesData);
                if (dataLabelStyle.equals("value")) {

                    renderer.setItemLabelGenerator(
                            new StandardXYItemLabelGenerator("{2}", numberFormat, numberFormat));

                } else if (dataLabelStyle.equals("rowlabel")) {

                    renderer.setItemLabelGenerator(
                            new StandardXYItemLabelGenerator("{0}", numberFormat, numberFormat));

                } else if (dataLabelStyle.equals("columnlabel")) {

                    if (series.get(0).getSeriesDataType() == cfCHARTSERIESData.XY_DATE_SERIES) {
                        renderer.setItemLabelGenerator(new StandardXYItemLabelGenerator("{1}",
                                SimpleDateFormat.getInstance(), NumberFormat.getInstance()));
                    } else {
                        renderer.setItemLabelGenerator(new StandardXYItemLabelGenerator("{1}",
                                NumberFormat.getInstance(), NumberFormat.getInstance()));
                    }

                } else if (dataLabelStyle.equals("pattern")) {

                    if (series.get(0).getSeriesDataType() == cfCHARTSERIESData.XY_DATE_SERIES) {
                        renderer.setItemLabelGenerator(new XYItemLabelGenerator("{1} {2} ({3} of {4})",
                                SimpleDateFormat.getInstance(), numberFormat));
                    } else {
                        renderer.setItemLabelGenerator(new XYItemLabelGenerator("{1} {2} ({3} of {4})",
                                NumberFormat.getInstance(), numberFormat));
                    }

                } else {
                    renderer.setItemLabelGenerator(
                            new XYItemLabelGenerator(dataLabelStyle, NumberFormat.getInstance(), numberFormat));
                }
            }
        }

        // Add the renderer to the plot.
        // NOTE: this must be done before the setPaintStyle() call so the
        // DrawingSupplier object
        // will be set up properly for the generation of default colors.
        plot.setRenderer(num, renderer);

        // Set the paint style for this series (series 0)
        if (seriesData.getType().equals("bar") || seriesData.getType().equals("horizontalbar")
                || seriesData.getType().equals("area"))
            setPaintStyle(seriesData.getPaintStyle(), renderer, 0, height);

        num++;
    }

    // If gridLines was specified then we need to calculate the yAxisUnits
    if ((gridLines != -1) && (valueAxis instanceof NumberAxis)) {
        // Calculate the yAxisUnits we need to use to create the number of
        // gridLines
        yAxisUnits = calculateYAxisUnits(gridLines, minMax);

        // Set the yAxisUnits
        ((NumberAxis) valueAxis).setTickUnit(new NumberTickUnit(yAxisUnits));
    }

    return plot;
}

From source file:wsattacker.plugin.dos.dosExtension.chart.ChartObject.java

public JFreeChart createOverlaidChart() {

    // ----------------------------
    // Data and X-Y-Axis - Response Time Testprobes
    // - Y-Achse 0
    final DateAxis yAxis = new DateAxis("Time");
    yAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    // - X-Achse 0
    final NumberAxis xAxis0 = new NumberAxis("Response Time in ms");
    xAxis0.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    // xAxis0.setTickUnit( new NumberTickUnit(1) );
    // - dataset// w w  w. ja v a 2 s  .  c  om
    // - renderer
    final XYDataset dataResponseTimeProbes = createDatasetResponseTime("testprobe");
    final XYLineAndShapeRenderer rendererResponseTimeProbes = new XYLineAndShapeRenderer(); // StandardXYItemRenderer();
                                                                                            // ->
                                                                                            // should
                                                                                            // not
                                                                                            // be
                                                                                            // used
    rendererResponseTimeProbes.setSeriesPaint(0, Color.blue);
    rendererResponseTimeProbes.setSeriesShape(0, new Ellipse2D.Double(-1.5, -1.5, 3.0, 3.0));
    rendererResponseTimeProbes.setSeriesLinesVisible(0, true);
    rendererResponseTimeProbes.setSeriesShapesVisible(0, true);
    rendererResponseTimeProbes.setUseOutlinePaint(false);
    rendererResponseTimeProbes.setSeriesOutlinePaint(0, Color.black);
    rendererResponseTimeProbes.setUseFillPaint(true);
    rendererResponseTimeProbes.setSeriesFillPaint(0, Color.blue);

    // ----------------------------
    // NEW XYPlot (new "Data and X-Y-Axis" from above added as default)
    final XYPlot plot = new XYPlot(dataResponseTimeProbes, yAxis, xAxis0, rendererResponseTimeProbes);

    // ----------------------------
    // Data and Axis 1 - Response time UNtampered
    // - Dataset
    // - Renderer.
    // - Dataset zu X-Axis 0 mappen
    final XYDataset dataResponseTimeUntampered = createDatasetResponseTime("untampered");
    final XYLineAndShapeRenderer rendererResponseTimeUntampered = new XYLineAndShapeRenderer(); // StandardXYItemRenderer();
                                                                                                // ->
                                                                                                // should
                                                                                                // not
                                                                                                // be
                                                                                                // used
    rendererResponseTimeUntampered.setSeriesPaint(0, new Color(0, 161, 4));
    rendererResponseTimeUntampered.setSeriesShape(0, new Ellipse2D.Double(-4, -4, 8.0, 8.0));
    rendererResponseTimeUntampered.setUseFillPaint(true);
    rendererResponseTimeUntampered.setSeriesFillPaint(0, Color.white);
    rendererResponseTimeUntampered.setUseOutlinePaint(false);
    rendererResponseTimeUntampered.setSeriesOutlinePaint(0, Color.black);
    rendererResponseTimeUntampered.setSeriesToolTipGenerator(0,
            new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                    new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00")));
    plot.setDataset(2, dataResponseTimeUntampered);
    plot.setRenderer(2, rendererResponseTimeUntampered);
    // plot.mapDatasetToRangeAxis(0, 1);

    // ----------------------------
    // Data and Axis - Response time tampered
    // - Dataset
    // - Renderer
    // - Dataset zu X-Axis 2 mappen
    final XYDataset dataResponseTimeTampered = createDatasetResponseTime("tampered");
    XYLineAndShapeRenderer rendererResponseTimeTampered = new XYLineAndShapeRenderer(); // XYSplineRenderer();
    rendererResponseTimeTampered.setSeriesPaint(0, new Color(189, 0, 0));
    rendererResponseTimeTampered.setSeriesShape(0, new Ellipse2D.Double(-4, -4, 8.0, 8.0));// (-2.5, -2.5, 6.0,
                                                                                           // 6.0) );
    rendererResponseTimeTampered.setUseFillPaint(true);
    rendererResponseTimeTampered.setSeriesFillPaint(0, Color.white);
    rendererResponseTimeTampered.setUseOutlinePaint(false);
    rendererResponseTimeTampered.setSeriesOutlinePaint(0, Color.black);
    plot.setDataset(3, dataResponseTimeTampered);
    plot.setRenderer(3, rendererResponseTimeTampered);
    // plot.mapDatasetToRangeAxis(0, 2);

    // ----------------------------
    // Data and X-Axis - Number Requests UNtampered
    // - X-Axis Number Requests
    final NumberAxis xAxis1 = new NumberAxis(
            "Number Requests Per Interval (" + (model.getIntervalLengthReport() / 1000) + " sec)");
    xAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // xAxis1.setTickUnit( new NumberTickUnit(2) );
    plot.setRangeAxis(1, xAxis1);
    // - Dataset
    // - Renderer
    final IntervalXYDataset dataNumberRequestsUntampered = createDatasetNumberRequestsUntampered();
    final XYBarRenderer rendererNumberRequestsUntampered = new XYBarRenderer(0.2);
    rendererNumberRequestsUntampered.setShadowVisible(false);
    rendererNumberRequestsUntampered.setBarPainter(new StandardXYBarPainter());
    rendererNumberRequestsUntampered.setSeriesPaint(0, new Color(128, 255, 128));
    plot.setDataset(4, dataNumberRequestsUntampered);
    plot.setRenderer(4, rendererNumberRequestsUntampered);
    plot.mapDatasetToRangeAxis(4, 1);

    // -------------------------------
    // Data - Number Requests tampered
    // - Dataset
    // - Renderer
    final IntervalXYDataset dataNumberRequestsTampered = createDatasetNumberRequestsTampered();
    final XYBarRenderer rendererBarNumberRequestsTampered = new XYBarRenderer(0.2);
    rendererBarNumberRequestsTampered.setShadowVisible(false);
    rendererBarNumberRequestsTampered.setBarPainter(new StandardXYBarPainter());
    rendererBarNumberRequestsTampered.setSeriesPaint(0, new Color(255, 148, 148));
    plot.setDataset(5, dataNumberRequestsTampered);
    plot.setRenderer(5, rendererBarNumberRequestsTampered);
    plot.mapDatasetToRangeAxis(5, 1);

    // -------------------------
    // Other formating stuff
    // - add annotations
    // final double x = new Day(9, SerialDate.MARCH,
    // 2002).getMiddleMillisecond();
    // final XYTextAnnotation annotation = new
    // XYTextAnnotation("Anmerkung zu Datenpunkt", x, 1000.0);
    // annotation.setFont(new Font("SansSerif", Font.PLAIN, 9));
    // plot.addAnnotation(annotation);

    // -------------------------
    // Create custom LegendTitles
    // Legend Row 1
    LegendTitle legendL1 = new LegendTitle(plot.getRenderer(0));
    legendL1.setMargin(new RectangleInsets(2D, 2D, 2D, 2D));
    legendL1.setBorder(0, 0, 0, 0);
    LegendTitle legendR1 = new LegendTitle(plot.getRenderer(4));
    legendR1.setMargin(new RectangleInsets(2D, 2D, 2D, 2D));
    legendR1.setBorder(0, 0, 0, 0);
    BlockContainer blockcontainer = new BlockContainer(new BorderArrangement());
    blockcontainer.setBorder(0, 0, 0, 0);
    blockcontainer.add(legendL1, RectangleEdge.LEFT);
    blockcontainer.add(legendR1, RectangleEdge.RIGHT);
    blockcontainer.add(new EmptyBlock(2000D, 0.0D));
    CompositeTitle compositetitle1 = new CompositeTitle(blockcontainer);
    compositetitle1.setPosition(RectangleEdge.BOTTOM);
    // Legend Row 2
    LegendTitle legendL2 = new LegendTitle(plot.getRenderer(2));
    legendL2.setMargin(new RectangleInsets(2D, 2D, 2D, 2D));
    legendL2.setBorder(0, 0, 0, 0);
    LegendTitle legendR2 = new LegendTitle(plot.getRenderer(5));
    legendR2.setMargin(new RectangleInsets(2D, 2D, 2D, 2D));
    legendR2.setBorder(0, 0, 0, 0);
    BlockContainer blockcontainer2 = new BlockContainer(new BorderArrangement());
    blockcontainer2.setBorder(0, 0, 0, 0);
    blockcontainer2.add(legendL2, RectangleEdge.LEFT);
    blockcontainer2.add(legendR2, RectangleEdge.RIGHT);
    blockcontainer2.add(new EmptyBlock(2000D, 0.0D));
    CompositeTitle compositetitle2 = new CompositeTitle(blockcontainer2);
    compositetitle2.setPosition(RectangleEdge.BOTTOM);
    // Legend Row 3
    LegendTitle legendL3 = new LegendTitle(plot.getRenderer(3));
    legendL3.setMargin(new RectangleInsets(2D, 2D, 2D, 2D));
    legendL3.setBorder(0, 0, 0, 0);
    BlockContainer blockcontainer3 = new BlockContainer(new BorderArrangement());
    blockcontainer3.setBorder(0, 0, 0, 0);
    blockcontainer3.add(legendL3, RectangleEdge.LEFT);
    blockcontainer3.add(new EmptyBlock(2000D, 0.0D));
    CompositeTitle compositetitle3 = new CompositeTitle(blockcontainer3);
    compositetitle3.setPosition(RectangleEdge.BOTTOM);

    // -------------------------
    // create Chart
    // - return a new chart containing the overlaid plot...
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE);
    plot.setOrientation(PlotOrientation.VERTICAL);
    JFreeChart jFreeChart = new JFreeChart(model.getAttackName() + " - Response Time Plot", // Roundtrip Time Plot
            JFreeChart.DEFAULT_TITLE_FONT, plot, true);

    // Add new legend boxes + format
    jFreeChart.addSubtitle(compositetitle1);
    jFreeChart.addSubtitle(compositetitle2);
    jFreeChart.addSubtitle(compositetitle3);

    // Surpress old Legends
    LegendTitle legendee2 = jFreeChart.getLegend(0);
    legendee2.setVisible(false);

    return jFreeChart;
}