Package org.jfree.chart

Examples of org.jfree.chart.JFreeChart


      totalTickets += openTickets.intValue();
      pieData.setValue(userName, openTickets);
    }

    // create the chart
    JFreeChart pieChart = ChartFactory.createPieChart("Open Tickets by User", pieData, true, true, false);

    // add the "Total Open Tickets" sub-title
    TextTitle t1 = new TextTitle("Total Open Tickets: " + String.valueOf(totalTickets),
                                 new Font("SansSerif", Font.PLAIN, 11));
    pieChart.addSubtitle(t1);

    // set the chart visual options
    PiePlot plot = (PiePlot)pieChart.getPlot();
    plot.setForegroundAlpha(0.65f);
    plot.setNoDataMessage("There are no currently open tickets.");

    // print the chart image directly the the HTTP stream
    OutputStream out = response.getOutputStream();
View Full Code Here


      Number ageValue = (Number)row.get("age");
      chartData.setValue(openTickets, userName, this.getAgeName(ageValue));
    }

    // create the chart
    JFreeChart barChart = ChartFactory.createStackedBarChart("Open Tickets by Age", "Age", "# Open Tickets",
                                                             chartData, org.jfree.chart.plot.PlotOrientation.VERTICAL,
                                                             true, true, false);

    // set the visual options
    CategoryPlot plot = barChart.getCategoryPlot();

    // set the X axis labels to be slanted
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 3.0));
View Full Code Here

        //
        // Build series data from the give statistic
        //

        JFreeChart chart = null;
        if ("area".equals(chartType)) {

            chart = ChartFactory.createXYAreaChart("", xLabel, yLabel, ds, PlotOrientation.VERTICAL,
                    showLegend, false, false);

            ((XYAreaRenderer) chart.getXYPlot().getRenderer()).setOutline(true);

        } else if ("stacked".equals(chartType)) {

            chart = ChartFactory.createStackedXYAreaChart("", xLabel, yLabel, ds, PlotOrientation.VERTICAL, showLegend,
                    false, false);

        } else if ("line".equals(chartType)) {

            chart = ChartFactory.createXYLineChart("", xLabel, yLabel, ds, PlotOrientation.VERTICAL, showLegend,
                    false, false);

            final XYLine3DRenderer renderer = new XYLine3DRenderer();
            renderer.setDrawOutlines(true);
            renderer.setLinesVisible(true);
            renderer.setShapesVisible(true);
            renderer.setStroke(new BasicStroke(2));
            renderer.setXOffset(1);
            renderer.setYOffset(1);
            chart.getXYPlot().setRenderer(renderer);
        }

        if (chart != null) {
            chart.setAntiAlias(true);
            chart.setBackgroundPaint(new Color(backgroundColor));
            for (int i = 0; i < SERIES_NUM; i++) {
                if (seriesColor[i] >= 0) {
                    chart.getXYPlot().getRenderer().setSeriesPaint(i, new Color(seriesColor[i]));
                }
                if (seriesOutlineColor[i] >= 0) {
                    chart.getXYPlot().getRenderer().setSeriesOutlinePaint(i, new Color(seriesOutlineColor[i]));
                }
            }
            chart.getXYPlot().setDomainGridlinePaint(new Color(gridColor));
            chart.getXYPlot().setRangeGridlinePaint(new Color(gridColor));
            chart.getXYPlot().setDomainAxis(0, new DateAxis());
            chart.getXYPlot().setDomainAxis(1, new DateAxis());
            chart.getXYPlot().setInsets(new RectangleInsets(-15, 0, 0, 10));

            response.setHeader("Content-type", "image/png");
            response.getOutputStream().write(ChartUtilities.encodeAsPNG(chart.createBufferedImage(width, height)));
        }

        return null;
    }
View Full Code Here

    NumberFormat numFormatter = NumberFormat.getCurrencyInstance();
    String totalForecastString = numFormatter.format(totalForecast);
    String totalActualString = numFormatter.format(totalActual);

    // create the chart
    JFreeChart pieChart = ChartFactory.createPieChart("Opportunities by Stage", pieData, true, true, false);

    // set the sub-title
    TextTitle t1 = new TextTitle("Total Forecasted: " + totalForecastString + "           " +
                                 "Total Amount: " + totalActualString,
                                 new Font("SansSerif", Font.PLAIN, 11));
    pieChart.addSubtitle(t1);

    // set the chart visual options
    PiePlot plot = (PiePlot)pieChart.getPlot();
    plot.setForegroundAlpha(0.65f);
    plot.setNoDataMessage("No data to display");
    plot.setLabelGenerator(new CustomLabelGenerator(numFormatter));

    // print the chart image directly the the HTTP stream
View Full Code Here

    NumberFormat numFormatter = NumberFormat.getCurrencyInstance();
    String totalForecastString = numFormatter.format(totalForecast);
    String totalActualString = numFormatter.format(totalActual);

    // create the chart
    JFreeChart barChart = ChartFactory.createStackedBarChart("Opportunities by Month", "Month", "Opportunity Value ($)",
                                                             chartData, org.jfree.chart.plot.PlotOrientation.VERTICAL,
                                                             true, true, false);

    // set the sub-title
    TextTitle t1 = new TextTitle("Total Forecasted: " + totalForecastString + "           " +
                                 "Total Amount: " + totalActualString,
                                 new Font("SansSerif", Font.PLAIN, 11));
    barChart.addSubtitle(t1);

    // set the chart visual options
    CategoryPlot plot = barChart.getCategoryPlot();
   
    // set the X axis labels to be slanted
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 3.0));
   
View Full Code Here

      dataset = DatasetReader
          .readCategoryDatasetFromXML(new ByteArrayInputStream(reader
              .getBuffer().toString().getBytes()));

      // create the chart...
      final JFreeChart chart = ChartFactory.createBarChart("Bar Chart", // chart
                                        // title
          "Domain", "Range", dataset, // data
          PlotOrientation.VERTICAL, true, // include legend
          true, false);
      updateSettings(chart,getChartInput.getChartConfig());
View Full Code Here

      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)
    {
      return ChartFactory.createXYAreaChart("XY Area Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL,
          true, false, false);// NON-NLS
    }
    if (aExpression instanceof XYBarChartExpression)
    {
      return XYBarChartExpression.createXYBarChart("XY Bar Chart", "X", false, "Y", createIntervalXYDataset(),
          PlotOrientation.VERTICAL, true, false, false);// NON-NLS
    }
    if (aExpression instanceof XYLineChartExpression)
    {
      return ChartFactory.createXYLineChart("XY Line Chart", "X", "Y", createXYZDataset(), PlotOrientation.VERTICAL,
          true, false, false);// NON-NLS
    }
    if (aExpression instanceof RadarChartExpression)
    {
      final SpiderWebPlot plot = new SpiderWebPlot(createDataset());
      return new JFreeChart("Radar Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    }
    return null;
  }
View Full Code Here

  }

  protected JFreeChart computeCategoryChart(final CategoryDataset categoryDataset)
  {
    final PlotOrientation orientation = computePlotOrientation();
    final JFreeChart chart;
    if (isStacked())
    {
      chart = createStackedAreaChart
          (computeTitle(), getCategoryAxisLabel(), getValueAxisLabel(),
              categoryDataset, orientation, isShowLegend(),
              false, false);
    }
    else
    {
      chart = ChartFactory.createAreaChart
          (computeTitle(), getCategoryAxisLabel(), getValueAxisLabel(), categoryDataset,
              orientation, isShowLegend(), false, false);
      chart.getCategoryPlot().setDomainAxis(new FormattedCategoryAxis(getCategoryAxisLabel(),
          getCategoricalAxisMessageFormat(), getRuntime().getResourceBundleFactory().getLocale()));
    }

    configureLogarithmicAxis(chart.getCategoryPlot());
    return chart;
  }
View Full Code Here

    }

    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

    setRangeTitleFont(Font.decode(barsLabelFont));
  }

  public JFreeChart computeCategoryChart(final CategoryDataset barsDataset)
  {
    final JFreeChart chart = super.computeCategoryChart(barsDataset);
    final CategoryDataset linesDataset = createLinesDataset();

    //Create the renderer with the barchart, use a different bar renderer depending
    //if 3D chart or not
    final CategoryPlot plot = chart.getCategoryPlot();
    final CategoryItemRenderer lineRenderer;
    if (isThreeD())
    {
      lineRenderer = new LineRenderer3D();
    }
View Full Code Here

TOP

Related Classes of org.jfree.chart.JFreeChart

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.