Examples of PiePlot


Examples of org.jfree.chart.plot.PiePlot

            }
            if (event.getSortOrderPieChartByValue() != null) {
                dataset.sortByKeys(event.getSortOrderPieChartByValue());
            }
           
            PiePlot plot = (PiePlot) chart.getPlot();
           
            if (event.isShowPercentages()) {
                plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} = {2}"));
            } else {
                plot.setLabelGenerator(new StandardPieSectionLabelGenerator("{0} = {1}"));
            }
        }

        for (int i = 0; i < event.getPieData().length; i++) {
            dataset.setValue(event.getPieDataNames()[i], event.getPieData()[i]);
        }
       
        // Exploded segments.
        PiePlot plot = (PiePlot) chart.getPlot();
       
        for (String key : event.getExplodedSegmentsPie().keySet()) {
            plot.setExplodePercent(key, event.getExplodedSegmentsPie().get(key));
        }
       
        // Segment paints.
        for (String key : event.getPaintSegments().keySet()) {
            plot.setSectionPaint(key, event.getPaintSegments().get(key));
        }
  }
View Full Code Here

Examples of org.jfree.chart.plot.PiePlot

            dataset,             // dataset
            true,                // include legend
            true,
            false
        );
        PiePlot plot = (PiePlot) chart.getPlot();
        plot.setNoDataMessage("No data available");
        plot.setExplodePercent("Three", 0.30);
        plot.setExplodePercent("One", 0.30);
        plot.setExplodePercent("Five", 0.10);
        return chart;
    }
View Full Code Here

Examples of org.jfree.chart.plot.PiePlot

        }
        dataset.setValue(name, Double.parseDouble(data[i].toString()));
      }

      chart = ChartFactory.createPieChart(title, dataset, true, false, false);
      PiePlot plot = (PiePlot) chart.getPlot();
      // 设置显示格式, {0}表示名称, {1}表示值, {2}表示百分比值
      if (labelFormat != null) {
        plot.setLabelGenerator(new StandardPieSectionLabelGenerator(
            labelFormat, NumberFormat.getNumberInstance(), new DecimalFormat(
                "0.0%")));
      }
      plot.setLabelFont(tickLabelFont);
      break;
    }
    case VBAR:
    case HBAR:
    case LINE:
    case SPIDER: {
      // 设置填充的数据集
      DefaultCategoryDataset dataset = new DefaultCategoryDataset();

      int step = 1 + (itemNames == null ? 1 : 0)
          + (groupNames != null && groupNames[0].length() == 0 ? 1 : 0);
      for (int i = 0; i < size; i++) {
        String name;
        if (itemNames != null) {
          name = itemNames[groupNames != null && groupNames[0].length() > 0 ? (i / step)
              / groupNames.length
              : i * itemNames.length / size];
        } else {
          name = data[i].toString();
          i++;
        }
        String category;
        if (groupNames != null) {
          if (groupNames[0].length() == 0) {
            category = data[i].toString();
            i++;
          } else {
            category = groupNames[((i / step) % groupNames.length)];
          }
        } else {
          category = "";
        }
        dataset
            .addValue(Double.parseDouble(data[i].toString()), category, name);
      }

      if (type == SPIDER) {
        AdvancedSpiderWebPlot plot = new AdvancedSpiderWebPlot(dataset);
        chart = new JFreeChart(title, titleFont, plot, groupNames != null);
        if (labelFormat != null) {
          plot.setLabelGenerator(new StandardCategoryItemLabelGenerator(
              labelFormat, NumberFormat.getNumberInstance(), new DecimalFormat(
                  "0.0%")));
        }
        plot.setLabelFont(labelFont);
        if (keys != null) {
          plot.setMaxValue(Double.parseDouble(keys[0]));
        }
      } else {
        if (type == LINE) {
          chart = ChartFactory.createLineChart(title, keys[0], keys[1],
              dataset, PlotOrientation.VERTICAL, groupNames != null, false,
              false);
        } else {
          chart = ChartFactory.createBarChart(title, keys[0], keys[1], dataset,
              type == VBAR ? PlotOrientation.VERTICAL
                  : PlotOrientation.HORIZONTAL, groupNames != null, false,
              false);
        }
        CategoryPlot plot = chart.getCategoryPlot();
        // 设置显示值的数字
        AbstractCategoryItemRenderer renderer = (AbstractCategoryItemRenderer) plot
            .getRenderer();
        if (labelFormat != null) {
          renderer.setBaseItemLabelFont(labelFont);
          renderer.setBaseItemLabelsVisible(true);
          renderer
              .setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
        }
        if (type == LINE) {
          // 线条模式设置显示节点图形
          ((LineAndShapeRenderer) renderer).setBaseShapesVisible(true);
        }

        // 设置数值轴的信息
        {
          NumberAxis axis = (NumberAxis) plot.getRangeAxis();
          axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
          axis.setUpperMargin(0.12D);
          axis.setLabelFont(labelFont);
          axis.setTickLabelFont(tickLabelFont);
        }

        // 设置分类/标题轴的信息
        {
          CategoryAxis axis = plot.getDomainAxis();
          axis.setLabelFont(labelFont);
          axis.setTickLabelFont(tickLabelFont);
        }
      }
      break;
View Full Code Here

Examples of org.jfree.chart.plot.PiePlot

        chart.setBackgroundPaint(Color.white);
        chart.setBorderVisible(false);
        chart.setBorderPaint(null);


        PiePlot plot = (PiePlot)chart.getPlot();
        plot.setSectionOutlinesVisible(false);
        plot.setLabelFont(new Font("SansSerif", Font.BOLD, 12));
        plot.setNoDataMessage("No data available");
        plot.setCircular(true);
        plot.setLabelGap(0.02);
        plot.setOutlinePaint(null);
        plot.setLabelLinksVisible(false);

        plot.setLabelGenerator(null);

        plot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0}"));


        plot.setStartAngle(270);
        plot.setDirection(Rotation.ANTICLOCKWISE);
        plot.setForegroundAlpha(0.60f);
        plot.setInteriorGap(0.33);

        return chart;
    }
View Full Code Here

Examples of org.jfree.chart.plot.PiePlot

    DefaultPieDataset dpd = createPieChartDataset(kategori, tutar);
    JFreeChart chart = ChartFactory.createPieChart(
        "Günlere Göre Satış Grafiği", dpd, true, true,
        false);

    PiePlot plot = (PiePlot) chart.getPlot();
    plot.setNoDataMessage("İşlenecek Veri Yok");
    plot.setCircular(false);
    plot.setLabelGap(0.02);

    chart.setBackgroundPaint(new Color(255, 255, 255));
    ChartPanel cp = new ChartPanel(chart);
    cp.setBackground(UIManager.getColor("Button.shadow"));
    cp.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
View Full Code Here

Examples of org.jfree.chart.plot.PiePlot

        pieDataset.setValue(key + " " + amount, new Double(chartData.getChartKunInvoiceAmount().doubleValue()));
      }

      String title = "Monthly amount for year 2009";
      JFreeChart chart = ChartFactory.createPieChart(title, pieDataset, true, true, true);
      PiePlot plot = (PiePlot) chart.getPlot();
      plot.setForegroundAlpha(0.5f);
      BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null);
      byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);

      AImage chartImage = new AImage("Pie Chart", bytes);
View Full Code Here

Examples of org.jfree.chart.plot.PiePlot

            true,               // include legend
            true,
            false
        );

        PiePlot plot = (PiePlot) chart.getPlot();
        plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12));
        plot.setNoDataMessage("No data available");
        plot.setCircular(false);
        plot.setLabelGap(0.02);
        return chart;
       
    }
View Full Code Here

Examples of org.jfree.chart.plot.PiePlot

            true,                // include legend
            true,
            false
        );

        PiePlot plot = (PiePlot) chart.getPlot();
        plot.setSectionOutlinesVisible(false);
        plot.setNoDataMessage("No data available");
        return chart;

    }
View Full Code Here

Examples of org.jfree.chart.plot.PiePlot

            true,                // include legend
            true,
            false
        );

        PiePlot plot = (PiePlot) chart.getPlot();
        plot.setSectionOutlinesVisible(false);
        plot.setNoDataMessage("No data available");
        return chart;

    }
View Full Code Here

Examples of org.jfree.chart.plot.PiePlot

     * dataset should be null.
     */
    public void testReplaceDatasetOnPieChart() {
        LocalListener l = new LocalListener();
        this.pieChart.addChangeListener(l);
        PiePlot plot = (PiePlot) this.pieChart.getPlot();
        plot.setDataset(null);
        assertEquals(true, l.flag);
        assertNull(plot.getDataset());
    }
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.