Package org.jfree.data.general

Examples of org.jfree.data.general.PieDataset


        // build a PieDataset representing Issues by Status
        final Comparator<Issue> issuesByStatusGrouper = GlazedLists.beanPropertyComparator(Issue.class, "status", new String[0]);
        final FunctionList.Function<List<Issue>, Comparable<String>> keyFunction = new StatusFunction();
        final FunctionList.Function<List<Issue>, Number> valueFunction = new ListSizeFunction();
        final EventList<Issue> pieDataSource = GlazedListsSwing.swingThreadProxyList(issuesList);
        final PieDataset issuesByStatusDataset = new EventListPieDataset<Issue, String>(pieDataSource, issuesByStatusGrouper, keyFunction, valueFunction);

        // build a Pie Chart and a panel to display it
        final JFreeChart pieChart_IssuesByStatus = new JFreeChart("Issues By Status", new CustomPiePlot(issuesByStatusDataset));
        pieChart_IssuesByStatus.setBackgroundPaint(CHART_PANEL_BACKGROUND_PAINT);
        pieChart_IssuesByStatus.getLegend().setBorder(CHART_LEGEND_BORDER);
View Full Code Here


  public MasterReport createReport() throws ReportDefinitionException
  {
    final MasterReport report = parseReport();
    // create a dataset...
    final PieDataset dataset = createSampleDataset();
    // create the chart...
    final JFreeChart chart = createChart(dataset);
    report.getParameterValues().put("Chart", chart);
    return report;
  }
View Full Code Here

  public MasterReport createReport() throws ReportDefinitionException
  {
    final MasterReport report = parseReport();
    // create a dataset...
    final PieDataset dataset = createSampleDataset();
    // create the chart...
    final JFreeChart chart = createChart(dataset);
    report.getParameterValues().put("Chart", chart);
    return report;
  }
View Full Code Here

    sectionDepth = 0.5;
  }

  protected JFreeChart computeChart(final Dataset dataset)
  {
    PieDataset pieDataset = null;
    if (dataset instanceof PieDataset)
    {
      pieDataset = (PieDataset) dataset;
    }
View Full Code Here

  }

  protected JFreeChart computeChart(final Dataset dataset)
  {

    PieDataset pieDataset = null;
    if (dataset instanceof PieDataset)
    {
      pieDataset = (PieDataset) dataset;
    }
View Full Code Here

  }


  protected void configureExplode(final PiePlot pp)
  {
    final PieDataset pieDS = pp.getDataset();

    final int explodeType = computeExplodeType();
    if (explodeType == EXPLODE_VALUE)
    {
      try
      {
        final int actualSegment = Integer.parseInt(explodeSegment);
        if (actualSegment >= 0)
        {
          pp.setExplodePercent(pieDS.getKey(actualSegment), explodePct.doubleValue());
        }
      }
      catch (Exception ignored)
      {
      }
      return;
    }

    // Calculate min and max...
    if (pieDS != null)
    {
      final int itemCount = pieDS.getItemCount();
      Number maxNum = new Double(Integer.MIN_VALUE);
      Number minNum = new Double(Integer.MAX_VALUE);
      int maxSegment = -1;
      int minSegment = -1;
      for (int i = 0; i < itemCount; i++)
      {
        final Number nbr = pieDS.getValue(i);
        if (nbr.doubleValue() > maxNum.doubleValue())
        {
          maxNum = nbr;
          maxSegment = i;
        }
        if (nbr.doubleValue() < minNum.doubleValue())
        {
          minNum = nbr;
          minSegment = i;
        }
      }

      if (explodeType == EXPLODE_MIN)
      { //$NON-NLS-1$
        if (minSegment >= 0)
        {
          pp.setExplodePercent(pieDS.getKey(minSegment), explodePct.doubleValue());
        }
      }
      else
      {
        if (maxSegment >= 0)
        {
          pp.setExplodePercent(pieDS.getKey(maxSegment), explodePct.doubleValue());
        }
      }
    }

  }
View Full Code Here

  {
    super.configureChart(chart);

    final Plot plot = chart.getPlot();
    final PiePlot pp = (PiePlot)plot;
    final PieDataset pieDS = pp.getDataset();
    pp.setDirection(rotationClockwise ? Rotation.CLOCKWISE : Rotation.ANTICLOCKWISE);
    if ((explodeSegment != null) && (explodePct != null))
    {
      configureExplode(pp);
    }
    if (StringUtils.isEmpty(getTooltipFormula()) == false)
    {
      pp.setToolTipGenerator(new FormulaPieTooltipGenerator(getRuntime(), getTooltipFormula()));
    }
    if (StringUtils.isEmpty(getUrlFormula()) == false)
    {
      pp.setURLGenerator(new FormulaPieURLGenerator(getRuntime(), getUrlFormula()));
    }

    pp.setIgnoreNullValues(ignoreNulls);
    pp.setIgnoreZeroValues(ignoreZeros);
    if (Boolean.FALSE.equals(getItemsLabelVisible()))
    {
      pp.setLabelGenerator(null);
    }
    else
    {
      final ExpressionRuntime runtime = getRuntime();
      final Locale locale = runtime.getResourceBundleFactory().getLocale();

      final FastDecimalFormat fastPercent = new FastDecimalFormat(FastDecimalFormat.TYPE_PERCENT, locale);
      final FastDecimalFormat fastInteger = new FastDecimalFormat(FastDecimalFormat.TYPE_INTEGER, locale);

      final DecimalFormat numFormat = new DecimalFormat(fastInteger.getPattern(), new DecimalFormatSymbols(locale));
      numFormat.setRoundingMode(RoundingMode.HALF_UP);

      final DecimalFormat percentFormat = new DecimalFormat(fastPercent.getPattern(), new DecimalFormatSymbols(locale));
      percentFormat.setRoundingMode(RoundingMode.HALF_UP);

      final StandardPieSectionLabelGenerator labelGen = new StandardPieSectionLabelGenerator(pieLabelFormat,
                                                                                             numFormat, percentFormat);
      pp.setLabelGenerator(labelGen);

      final StandardPieSectionLabelGenerator legendGen = new StandardPieSectionLabelGenerator(pieLegendLabelFormat,
                                                                                              numFormat, percentFormat);
      pp.setLegendLabelGenerator(legendGen);
    }

    if (StringUtils.isEmpty(getLabelFont()) == false)
    {
      pp.setLabelFont(Font.decode(getLabelFont()));
    }

    if (pieDS != null)
    {
      final String[] colors = getSeriesColor();
      for (int i = 0; i < colors.length; i++)
      {
        if (i < pieDS.getItemCount())
        {
          pp.setSectionPaint(pieDS.getKey(i), parseColorFromString(colors[i]));
        }
        else
        {
          break;
        }
View Full Code Here

   * @param name
   * @param outputFileName
   * @param data
   */
  public static void drawPie(String name, String outputFileName, List<Entry> data) {
    PieDataset dataset = makePieDataSet(data)
    JFreeChart chart = ChartFactory.createPieChart3D(name, dataset, true, true, false)
    PiePlot3D  plot = (PiePlot3D)chart.getPlot()
    // 图片中显示百分比:默认方式 
    //plot.setLabelGenerator(new           StandardPieSectionLabelGenerator(StandardPieToolTipGenerator.DEFAULT_TOOLTIP_FORMAT)); 
    // 图片中显示百分比:自定义方式,{0} 表示选项, {1} 表示数值, {2} 表示所占比例 ,小数点后两位 
View Full Code Here

                            int section,
                            Rectangle2D dataArea,
                            PiePlotState state,
                            int currentPass) {

        PieDataset dataset = getDataset();
        Number n = dataset.getValue(section);
        if (n == null) {
            return;
        }
        double value = n.doubleValue();
        double angle1 = 0.0;
View Full Code Here

            else {
                title = this.dataset.getColumnKey(pieIndex).toString();
            }
            this.pieChart.setTitle(title);

            PieDataset piedataset = null;
            PieDataset dd = new CategoryToPieDataset(this.dataset,
                    this.dataExtractOrder, pieIndex);
            if (this.limit > 0.0) {
                piedataset = DatasetUtilities.createConsolidatedPieDataset(
                        dd, this.aggregatedItemsKey, this.limit);
            }
View Full Code Here

TOP

Related Classes of org.jfree.data.general.PieDataset

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.