Package org.jfree.chart.plot

Examples of org.jfree.chart.plot.CategoryPlot


  protected void configureChart(final JFreeChart chart)
  {
    super.configureChart(chart);

    final CategoryPlot cpl = chart.getCategoryPlot();
    final CategoryItemRenderer renderer = cpl.getRenderer();
    renderer.setStroke(translateLineStyle(lineWidth, lineStyle));
    if (renderer instanceof LineAndShapeRenderer)
    {
      final LineAndShapeRenderer shapeRenderer = (LineAndShapeRenderer) renderer;
      shapeRenderer.setShapesVisible(isMarkersVisible());
View Full Code Here


      }
      chart.getCategoryPlot().setDomainAxis(new FormattedCategoryAxis(getCategoryAxisLabel(),
          getCategoricalAxisMessageFormat(), getRuntime().getResourceBundleFactory().getLocale()));
    }

    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    configureLogarithmicAxis(plot);

    return chart;
  }
View Full Code Here

    return chart;
  }

  protected void configureChart(final JFreeChart chart)
  {
    final CategoryPlot cpl = chart.getCategoryPlot();
    final CategoryItemRenderer renderer = cpl.getRenderer();
    final BarRenderer br = (BarRenderer) renderer;
    if (isAutoRange())
    {
      br.setIncludeBaseInRange(false);
    }
View Full Code Here

    {
        CategoryAxis xAxis = new CategoryAxis(xAxisTitle);
        ValueAxis yAxis = new NumberAxis(yAxisTitle);
        CategoryItemRenderer renderer = new StatisticalBarRenderer();

        CategoryPlot plot = new CategoryPlot((StatisticalCategoryDataset) dataset, xAxis, yAxis, renderer);

        JFreeChart chart = new JFreeChart(title, new Font("Arial", Font.PLAIN, 10), plot, true);
        return chart;
    }
View Full Code Here

                    false // urls
                    );

            chart.setBackgroundPaint(Color.white);

            final CategoryPlot plot = chart.getCategoryPlot();

            // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
            plot.setBackgroundPaint(Color.WHITE);
            plot.setOutlinePaint(null);
            plot.setForegroundAlpha(0.8f);
            // plot.setDomainGridlinesVisible(true);
            // plot.setDomainGridlinePaint(Color.white);
            plot.setRangeGridlinesVisible(true);
            plot.setRangeGridlinePaint(Color.black);

            CategoryAxis domainAxis = new ShiftedCategoryAxis(null);
            plot.setDomainAxis(domainAxis);
            domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
            domainAxis.setLowerMargin(0.0);
            domainAxis.setUpperMargin(0.0);
            domainAxis.setCategoryMargin(0.0);

            final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
            ChartUtil.adjustChebyshev(dataset, rangeAxis);
            rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            rangeAxis.setAutoRange(true);

            StackedAreaRenderer ar = new StackedAreaRenderer2() {
                @Override
                public Paint getItemPaint(int row, int column) {
                    ChartLabel key = (ChartLabel) dataset.getColumnKey(column);
                    if (key.getColor() != null) return key.getColor();
                    return super.getItemPaint(row, column);
                }

                @Override
                public String generateURL(CategoryDataset dataset, int row,
                        int column) {
                    ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
                    return label.getUrl();
                }

                @Override
                public String generateToolTip(CategoryDataset dataset, int row,
                        int column) {
                    ChartLabel label = (ChartLabel) dataset.getColumnKey(column);
                    return label.o.getOwner().getDisplayName() + " : "
                            + label.o.getDurationString();
                }
            };
            plot.setRenderer(ar);
            ar.setSeriesPaint(0,ColorPalette.RED); // Failures.
            ar.setSeriesPaint(1,ColorPalette.YELLOW); // Skips.
            ar.setSeriesPaint(2,ColorPalette.BLUE); // Total.

            // crop extra space around the graph
            plot.setInsets(new RectangleInsets(0, 0, 0, 5.0));

            return chart;
        }
View Full Code Here

    {
      final CategoryAxis catAxis = new CategoryAxis("Category");// NON-NLS
      final NumberAxis barsAxis = new NumberAxis("Value");// NON-NLS
      final NumberAxis linesAxis = new NumberAxis("Value2");// NON-NLS

      final CategoryPlot plot = new CategoryPlot(createDataset(), catAxis, barsAxis, new BarRenderer());
      plot.setRenderer(1, new LineAndShapeRenderer());

      // add lines dataset and axis to plot
      plot.setDataset(1, createDataset());
      plot.setRangeAxis(1, linesAxis);

      // map lines to second axis
      plot.mapDatasetToRangeAxis(1, 1);

      // set rendering order
      plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

      // set location of second axis
      plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);

      return new JFreeChart("Bar Line Chart", plot);
    }

    if (aExpression instanceof RingChartExpression)
    {
      return ChartFactory.createRingChart("Ring Chart", createPieDataset(), true, false, false);// NON-NLS
    }
    if (aExpression instanceof AreaChartExpression)
    {
      return ChartFactory.createAreaChart("Area Chart", "Category", "Value", createDataset(), PlotOrientation.VERTICAL,
          true, false, false);// NON-NLS
    }
    if (aExpression instanceof BarChartExpression)
    {
      return ChartFactory.createBarChart("Bar Chart", "Category", "Value", createDataset(), PlotOrientation.VERTICAL,
          true, false, false);// NON-NLS

    }
    if (aExpression instanceof LineChartExpression)
    {
      return ChartFactory.createLineChart("Line Chart", "Category", "Value", createDataset(), PlotOrientation.VERTICAL,
          true, false, false);// NON-NLS
    }
    if (aExpression instanceof MultiPieChartExpression)
    {
      return ChartFactory.createMultiplePieChart("Multi Pie Chart", createDataset(), TableOrder.BY_COLUMN, true, false,
          false);// NON-NLS
    }
    if (aExpression instanceof PieChartExpression)
    {
      return ChartFactory.createPieChart("Pie Chart", createPieDataset(), true, false, false);// NON-NLS
    }
    if (aExpression instanceof WaterfallChartExpressions)
    {
      return ChartFactory.createWaterfallChart("Bar Chart", "Category", "Value", createDataset(),
          PlotOrientation.HORIZONTAL, true, false, false);// NON-NLS
    }
    if (aExpression instanceof BubbleChartExpression)
    {
      return ChartFactory.createBubbleChart("Bubble Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL,
          true, false, false);// NON-NLS
    }
    if (aExpression instanceof ExtendedXYLineChartExpression)
    {
      return ChartFactory.createXYLineChart("XY Line Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL,
          true, false, false);// NON-NLS
    }
    if (aExpression instanceof ScatterPlotChartExpression)
    {
      return ChartFactory.createScatterPlot("Scatter Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL,
          true, false, false);// NON-NLS
    }
    if (aExpression instanceof XYAreaLineChartExpression)
    {
      final NumberAxis catAxis = new NumberAxis("Range");// NON-NLS
      final NumberAxis barsAxis = new NumberAxis("Value");// NON-NLS
      final NumberAxis linesAxis = new NumberAxis("Value2");// NON-NLS

      final XYPlot plot = new XYPlot(createXYZDataset(), catAxis, barsAxis, new XYAreaRenderer());
      plot.setRenderer(1, new XYLineAndShapeRenderer());

      // add lines dataset and axis to plot
      plot.setDataset(1, createXYZDataset());
      plot.setRangeAxis(1, linesAxis);

      // map lines to second axis
      plot.mapDatasetToRangeAxis(1, 1);

      // set rendering order
      plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

      // set location of second axis
      plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);

      return new JFreeChart("XY Area Line Chart", plot);// NON-NLS
    }
    if (aExpression instanceof XYAreaChartExpression)
    {
View Full Code Here

    {
      final RenderableReplacedContentBox c = (RenderableReplacedContentBox) renderNode;
      final DrawableWrapper rawObject = (DrawableWrapper) c.getContent().getRawObject();
      final JFreeChartReportDrawable backend = (JFreeChartReportDrawable) rawObject.getBackend();
      final JFreeChart chart = backend.getChart();
      final CategoryPlot p = (CategoryPlot) chart.getPlot();
      final CategoryDataset dataset = p.getDataset();
      Assert.assertNotNull(dataset);
      DebugLog.log(rawObject);
    }
  }
View Full Code Here

  protected void configureChart(final JFreeChart chart)
  {
    super.configureChart(chart);

    final CategoryPlot cpl = chart.getCategoryPlot();
    final CategoryItemRenderer renderer = cpl.getRenderer();
    if (StringUtils.isEmpty(getTooltipFormula()) == false)
    {
      renderer.setBaseToolTipGenerator(new FormulaCategoryTooltipGenerator(getRuntime(), getTooltipFormula()));
    }
    if (StringUtils.isEmpty(getUrlFormula()) == false)
    {
      renderer.setBaseItemURLGenerator(new FormulaCategoryURLGenerator(getRuntime(), getUrlFormula()));
    }
    if (this.categoricalLabelFormat != null)
    {
      final StandardCategoryItemLabelGenerator scilg;
      if (categoricalLabelDecimalFormat != null)
      {
        final DecimalFormat numFormat = new DecimalFormat(categoricalLabelDecimalFormat,
                                                          new DecimalFormatSymbols(getRuntime().getResourceBundleFactory().getLocale()));
        numFormat.setRoundingMode(RoundingMode.HALF_UP);
        scilg = new StandardCategoryItemLabelGenerator(categoricalLabelFormat, numFormat);
      }
      else if (categoricalLabelDateFormat != null)
      {
        scilg = new StandardCategoryItemLabelGenerator(categoricalLabelFormat,
            new SimpleDateFormat(categoricalLabelDateFormat, getRuntime().getResourceBundleFactory().getLocale()));
      }
      else
      {
        final DecimalFormat formatter = new DecimalFormat();
        formatter.setDecimalFormatSymbols
            (new DecimalFormatSymbols(getRuntime().getResourceBundleFactory().getLocale()));
        scilg = new StandardCategoryItemLabelGenerator(categoricalLabelFormat, formatter);
      }
      renderer.setBaseItemLabelGenerator(scilg);
    }
    renderer.setBaseItemLabelsVisible(Boolean.TRUE.equals(getItemsLabelVisible()));
    if (getItemLabelFont() != null)
    {
      renderer.setBaseItemLabelFont(getItemLabelFont());
    }

    if (categoricalItemLabelRotation != null)
    {
      final ItemLabelPosition orgPosItemLabelPos = renderer.getBasePositiveItemLabelPosition();
      if (orgPosItemLabelPos == null)
      {
        final ItemLabelPosition pos2 = new ItemLabelPosition
            (ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER,
                TextAnchor.CENTER, categoricalItemLabelRotation.doubleValue());
        renderer.setBasePositiveItemLabelPosition(pos2);
      }
      else
      {
        final ItemLabelPosition pos2 = new ItemLabelPosition
            (orgPosItemLabelPos.getItemLabelAnchor(), orgPosItemLabelPos.getTextAnchor(),
                orgPosItemLabelPos.getRotationAnchor(), categoricalItemLabelRotation.doubleValue());
        renderer.setBasePositiveItemLabelPosition(pos2);
      }

      final ItemLabelPosition orgNegItemLabelPos = renderer.getBaseNegativeItemLabelPosition();
      if (orgNegItemLabelPos == null)
      {
        final ItemLabelPosition pos2 = new ItemLabelPosition
            (ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER,
                TextAnchor.CENTER, categoricalItemLabelRotation.doubleValue());
        renderer.setBaseNegativeItemLabelPosition(pos2);
      }
      else
      {
        final ItemLabelPosition neg2 = new ItemLabelPosition
            (orgNegItemLabelPos.getItemLabelAnchor(), orgNegItemLabelPos.getTextAnchor(),
                orgNegItemLabelPos.getRotationAnchor(), categoricalItemLabelRotation.doubleValue());
        renderer.setBaseNegativeItemLabelPosition(neg2);
      }
    }

    final Font labelFont = Font.decode(getLabelFont());


    final CategoryAxis categoryAxis = cpl.getDomainAxis();
    categoryAxis.setLabelFont(labelFont);
    categoryAxis.setTickLabelFont(labelFont);
    if (getCategoryTitleFont() != null)
    {
      categoryAxis.setLabelFont(getCategoryTitleFont());
    }
    if (getCategoryTickFont() != null)
    {
      categoryAxis.setTickLabelFont(getCategoryTickFont());
    }

    if (maxCategoryLabelWidthRatio != null)
    {
      categoryAxis.setMaximumCategoryLabelWidthRatio(maxCategoryLabelWidthRatio.floatValue());
    }
    cpl.setDomainGridlinesVisible(showGridlines);
    if (labelRotation != null)
    {
      categoryAxis.setCategoryLabelPositions
          (CategoryLabelPositions.createUpRotationLabelPositions(labelRotation.doubleValue()));
    }

    final String[] colors = getSeriesColor();
    for (int i = 0; i < colors.length; i++)
    {
      renderer.setSeriesPaint(i, parseColorFromString(colors[i]));
    }

    if (lowerMargin != null)
    {
      categoryAxis.setLowerMargin(lowerMargin.doubleValue());
    }
    if (upperMargin != null)
    {
      categoryAxis.setUpperMargin(upperMargin.doubleValue());
    }
    if (categoryMargin != null)
    {
      categoryAxis.setCategoryMargin(categoryMargin.doubleValue());
    }


    final ValueAxis rangeAxis = cpl.getRangeAxis();
    if (rangeAxis instanceof NumberAxis)
    {
      final NumberAxis numberAxis = (NumberAxis) rangeAxis;
      numberAxis.setAutoRangeIncludesZero(isRangeIncludesZero());
      numberAxis.setAutoRangeStickyZero(isRangeStickyZero());
View Full Code Here

    {
      renderer.setBaseItemURLGenerator(
          new StandardCategoryURLGenerator());
    }

    final CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis,
        renderer);
    plot.setOrientation(orientation);
    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
  }
View Full Code Here

  }

  protected void configureChart(final JFreeChart chart)
  {
    super.configureChart(chart);
    final CategoryPlot cpl = chart.getCategoryPlot();

    cpl.getDomainAxis().setCategoryMargin(0.0);

    final CategoryItemRenderer renderer = cpl.getRenderer();
    if ((isStacked()) && renderAsPercentages && (renderer instanceof StackedAreaRenderer))
    {
      final StackedAreaRenderer sbr = (StackedAreaRenderer) renderer;
      sbr.setRenderAsPercentages(true);
    }
View Full Code Here

TOP

Related Classes of org.jfree.chart.plot.CategoryPlot

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.