Пример #1
1
 private static JFreeChart createChart(CategoryDataset categorydataset) {
   JFreeChart jfreechart =
       ChartFactory.createBarChart(
           "Bar Chart Demo 1",
           "Category",
           "Value",
           categorydataset,
           PlotOrientation.VERTICAL,
           true,
           true,
           false);
   CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
   categoryplot.setDomainGridlinesVisible(true);
   categoryplot.setRangeCrosshairVisible(true);
   categoryplot.setRangeCrosshairPaint(Color.blue);
   NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
   numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
   BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
   barrenderer.setDrawBarOutline(false);
   GradientPaint gradientpaint =
       new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64));
   GradientPaint gradientpaint1 =
       new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0));
   GradientPaint gradientpaint2 =
       new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0));
   barrenderer.setSeriesPaint(0, gradientpaint);
   barrenderer.setSeriesPaint(1, gradientpaint1);
   barrenderer.setSeriesPaint(2, gradientpaint2);
   barrenderer.setLegendItemToolTipGenerator(
       new StandardCategorySeriesLabelGenerator("Tooltip: {0}"));
   CategoryAxis categoryaxis = categoryplot.getDomainAxis();
   categoryaxis.setCategoryLabelPositions(
       CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D));
   return jfreechart;
 }
Пример #2
0
 private JFreeChart createChart(CategoryDataset setCategory) {
   JFreeChart chart =
       ChartFactory.createBarChart(
           this.chartTitle, "", "", setCategory, PlotOrientation.VERTICAL, true, true, false);
   CategoryPlot plot = (CategoryPlot) chart.getPlot();
   plot.addRangeMarker(ChartUtil.getAverageMarker(this.average), Layer.FOREGROUND);
   BookModel model = this.mainFrame.getBookModel();
   Session session = model.beginTransaction();
   StrandDAOImpl daoStrand = new StrandDAOImpl(session);
   List strands = daoStrand.findAll();
   model.commit();
   Color[] colors = new Color[strands.size()];
   int i = 0;
   Object iObject = strands.iterator();
   while (((Iterator) iObject).hasNext()) {
     Strand strand = (Strand) ((Iterator) iObject).next();
     colors[i] = ColorUtil.darker(strand.getJColor(), 0.25D);
     i++;
   }
   iObject = (BarRenderer) plot.getRenderer();
   for (int j = 0; j < setCategory.getRowCount(); j++) {
     Color color = colors[(j % colors.length)];
     ((BarRenderer) iObject).setSeriesPaint(j, color);
   }
   return chart;
 }
Пример #3
0
 private static JFreeChart createChart(CategoryDataset categorydataset) {
   JFreeChart jfreechart =
       ChartFactory.createStackedBarChart3D(
           "Stacked Bar Chart 3D Demo 2",
           "Category",
           "Value",
           categorydataset,
           PlotOrientation.VERTICAL,
           true,
           true,
           false);
   CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
   NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
   numberaxis.setNumberFormatOverride(new DecimalFormat("0.0%"));
   StackedBarRenderer3D stackedbarrenderer3d = (StackedBarRenderer3D) categoryplot.getRenderer();
   stackedbarrenderer3d.setRenderAsPercentages(true);
   stackedbarrenderer3d.setDrawBarOutline(false);
   stackedbarrenderer3d.setBaseItemLabelGenerator(
       new StandardCategoryItemLabelGenerator(
           "{3}", NumberFormat.getIntegerInstance(), new DecimalFormat("0.0%")));
   stackedbarrenderer3d.setBaseItemLabelsVisible(true);
   stackedbarrenderer3d.setBasePositiveItemLabelPosition(
       new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
   stackedbarrenderer3d.setBaseNegativeItemLabelPosition(
       new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
   return jfreechart;
 }
  protected void configurePlot(Plot plot, JRChartPlot jrPlot) {

    super.configurePlot(plot, jrPlot);

    if (plot instanceof CategoryPlot) {
      CategoryPlot categoryPlot = (CategoryPlot) plot;
      CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer();
      CategoryDataset categoryDataset = categoryPlot.getDataset();
      if (categoryDataset != null) {
        for (int i = 0; i < categoryDataset.getRowCount(); i++) {
          categoryRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
        }
      }
      categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217);
      categoryPlot.setRangeGridlineStroke(new BasicStroke(0.5f));
      categoryPlot.setDomainGridlinesVisible(false);
      categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    } else if (plot instanceof XYPlot) {
      XYPlot xyPlot = (XYPlot) plot;
      XYItemRenderer xyItemRenderer = xyPlot.getRenderer();
      XYDataset xyDataset = xyPlot.getDataset();
      if (xyDataset != null) {
        for (int i = 0; i < xyDataset.getSeriesCount(); i++) {
          xyItemRenderer.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
        }
      }
      xyPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217);
      xyPlot.setRangeGridlineStroke(new BasicStroke(0.5f));
      xyPlot.setDomainGridlinesVisible(false);
      xyPlot.setRangeZeroBaselineVisible(true);
    }
  }
Пример #5
0
  /**
   * Creates a chart.
   *
   * @param dataset the dataset.
   * @return The chart.
   */
  private static JFreeChart createChart(CategoryDataset dataset) {

    JFreeChart chart =
        ChartFactory.createStackedBarChart3D(
            "Stacked Bar Chart 3D Demo 1", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // the plot orientation
            true, // include legend
            true, // tooltips
            false // urls
            );
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    IntervalMarker m =
        new IntervalMarker(
            5.0, 10.0, Color.gray, new BasicStroke(0.5f), Color.blue, new BasicStroke(0.5f), 0.5f);
    plot.addRangeMarker(m);
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);
    renderer.setBasePositiveItemLabelPosition(
        new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
    renderer.setBaseNegativeItemLabelPosition(
        new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
    return chart;
  }
  private static void generateChart(
      String benchmark, DefaultCategoryDataset dataset, int benchmarkCount) {
    JFreeChart chart =
        ChartFactory.createBarChart(
            benchmark,
            "framework",
            "throughput",
            dataset,
            PlotOrientation.HORIZONTAL,
            true,
            false,
            false);

    CategoryPlot plot = chart.getCategoryPlot();
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setItemMargin(0);
    notSoUglyPlease(chart);

    String pngFile = getOutputName(benchmark);

    try {
      int height = 100 + benchmarkCount * 20;
      ChartUtilities.saveChartAsPNG(new File(pngFile), chart, 700, height);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
Пример #7
0
 private static JFreeChart finishBarChart(JFreeChart chart, Color... colors) {
   CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
   categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
   categoryplot.setRangePannable(true);
   if (colors.length > 0) categoryplot.setRenderer(new CustomRenderer(colors));
   BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
   barrenderer.setItemLabelAnchorOffset(9D);
   barrenderer.setBaseItemLabelsVisible(true);
   barrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
   barrenderer.setMaximumBarWidth(0.05);
   barrenderer.setItemMargin(0.03D);
   ItemLabelPosition itemlabelposition =
       new ItemLabelPosition(INSIDE12, CENTER_RIGHT, CENTER_RIGHT, -1.5707963267948966D);
   barrenderer.setBasePositiveItemLabelPosition(itemlabelposition);
   ItemLabelPosition itemlabelposition1 =
       new ItemLabelPosition(OUTSIDE12, CENTER_LEFT, CENTER_LEFT, -1.5707963267948966D);
   barrenderer.setPositiveItemLabelPositionFallback(itemlabelposition1);
   CategoryAxis categoryaxis = categoryplot.getDomainAxis();
   categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
   categoryaxis.setCategoryMargin(0.25D);
   categoryaxis.setUpperMargin(0.02D);
   categoryaxis.setLowerMargin(0.02D);
   NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
   numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
   numberaxis.setUpperMargin(0.10000000000000001D);
   ChartUtilities.applyCurrentTheme(chart);
   return chart;
 }
  public void loadDataToGrafik() throws IOException {
    DefaultCategoryDataset dataset = (DefaultCategoryDataset) this.generateData();
    chart =
        ChartFactory.createBarChart(
            "Statistik Pendidikan Dosen",
            "Prodi",
            "Jumlah Dosen",
            dataset,
            PlotOrientation.HORIZONTAL,
            true,
            true,
            false);
    chart.setBackgroundPaint(new Color(0xCC, 0xFF, 0xCC));

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);
    plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    final CategoryItemRenderer renderer1 = plot.getRenderer();
    renderer1.setSeriesPaint(0, Color.red);
    renderer1.setSeriesPaint(1, Color.yellow);
    renderer1.setSeriesPaint(2, Color.green);
    BarRenderer br = (BarRenderer) renderer1;
    br.setShadowVisible(false);

    br.setShadowVisible(false);
    BufferedImage bi = chart.createBufferedImage(900, 1500, BufferedImage.TRANSLUCENT, null);
    byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);
    AImage image = new AImage("Bar Chart", bytes);
    chartImg.setContent(image);
    btnExport.setDisabled(false);
  }
 private JFreeChart formChart() {
   DefaultCategoryDataset data = new DefaultCategoryDataset();
   String dateString = request.getParameter("date");
   Date date = null;
   if (dateString != null && (!dateString.equals("null"))) {
     date = DayTransformer.transform(dateString);
   } else {
     date = new Date(System.currentTimeMillis());
   }
   String[][] storeSellingDis =
       saleperformanceManage.getStoreSellingDis(DayTransformer.transformToMonth(date));
   for (int i = 0; i < storeSellingDis.length; i++) {
     data.setValue(
         Double.parseDouble(storeSellingDis[i][1]), storeSellingDis[i][0], storeSellingDis[i][0]);
   }
   JFreeChart barChart =
       ChartFactory.createBarChart(
           "店铺销售分布图", "店铺名称", "销售额", data, PlotOrientation.VERTICAL, true, true, false);
   CategoryPlot plot = (CategoryPlot) barChart.getCategoryPlot();
   BarRenderer renderer = (BarRenderer) plot.getRenderer();
   // 显示条目标签
   renderer.setBaseItemLabelsVisible(true);
   // 设置条目标签生成器,在JFreeChart1.0.6之前可以通过renderer.setItemLabelGenerator(CategoryItemLabelGenerator
   // generator)方法实现,但是从版本1.0.6开始有下面方法代替
   renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
   // 设置条目标签显示的位置,outline表示在条目区域外,baseline_center表示基于基线且居中
   renderer.setBasePositiveItemLabelPosition(
       new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
   barChart.getLegend().setItemFont(new Font("黑体", Font.BOLD, 15)); // 设置引用标签字体
   barChart.getTitle().setFont(new Font("华文行楷", Font.BOLD, 32));
   return barChart;
 }
Пример #10
0
  /**
   * Creates a sample chart.
   *
   * @param dataset the dataset.
   * @return The chart.
   */
  private static JFreeChart createchart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart =
        ChartFactory.createBarChart(
            "Bar Chart Demo 1", // chart
            // title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
            );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    // ******************************************************************
    // More than 150 demo applications are included with the JFreeChart
    // Developer Guide...for more information, see:
    //
    // > http://www.object-refinery.com/jfreechart/guide.html
    //
    // ******************************************************************

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    // renderer.setDrawBarOutline(false);

    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(
        CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;
  }
Пример #11
0
 /** Check that setting a tool tip generator for a series does override the default generator. */
 public void testSetSeriesToolTipGenerator() {
   CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
   CategoryItemRenderer renderer = plot.getRenderer();
   StandardCategoryToolTipGenerator tt = new StandardCategoryToolTipGenerator();
   renderer.setSeriesToolTipGenerator(0, tt);
   CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0);
   assertTrue(tt2 == tt);
 }
Пример #12
0
 /** Check that setting a URL generator for a series does override the default generator. */
 public void testSetSeriesURLGenerator() {
   CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
   CategoryItemRenderer renderer = plot.getRenderer();
   StandardCategoryURLGenerator url1 = new StandardCategoryURLGenerator();
   renderer.setSeriesItemURLGenerator(0, url1);
   CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0);
   assertTrue(url2 == url1);
 }
Пример #13
0
    protected void configurePlot(CategoryPlot plot) {
      plot.setBackgroundPaint(Color.WHITE);
      plot.setOutlinePaint(null);
      plot.setRangeGridlinesVisible(true);
      plot.setRangeGridlinePaint(Color.black);

      configureRenderer((LineAndShapeRenderer) plot.getRenderer());
      configureDomainAxis(plot);
    }
Пример #14
0
  /**
   * Draws the axis on a Java 2D graphics device (such as the screen or a printer).
   *
   * @param g2 the graphics device (<code>null</code> not permitted).
   * @param cursor the cursor location.
   * @param plotArea the area within which the axis should be drawn (<code>null</code> not
   *     permitted).
   * @param dataArea the area within which the plot is being drawn (<code>null</code> not
   *     permitted).
   * @param edge the location of the axis (<code>null</code> not permitted).
   * @param plotState collects information about the plot (<code>null</code> permitted).
   * @return the axis state (never <code>null</code>).
   */
  public AxisState draw(
      Graphics2D g2,
      double cursor,
      Rectangle2D plotArea,
      Rectangle2D dataArea,
      RectangleEdge edge,
      PlotRenderingInfo plotState) {

    // if the axis is not visible, don't draw it...
    if (!isVisible()) {
      return new AxisState(cursor);
    }

    // calculate the adjusted data area taking into account the 3D effect...
    // this assumes that there is a 3D renderer, all this 3D effect is a bit of an
    // ugly hack...
    CategoryPlot plot = (CategoryPlot) getPlot();

    Rectangle2D adjustedDataArea = new Rectangle2D.Double();
    if (plot.getRenderer() instanceof Effect3D) {
      Effect3D e3D = (Effect3D) plot.getRenderer();
      double adjustedX = dataArea.getMinX();
      double adjustedY = dataArea.getMinY();
      double adjustedW = dataArea.getWidth() - e3D.getXOffset();
      double adjustedH = dataArea.getHeight() - e3D.getYOffset();

      if (edge == RectangleEdge.LEFT || edge == RectangleEdge.BOTTOM) {
        adjustedY += e3D.getYOffset();
      } else if (edge == RectangleEdge.RIGHT || edge == RectangleEdge.TOP) {
        adjustedX += e3D.getXOffset();
      }
      adjustedDataArea.setRect(adjustedX, adjustedY, adjustedW, adjustedH);
    } else {
      adjustedDataArea.setRect(dataArea);
    }

    // draw the category labels and axis label
    AxisState state = new AxisState(cursor);
    state = drawCategoryLabels(g2, plotArea, adjustedDataArea, edge, state, plotState);
    state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state);

    return state;
  }
Пример #15
0
  @Override
  protected void formatPlot(Plot plot) {
    CategoryPlot cPlot = (CategoryPlot) plot;
    cPlot.setBackgroundPaint(format.getBackgroundColor());
    cPlot.setRangeGridlinePaint(format.getGridColor());
    cPlot.setDomainGridlinePaint(format.getGridColor());

    formatRenderer((BarRenderer) cPlot.getRenderer());
    setRange();
  }
Пример #16
0
  /**
   * This method renders the chart given a dataset on the respective panel
   *
   * @param dataset
   * @param type (0: Assets, 1: Liabilities, 2: Income, 3: Expense)
   */
  private ChartPanel renderBarChart(DefaultCategoryDataset dataset, int type) {

    // Customize the chart's title
    String title = "";
    switch (type) {
      case 0:
        title = "Assets";
        break;
      case 1:
        title = "Liabilities";
        break;
      case 2:
        title = "Income";
        break;
      case 3:
        title = "Expenses";
        break;
    }

    // Create JFreeChart with dataSet
    JFreeChart newChart =
        ChartFactory.createBarChart(
            title, "Categories", "Amount", dataset, PlotOrientation.VERTICAL, false, true, false);

    // Change the chart's visual properties
    CategoryPlot chartPlot = newChart.getCategoryPlot();
    chartPlot.setBackgroundPaint(Color.WHITE); // to set the background color of the chart as white
    BarRenderer chartRenderer = (BarRenderer) chartPlot.getRenderer();

    // Customize the chart's color
    switch (type) {
      case 0:
        chartRenderer.setSeriesPaint(0, new Color(50, 170, 20));
        break;
      case 1:
        chartRenderer.setSeriesPaint(0, new Color(200, 30, 20));
        break;
      case 2:
        chartRenderer.setSeriesPaint(0, new Color(13, 92, 166));
        break;
      case 3:
        chartRenderer.setSeriesPaint(0, new Color(255, 205, 50));
        break;
    }
    chartRenderer.setBarPainter(new StandardBarPainter()); // to disable the default 'shiny look'

    // Create the chart panel
    ChartPanel newChartPanel =
        new ChartPanel(newChart, 350, 200, 200, 100, 800, 300, true, true, true, true, true, true);
    newChartPanel.setSize(270, 200);

    return newChartPanel;
  }
Пример #17
0
  private JFreeChart createChart(final CategoryDataset dataset) {

    final JFreeChart chart =
        ChartFactory.createLineChart(
            "Daily Stock Report", // chart title
            "Type", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
            );
    chart.setBackgroundPaint(Color.white);
    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);
    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
    // customise the range axis...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(true);
    final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesStroke(
        0,
        new BasicStroke(
            2.0f,
            BasicStroke.CAP_ROUND,
            BasicStroke.JOIN_ROUND,
            1.0f,
            new float[] {10.0f, 6.0f},
            0.0f));
    renderer.setSeriesStroke(
        1,
        new BasicStroke(
            2.0f,
            BasicStroke.CAP_ROUND,
            BasicStroke.JOIN_ROUND,
            1.0f,
            new float[] {6.0f, 6.0f},
            0.0f));
    renderer.setSeriesStroke(
        2,
        new BasicStroke(
            2.0f,
            BasicStroke.CAP_ROUND,
            BasicStroke.JOIN_ROUND,
            1.0f,
            new float[] {2.0f, 6.0f},
            0.0f));
    return chart;
  }
Пример #18
0
  /**
   * Draws the axis on a Java 2D graphics device (such as the screen or a printer).
   *
   * @param g2 the graphics device.
   * @param cursor the cursor.
   * @param plotArea the area for drawing the axes and data.
   * @param dataArea the area for drawing the data (a subset of the plotArea).
   * @param edge the axis location.
   * @param plotState collects information about the plot (<code>null</code> permitted).
   * @return The updated cursor value.
   */
  public AxisState draw(
      Graphics2D g2,
      double cursor,
      Rectangle2D plotArea,
      Rectangle2D dataArea,
      RectangleEdge edge,
      PlotRenderingInfo plotState) {

    // if the axis is not visible, don't draw it...
    if (!isVisible()) {
      AxisState state = new AxisState(cursor);
      // even though the axis is not visible, we need ticks for the
      // gridlines...
      List ticks = refreshTicks(g2, state, dataArea, edge);
      state.setTicks(ticks);
      return state;
    }

    // calculate the adjusted data area taking into account the 3D effect...
    double xOffset = 0.0;
    double yOffset = 0.0;
    Plot plot = getPlot();
    if (plot instanceof CategoryPlot) {
      CategoryPlot cp = (CategoryPlot) plot;
      CategoryItemRenderer r = cp.getRenderer();
      if (r instanceof Effect3D) {
        Effect3D e3D = (Effect3D) r;
        xOffset = e3D.getXOffset();
        yOffset = e3D.getYOffset();
      }
    }

    double adjustedX = dataArea.getMinX();
    double adjustedY = dataArea.getMinY();
    double adjustedW = dataArea.getWidth() - xOffset;
    double adjustedH = dataArea.getHeight() - yOffset;

    if (edge == RectangleEdge.LEFT || edge == RectangleEdge.BOTTOM) {
      adjustedY += yOffset;
    } else if (edge == RectangleEdge.RIGHT || edge == RectangleEdge.TOP) {
      adjustedX += xOffset;
    }
    Rectangle2D adjustedDataArea =
        new Rectangle2D.Double(adjustedX, adjustedY, adjustedW, adjustedH);

    // draw the tick marks and labels...
    AxisState info = drawTickMarksAndLabels(g2, cursor, plotArea, adjustedDataArea, edge);

    // draw the axis label...
    info = drawLabel(getLabel(), g2, plotArea, dataArea, edge, info);

    return info;
  }
Пример #19
0
  public JFreeChart createChart(int size) {
    CategoryDataset paramCategoryDataset = createDataset(size);
    // 创建主题样式
    StandardChartTheme standardChartTheme = new StandardChartTheme("CN");
    // 设置标题字体
    standardChartTheme.setExtraLargeFont(new Font("隶书", Font.BOLD, 20));
    // 设置图例的字体
    standardChartTheme.setRegularFont(new Font("宋书", Font.PLAIN, 12));
    // 设置轴向的字体
    standardChartTheme.setLargeFont(new Font("宋书", Font.PLAIN, 12));
    // 应用主题样式
    ChartFactory.setChartTheme(standardChartTheme);
    JFreeChart localJFreeChart =
        ChartFactory.createLineChart(
            title, "期号", yTitle, paramCategoryDataset, PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot localCategoryPlot = (CategoryPlot) localJFreeChart.getPlot();
    //		SymbolAxis localSymbolAxis = new SymbolAxis("个数", new String[] {
    //				"0", "1", "2", "3", "4", "5", "6" });
    //		localCategoryPlot.setRangeAxis(localSymbolAxis);
    ChartUtilities.applyCurrentTheme(localJFreeChart);
    LineAndShapeRenderer xyitem = (LineAndShapeRenderer) localCategoryPlot.getRenderer();
    CategoryPlot plot = (CategoryPlot) localJFreeChart.getPlot();
    // 设置网格背景颜色
    plot.setBackgroundPaint(Color.white);
    // 设置网格竖线颜色
    plot.setDomainGridlinePaint(Color.black);
    // 设置网格横线颜色
    plot.setRangeGridlinePaint(Color.black);
    // 设置曲线图与xy轴的距离
    plot.setAxisOffset(new RectangleInsets(0D, 0D, 0D, 0D));

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(true);
    if ("和值".equals(type)) {
      rangeAxis.setLowerBound(70);
      rangeAxis.setTickUnit(new NumberTickUnit(10));
    } else {
      rangeAxis.setLowerBound(0);
      rangeAxis.setTickUnit(new NumberTickUnit(1));
    }
    //		rangeAxis.setUpperMargin(0.20);
    // 设置曲线显示各数据点的值
    xyitem.setBaseItemLabelsVisible(true);
    xyitem.setBasePositiveItemLabelPosition(
        new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
    xyitem.setSeriesStroke(0, new BasicStroke(1.5F));
    xyitem.setBaseItemLabelFont(new Font("Dialog", 1, 14));
    xyitem.setSeriesShapesVisible(0, true);
    plot.setRenderer(xyitem);
    return localJFreeChart;
  }
Пример #20
0
  @Override
  protected JFreeChart createGraph() {
    final JFreeChart chart =
        ChartFactory.createLineChart(
            null, // chart title
            null, // unused
            yLabel, // range axis label
            categoryDataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
            );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    final LegendTitle legend = chart.getLegend();
    legend.setPosition(RectangleEdge.RIGHT);

    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.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();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLowerBound(0);
    rangeAxis.setAutoRange(true);

    final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseStroke(new BasicStroke(2.0f));
    ColorPalette.apply(renderer);

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

    return chart;
  }
 protected JFreeChart createStackedBar3DChart() throws JRException {
   JFreeChart jfreeChart = super.createStackedBar3DChart();
   CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot();
   BarRenderer3D barRenderer3D = (BarRenderer3D) categoryPlot.getRenderer();
   barRenderer3D.setWallPaint(ChartThemesConstants.TRANSPARENT_PAINT);
   barRenderer3D.setItemMargin(0);
   CategoryDataset categoryDataset = categoryPlot.getDataset();
   if (categoryDataset != null) {
     for (int i = 0; i < categoryDataset.getRowCount(); i++) {
       barRenderer3D.setSeriesOutlinePaint(i, ChartThemesConstants.TRANSPARENT_PAINT);
     }
   }
   return jfreeChart;
 }
  /**
   * Erstellt ein Stabdiagramm aus den Parametern.
   *
   * @param dataset Datenset
   * @param titel Titel
   * @return {@link JFreeChart}
   */
  protected JFreeChart erstelleDiagramm(
      CategoryDataset dataset,
      String titel,
      String reihenBeschriftung,
      String spaltenBeschriftung) {
    // create the chart...
    JFreeChart chart =
        ChartFactory.createBarChart3D(
            titel,
            reihenBeschriftung,
            spaltenBeschriftung,
            dataset,
            PlotOrientation.VERTICAL,
            true,
            true,
            false);

    TextTitle t = chart.getTitle();
    t.setHorizontalAlignment(HorizontalAlignment.CENTER);
    t.setFont(new Font("Arial", Font.CENTER_BASELINE, 26));

    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    for (int i = 0; i < parteienListe.size(); i++) {
      if (parteienListe.get(i).getFarbe() != null) {
        GradientPaint gp =
            new GradientPaint(
                0.0f,
                0.0f,
                parteienListe.get(i).getFarbe(),
                0.0f,
                0.0f,
                new Color(parteienListe.get(i).getFarbe().getRGB()));
        renderer.setSeriesPaint(i, gp);
      }
    }

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(
        CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    return chart;
  }
Пример #23
0
  /**
   * Method returns a constructed, fully customised chart.
   *
   * @param dataset - dataset from the de-serialized Statistics object
   * @return JFreeChart chart
   */
  private static JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart =
        ChartFactory.createBarChart(
            "Time taken/Cells covered Performance", // Title of the chart
            "", // X Axis label
            "Time taken", // Y axis label
            dataset, // Data used for the chart
            PlotOrientation.VERTICAL, // Orientation of the chart to be drawn
            false, // Legend
            true, // Tooltips
            false // URL
            );

    // Display an additional label undeneath the bar chart to tell the user to hover over the bar
    // chart to see more deatils
    TextTitle legendText = new TextTitle("* Hover over the bar to see the cells covered.");
    legendText.setPosition(RectangleEdge.BOTTOM);
    chart.addSubtitle(legendText);

    // Background for the chart
    chart.setBackgroundPaint(Color.white);

    // Store reference to the plot to customise it
    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    // Y axis should display integers only (so that the time taken is given in second integers)
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    // Set the colours for the graphs
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));

    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    // Set up the X axis so that the title appears diagonal
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(
        CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));

    return chart;
  }
  public void createChart() {

    CategoryDataset categorydataset = (CategoryDataset) this.datasetStrategy.getDataset();
    report =
        ChartFactory.createStackedBarChart(
            this.datasetStrategy.getTitle(),
            this.datasetStrategy.getYAxisLabel(),
            this.datasetStrategy.getXAxisLabel(),
            categorydataset,
            PlotOrientation.HORIZONTAL,
            true,
            true,
            false);
    // report.setBackgroundPaint( Color.lightGray );
    report.setAntiAlias(false);
    report.setPadding(new RectangleInsets(5.0d, 5.0d, 5.0d, 5.0d));
    CategoryPlot categoryplot = (CategoryPlot) report.getPlot();
    categoryplot.setBackgroundPaint(Color.white);
    categoryplot.setRangeGridlinePaint(Color.lightGray);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    if (datasetStrategy instanceof CloverBarChartStrategy
        || datasetStrategy instanceof MultiCloverBarChartStrategy) {
      numberaxis.setRange(0.0D, StackedBarChartRenderer.NUMBER_AXIS_RANGE);
      numberaxis.setNumberFormatOverride(NumberFormat.getPercentInstance());
    } else {
      numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }
    numberaxis.setLowerMargin(0.0D);
    StackedBarRenderer stackedbarrenderer = (StackedBarRenderer) categoryplot.getRenderer();
    stackedbarrenderer.setDrawBarOutline(false);
    stackedbarrenderer.setItemLabelsVisible(true);
    stackedbarrenderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    stackedbarrenderer.setItemLabelFont(
        StackedBarRenderer.DEFAULT_VALUE_LABEL_FONT.deriveFont(Font.BOLD));
    int height =
        (categorydataset.getColumnCount() * ChartUtils.STANDARD_BARCHART_ENTRY_HEIGHT * 2)
            + ChartUtils.STANDARD_BARCHART_ADDITIONAL_HEIGHT
            + 10;
    if (height > ChartUtils.MINIMUM_HEIGHT) {
      super.setHeight(height);
    } else {
      super.setHeight(ChartUtils.MINIMUM_HEIGHT);
    }
    Paint[] paints = this.datasetStrategy.getPaintColor();

    for (int i = 0; i < categorydataset.getRowCount() && i < paints.length; i++) {
      stackedbarrenderer.setSeriesPaint(i, paints[i]);
    }
  }
Пример #25
0
  /**
   * Creates a sample chart.
   *
   * @param dataset the dataset.
   * @return The chart.
   */
  private JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart =
        ChartFactory.createBarChart(
            "", // chart
            // title
            xLabel, // domain axis label
            yLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
            );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(
        CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0));
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;
  }
Пример #26
0
  /**
   * Helper to set color of series. If the parameter colorsHex is null, then default Sonar colors
   * are used.
   */
  protected void configureColors(Values2D dataset, CategoryPlot plot, String[] colorsHex) {
    Color[] colors = COLORS;
    if (colorsHex != null && colorsHex.length > 0) {
      colors = new Color[colorsHex.length];
      for (int i = 0; i < colorsHex.length; i++) {
        colors[i] = Color.decode("#" + colorsHex[i]);
      }
    }

    dataset.getColumnCount();
    AbstractRenderer renderer = (AbstractRenderer) plot.getRenderer();
    for (int i = 0; i < dataset.getColumnCount(); i++) {
      renderer.setSeriesPaint(i, colors[i % colors.length]);
    }
  }
Пример #27
0
 private static JFreeChart createChart(CategoryDataset categorydataset, String title) {
   JFreeChart jfreechart =
       ChartFactory.createStackedBarChart(
           title, "分类:区域", "短信数", categorydataset, PlotOrientation.HORIZONTAL, true, true, false);
   jfreechart.setBackgroundPaint(Color.white);
   CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
   categoryplot.setBackgroundPaint(Color.lightGray);
   categoryplot.setRangeGridlinePaint(Color.white);
   categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
   StackedBarRenderer stackedbarrenderer = (StackedBarRenderer) categoryplot.getRenderer();
   stackedbarrenderer.setDrawBarOutline(false);
   stackedbarrenderer.setMaximumBarWidth(0.1);
   stackedbarrenderer.setItemLabelsVisible(true);
   return jfreechart;
 }
  protected JFreeChart createGanttChart() throws JRException {

    JFreeChart jfreeChart = super.createGanttChart();
    CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot();
    categoryPlot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.STANDARD);
    categoryPlot.setDomainGridlinesVisible(true);
    categoryPlot.setDomainGridlinePosition(CategoryAnchor.END);
    categoryPlot.setDomainGridlineStroke(
        new BasicStroke(
            0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] {1}, 0));

    categoryPlot.setDomainGridlinePaint(ChartThemesConstants.GRAY_PAINT_217);

    categoryPlot.setRangeGridlinesVisible(true);
    categoryPlot.setRangeGridlineStroke(
        new BasicStroke(
            0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 50, new float[] {1}, 0));

    categoryPlot.setRangeGridlinePaint(ChartThemesConstants.GRAY_PAINT_217);
    //		JRBarPlot barPlot = (BarPlot)categoryPlot;
    //		categoryPlot.getDomainAxis().setTickLabelsVisible(
    //				categoryPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels().
    //				true
    //				);
    CategoryItemRenderer categoryRenderer = categoryPlot.getRenderer();
    categoryRenderer.setBaseItemLabelsVisible(true);
    BarRenderer barRenderer = (BarRenderer) categoryRenderer;
    List seriesPaints =
        (List) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS);
    barRenderer.setSeriesPaint(0, (Paint) seriesPaints.get(3));
    barRenderer.setSeriesPaint(1, (Paint) seriesPaints.get(0));
    CategoryDataset categoryDataset = categoryPlot.getDataset();
    if (categoryDataset != null) {
      for (int i = 0; i < categoryDataset.getRowCount(); i++) {
        barRenderer.setSeriesItemLabelFont(i, categoryPlot.getDomainAxis().getTickLabelFont());
        barRenderer.setSeriesItemLabelsVisible(i, true);
        //			barRenderer.setSeriesPaint(i, GRADIENT_PAINTS[i]);
        //			CategoryMarker categoryMarker = new
        // CategoryMarker(categoryDataset.getColumnKey(i),MARKER_COLOR, new BasicStroke(1f));
        //			categoryMarker.setAlpha(0.5f);
        //			categoryPlot.addDomainMarker(categoryMarker, Layer.BACKGROUND);
      }
    }
    categoryPlot.setOutlinePaint(Color.DARK_GRAY);
    categoryPlot.setOutlineStroke(new BasicStroke(1.5f));
    categoryPlot.setOutlineVisible(true);
    return jfreeChart;
  }
Пример #29
0
  /**
   * Creates a sample chart.
   *
   * @param dataset the dataset.
   * @return The chart.
   */
  private static JFreeChart createChart(CategoryDataset dataset) {

    // create the chart...
    JFreeChart chart =
        ChartFactory.createBarChart(
            "SubCategoryAxis Demo 1", // chart title
            "Category", // domain axis label
            "Value", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
            );

    // get a reference to the plot for further customisation...
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    SubCategoryAxis axis = new SubCategoryAxis(null);
    axis.addSubCategory("S1");
    axis.addSubCategory("S2");
    axis.addSubCategory("S3");
    plot.setDomainAxis(axis);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // disable bar outlines...
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);

    ChartUtilities.applyCurrentTheme(chart);

    // set up gradient paints for series...
    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    return chart;
  }
Пример #30
0
  private JFreeChart getBarChart() {
    // Load the data, if necessary
    loadData();

    // Create the vertical bar chart
    final JFreeChart chart =
        ChartFactory.createBarChart(
            getTitle(),
            "",
            "",
            getCategoryDataset(),
            PlotOrientation.HORIZONTAL,
            false,
            true,
            false);
    final CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
    categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    categoryplot.setRangePannable(true);
    categoryplot.setNoDataMessage("No data available");

    final BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setItemLabelAnchorOffset(9D);
    barrenderer.setBaseItemLabelsVisible(true);
    barrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    // barrenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator("{1} = {2}", new
    // DecimalFormat("0")));
    final CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryMargin(0.25D);

    categoryaxis.setUpperMargin(0.02D);
    categoryaxis.setLowerMargin(0.02D);
    final NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setUpperMargin(0.10000000000000001D);
    ChartUtilities.applyCurrentTheme(chart);

    //    if (useLegend())
    //    {
    //      // pieplot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator("{0} ({1})"));
    //      chart.getLegend().setPosition(RectangleEdge.RIGHT);
    //      // pieplot.setLegendLabelToolTipGenerator(new StandardPieSectionLabelGenerator("{0}:
    // {2}%"));
    //    }

    return chart;
  }