Example usage for org.jfree.chart.renderer.category BarRenderer setItemLabelGenerator

List of usage examples for org.jfree.chart.renderer.category BarRenderer setItemLabelGenerator

Introduction

In this page you can find the example usage for org.jfree.chart.renderer.category BarRenderer setItemLabelGenerator.

Prototype

@Override
public void setItemLabelGenerator(CategoryItemLabelGenerator generator) 

Source Link

Document

Sets the item label generator for ALL series and sends a RendererChangeEvent to all registered listeners.

Usage

From source file:fr.paris.lutece.plugins.form.business.GraphTypeBarChart.java

/**
* return the JFreeChart BarChart graph/*from  w  w w .j  a  va  2s  .c o m*/
* @param listStatistic listStatistic
* @param strGraphTitle graph title
* @param nGraphThreeDimension true if the graph must be in three dimension
* @param nGraphLabelValue true if the labels must appear in the graph
* @return the JFreeChart graph associate to the graph type
*/

//Cration de l'histogramme
public static JFreeChart createBarChart(List<StatisticEntrySubmit> listStatistic, String strGraphTitle,
        boolean nGraphThreeDimension, boolean nGraphLabelValue) {
    JFreeChart chart;
    CategoryDataset dataset = createBarChartDataset(listStatistic);

    if (nGraphThreeDimension) {
        chart = ChartFactory.createBarChart3D(strGraphTitle, null, null, dataset, PlotOrientation.VERTICAL,
                true, false, false);
    } else {
        chart = ChartFactory.createBarChart(strGraphTitle, null, null, dataset, PlotOrientation.VERTICAL, true,
                false, false);
    }

    CategoryPlot categoryPlot = chart.getCategoryPlot();
    CategoryAxis categoryAxis = categoryPlot.getDomainAxis();
    CategoryLabelPositions labelPositions = CategoryLabelPositions.UP_45;
    categoryAxis.setCategoryLabelPositions(labelPositions);

    BarRenderer renderer = (BarRenderer) categoryPlot.getRenderer();

    if (nGraphLabelValue) {
        renderer.setItemLabelsVisible(true);

        DecimalFormat decimalformat1 = new DecimalFormat("#.#");
        renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", decimalformat1));

        if (nGraphThreeDimension) {
            renderer.setPositiveItemLabelPositionFallback(
                    new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.BASELINE_LEFT));
            categoryPlot.setRenderer(renderer);
        }
    }

    return chart;
}

From source file:org.jrecruiter.web.actions.admin.ShowStatisticsAction.java

private static JFreeChart createChart(final CategoryDataset categorydataset, final String chartTitle) {
    final JFreeChart chart = ChartFactory.createBarChart(chartTitle, "Jobs", "Number of Hits", categorydataset,
            PlotOrientation.VERTICAL, true, true, false);

    final CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
    categoryplot.setNoDataMessage("NO DATA!");

    chart.setBackgroundPaint(new Color(245, 245, 255));
    chart.setBorderPaint(new Color(204, 204, 204));
    chart.setBorderStroke(new BasicStroke(1f));

    final LegendTitle legend = chart.getLegend();
    legend.setWidth(1000);/*  w ww. j a va  2s. c o m*/
    legend.setPosition(RectangleEdge.BOTTOM);

    final BlockBorder border = new BlockBorder(new Color(204, 204, 204));
    legend.setBorder(border);

    final CategoryPlot categoryPlot = (CategoryPlot) chart.getPlot();
    categoryPlot.setBackgroundPaint(Color.WHITE);
    categoryPlot.setRangeGridlinePaint(new Color(204, 204, 204));
    categoryPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    final NumberAxis numberaxis = (NumberAxis) categoryPlot.getRangeAxis();

    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    final BarRenderer renderer = (BarRenderer) categoryPlot.getRenderer();
    renderer.setDrawBarOutline(true);

    final ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.CENTER,
            TextAnchor.CENTER);
    renderer.setPositiveItemLabelPosition(itemlabelposition);

    renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());

    renderer.setItemLabelsVisible(true);
    return chart;
}

From source file:org.bonitasoft.simulation.reporting.jasperreport.BarChartVisibleBarLabel.java

public void customize(JFreeChart chart, JRChart jasperChart) {

    BarRenderer bsr = (BarRenderer) chart.getCategoryPlot().getRenderer();
    bsr.setItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    bsr.setItemLabelsVisible(true);/*from  w  ww.  j av  a  2 s  .c o  m*/
    // Set position of Items label : center
    bsr.setPositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
    bsr.setNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER));
    // If there isn't enough space to draw the ItemLabel...
    bsr.setPositiveItemLabelPositionFallback(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.CENTER));
    bsr.setNegativeItemLabelPositionFallback(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.CENTER));
}

From source file:org.neo4j.bench.chart.JFreeBarChart.java

@Override
protected JFreeChart createChart(AbstractDataset dataset) {
    JFreeChart chart = ChartFactory.createBarChart("Performance chart", "Bench case", "Time(s)",
            (DefaultCategoryDataset) dataset, PlotOrientation.VERTICAL, true, true, false);

    rotateCategoryAxis(chart, Math.PI / 4.0);
    CategoryPlot plot = chart.getCategoryPlot();
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setItemLabelGenerator(new CategoryItemLabelGenerator() {
        public String generateColumnLabel(CategoryDataset dataset, int column) {
            return "col" + column;
        }/*  w w  w .jav a 2  s .c  o m*/

        public String generateLabel(CategoryDataset dataset, int row, int column) {
            return "" + dataset.getValue(row, column).intValue();
        }

        public String generateRowLabel(CategoryDataset dataset, int row) {
            return "row" + row;
        }
    });
    renderer.setBaseItemLabelPaint(Color.black);
    renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE12,
            TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, -Math.PI / 2.0));
    renderer.setItemLabelsVisible(true);

    return chart;
}

From source file:nl.strohalm.cyclos.controls.reports.statistics.graphs.ChartPostProcessorImpl.java

/**
 * not in use yet. This method generates labels above each bar. At this very moment, these labels just show the value of the underlying data
 * (which is not very usefull). It could be used to display for example n-values.
 * @param plot//ww w .j a  v  a2s. co  m
 */
@SuppressWarnings("unused")
private void setItemLabels(final CategoryPlot plot) {
    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); // TODO change to a custom ItemLabelGenerator; see JFreeChart
    // developer Guide, version 0.9.18 (april 2004), page 80 and
    // following pages
    renderer.setItemLabelsVisible(true);
    renderer.setItemLabelFont(new Font("SansSerif", Font.PLAIN, 9));
    renderer.setItemLabelPaint(null);
    renderer.setSeriesItemLabelPaint(0, renderer.getSeriesPaint(0));
    renderer.setSeriesItemLabelPaint(1, renderer.getSeriesPaint(1));
}

From source file:reports.util.BarChartScriptlet.java

/**
 *
 *//*from   www.j a va  2  s  .  c  o m*/
public void afterReportInit() throws JRScriptletException {

    JFreeChart jfreechart = ChartFactory.createBarChart3D("Bar Chart Demo", // chart title
            "States", // X Label              
            "Sell Amount", // Y Label 
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips? 
            false // URLs? 
    );

    CategoryPlot categoryplot = jfreechart.getCategoryPlot();
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryLabelPositions(
            CategoryLabelPositions.createUpRotationLabelPositions(0.39269908169872414D));

    LegendTitle legendtitle = (LegendTitle) jfreechart.getSubtitle(0);
    legendtitle.setPosition(RectangleEdge.RIGHT);
    legendtitle.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0.0D, 4D, 0.0D, 4D));

    IntervalMarker intervalmarker = new IntervalMarker(4000D, 5000D);
    intervalmarker.setLabel("Target Range");
    intervalmarker.setLabelFont(new Font("SansSerif", 2, 11));
    intervalmarker.setLabelAnchor(RectangleAnchor.LEFT);
    intervalmarker.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    intervalmarker.setPaint(new Color(222, 222, 255, 128));
    categoryplot.addRangeMarker(intervalmarker, Layer.BACKGROUND);

    CategoryItemRenderer categoryitemrenderer = categoryplot.getRenderer();
    categoryitemrenderer.setItemLabelsVisible(true);
    BarRenderer barrenderer = (BarRenderer) categoryitemrenderer;
    barrenderer.setMaxBarWidth(0.050000000000000003D);

    barrenderer.setItemLabelGenerator(new LabelGenerator());
    barrenderer.setItemLabelsVisible(true);

    ItemLabelPosition itemlabelposition1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
            TextAnchor.CENTER_LEFT, TextAnchor.CENTER_LEFT, -1.5707963267948966D);
    barrenderer.setPositiveItemLabelPositionFallback(itemlabelposition1);

    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);

    /*
    jfreechart.setBackgroundPaint(Color.white); 
    CategoryPlot categoryplot = jfreechart.getCategoryPlot();
    categoryplot.setBackgroundPaint(Color.lightGray); 
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setRangeGridlinePaint(Color.white);
    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);
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D));
       */
    this.setVariableValue("Chart", new JCommonDrawableRenderer(jfreechart));
}

From source file:edu.indiana.htrc.visual.HTRCBarChartDrawer.java

@Override
public File draw() {

    System.out.println("draw bar!!!!!!!!!!!!!");

    DefaultCategoryDataset bar_dataset = new DefaultCategoryDataset();
    /*dataset.setValue(6, "Profit", "Jane");
    dataset.setValue(7, "Profit", "Tom");
    dataset.setValue(8, "Profit", "Jill");
    dataset.setValue(5, "Profit", "John");
    dataset.setValue(12, "Profit", "Fred");*/
    Set<String> key_set = input_map.keySet();
    Iterator<String> iter = key_set.iterator();

    while (iter.hasNext()) {
        String key = iter.next();
        int value = input_map.get(key);
        bar_dataset.setValue(value, dataset_label, key);
    }// ww  w.  j  av a 2  s . c o m

    JFreeChart chart = null;
    if (is3D) {
        chart = ChartFactory.createBarChart3D(chart_name, x_axis_label, y_axis_label, bar_dataset,
                PlotOrientation.VERTICAL, true, true, false);
    } else {
        chart = ChartFactory.createBarChart(chart_name, x_axis_label, y_axis_label, bar_dataset,
                PlotOrientation.VERTICAL, true, true, false);
    }

    CategoryPlot p = chart.getCategoryPlot();
    /*  NumberAxis rangeAxis = (NumberAxis) p.getRangeAxis();
      rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());*/
    BarRenderer renderer = (BarRenderer) p.getRenderer();
    DecimalFormat decimalformat1 = new DecimalFormat("##");

    StandardCategoryItemLabelGenerator label_generator = new StandardCategoryItemLabelGenerator("{2}",
            decimalformat1);

    renderer.setItemLabelGenerator(label_generator);

    final ItemLabelPosition pos = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE1, TextAnchor.CENTER_RIGHT,
            TextAnchor.CENTER_RIGHT, 0/* -Math.PI / 2.0*/
    );
    renderer.setPositiveItemLabelPosition(pos);
    final CategoryAxis domainAxis = p.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    renderer.setMaximumBarWidth(.15);
    renderer.setItemLabelsVisible(true);
    chart.getCategoryPlot().setRenderer(renderer);
    File img = new File("../webapps/HTRC-UI-AuditAnalyzer/images/" + System.currentTimeMillis() + ".jpg");

    try {
        ChartUtilities.saveChartAsJPEG(img, chart, 1400, 600);
    } catch (IOException e) {
        System.err.println("Problem occurred creating chart.");
    }
    return img;
}

From source file:com.pusksesmas.form_statistik.statistik_obat_masuk.java

private void tabelDataMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabelDataMouseClicked

    if (vpil.getSelectedIndex() == 1) {
        int row = tabelData.getSelectedRow();
        String namaObat = (tabelData.getModel().getValueAt(row, 0)).toString();
        String jan = (tabelData.getModel().getValueAt(row, 1)).toString();
        String feb = (tabelData.getModel().getValueAt(row, 2)).toString();
        String mar = (tabelData.getModel().getValueAt(row, 3)).toString();
        String apr = (tabelData.getModel().getValueAt(row, 4)).toString();
        String mei = (tabelData.getModel().getValueAt(row, 5)).toString();
        String jun = (tabelData.getModel().getValueAt(row, 6)).toString();
        String jul = (tabelData.getModel().getValueAt(row, 7)).toString();
        String agus = (tabelData.getModel().getValueAt(row, 8)).toString();
        String sept = (tabelData.getModel().getValueAt(row, 9)).toString();
        String okt = (tabelData.getModel().getValueAt(row, 10)).toString();
        String nov = (tabelData.getModel().getValueAt(row, 11)).toString();
        String des = (tabelData.getModel().getValueAt(row, 12)).toString();

        DefaultCategoryDataset pieDataset = new DefaultCategoryDataset();
        //        pieDataset.setValue("Diagnosa", new Integer(jan));
        pieDataset.setValue(new Integer(jan), "", "Januari");
        pieDataset.setValue(new Integer(feb), "", "Februari");
        pieDataset.setValue(new Integer(mar), "", "Maret");
        pieDataset.setValue(new Integer(apr), "", "April");
        pieDataset.setValue(new Integer(mei), "", "Mei");
        pieDataset.setValue(new Integer(jun), "", "Juni");
        pieDataset.setValue(new Integer(jul), "", "Juli");
        pieDataset.setValue(new Integer(agus), "", "Agustus");
        pieDataset.setValue(new Integer(sept), "", "September");
        pieDataset.setValue(new Integer(okt), "", "Oktober");
        pieDataset.setValue(new Integer(nov), "", "November");
        pieDataset.setValue(new Integer(des), "", "Desember");
        JFreeChart chart = ChartFactory.createBarChart3D("STATISTIK PENERIMAAN OBAT\nNAMA OBAT: " + namaObat,
                "BULAN", "JUMLAH", (CategoryDataset) pieDataset, PlotOrientation.VERTICAL, false, true, false);
        chart.setBackgroundPaint(Color.yellow);
        chart.getTitle().setPaint(Color.red);

        final CategoryPlot p = chart.getCategoryPlot();

        BarRenderer renderer = (BarRenderer) p.getRenderer();
        DecimalFormat sdf = new DecimalFormat("#,##0");
        renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", sdf));
        p.setRenderer(renderer);//  w w w  .ja  va2 s.  c om
        renderer.setBasePositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER));
        renderer.setItemLabelsVisible(true);
        chart.getCategoryPlot().setRenderer(renderer);

        p.setRangeGridlinePaint(Color.blue);
        ChartFrame frame = new ChartFrame("barchart", chart);
        frame.setVisible(true);
        frame.setLocation(250, 100);
        frame.setSize(800, 600);
    } else if (vpil.getSelectedIndex() == 2) {
        int row = tabelData.getSelectedRow();
        String jan = (tabelData.getModel().getValueAt(row, 1)).toString();
        String feb = (tabelData.getModel().getValueAt(row, 2)).toString();
        String mar = (tabelData.getModel().getValueAt(row, 3)).toString();
        String apr = (tabelData.getModel().getValueAt(row, 4)).toString();
        String mei = (tabelData.getModel().getValueAt(row, 5)).toString();
        String jun = (tabelData.getModel().getValueAt(row, 6)).toString();
        String jul = (tabelData.getModel().getValueAt(row, 7)).toString();
        String agus = (tabelData.getModel().getValueAt(row, 8)).toString();
        String sept = (tabelData.getModel().getValueAt(row, 9)).toString();
        String okt = (tabelData.getModel().getValueAt(row, 10)).toString();
        String nov = (tabelData.getModel().getValueAt(row, 11)).toString();
        String des = (tabelData.getModel().getValueAt(row, 12)).toString();
        DefaultPieDataset pieDataset = new DefaultPieDataset();
        pieDataset.setValue("Januari", new Integer(jan));
        pieDataset.setValue("Februari", new Integer(feb));
        pieDataset.setValue("Maret", new Integer(mar));
        pieDataset.setValue("April", new Integer(apr));
        pieDataset.setValue("Mei", new Integer(mei));
        pieDataset.setValue("Juni", new Integer(jun));
        pieDataset.setValue("Juli", new Integer(jul));
        pieDataset.setValue("Agustus", new Integer(agus));
        pieDataset.setValue("September", new Integer(sept));
        pieDataset.setValue("Oktober", new Integer(okt));
        pieDataset.setValue("November", new Integer(nov));
        pieDataset.setValue("Desember", new Integer(des));
        JFreeChart chart = ChartFactory.createPieChart("STATISTIK PENERIMAAN OBAT", pieDataset, true, true,
                true);
        //        PiePlot3D P = (PiePlot3D)chart.getPlot();
        PiePlot P = (PiePlot) chart.getPlot();
        //P.setForegroundAlpha(TOP_ALIGNMENT);
        ChartFrame frame = new ChartFrame("STATISTIK PENERIMAAN OBAT", chart);
        frame.setVisible(true);
        frame.setLocation(250, 100);
        frame.setSize(800, 600);
    } else {

    }

}

From source file:com.pusksesmas.form_statistik.statistik_diagnosa.java

private void tabelDataMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabelDataMouseClicked

    if (vpil.getSelectedIndex() == 1) {
        int row = tabelData.getSelectedRow();
        String namaPenyakit = (tabelData.getModel().getValueAt(row, 0)).toString();
        String jan = (tabelData.getModel().getValueAt(row, 1)).toString();
        String feb = (tabelData.getModel().getValueAt(row, 2)).toString();
        String mar = (tabelData.getModel().getValueAt(row, 3)).toString();
        String apr = (tabelData.getModel().getValueAt(row, 4)).toString();
        String mei = (tabelData.getModel().getValueAt(row, 5)).toString();
        String jun = (tabelData.getModel().getValueAt(row, 6)).toString();
        String jul = (tabelData.getModel().getValueAt(row, 7)).toString();
        String agus = (tabelData.getModel().getValueAt(row, 8)).toString();
        String sept = (tabelData.getModel().getValueAt(row, 9)).toString();
        String okt = (tabelData.getModel().getValueAt(row, 10)).toString();
        String nov = (tabelData.getModel().getValueAt(row, 11)).toString();
        String des = (tabelData.getModel().getValueAt(row, 12)).toString();

        DefaultCategoryDataset pieDataset = new DefaultCategoryDataset();
        //        pieDataset.setValue("Diagnosa", new Integer(jan));
        pieDataset.setValue(new Integer(jan), "", "Januari");
        pieDataset.setValue(new Integer(feb), "", "Februari");
        pieDataset.setValue(new Integer(mar), "", "Maret");
        pieDataset.setValue(new Integer(apr), "", "April");
        pieDataset.setValue(new Integer(mei), "", "Mei");
        pieDataset.setValue(new Integer(jun), "", "Juni");
        pieDataset.setValue(new Integer(jul), "", "Juli");
        pieDataset.setValue(new Integer(agus), "", "Agustus");
        pieDataset.setValue(new Integer(sept), "", "September");
        pieDataset.setValue(new Integer(okt), "", "Oktober");
        pieDataset.setValue(new Integer(nov), "", "November");
        pieDataset.setValue(new Integer(des), "", "Desember");
        JFreeChart chart = ChartFactory.createBarChart3D(
                "STATISTIK HASIL DIGNOSA\nNAMA PENYAKIT: " + namaPenyakit, "BULAN", "JUMLAH",
                (CategoryDataset) pieDataset, PlotOrientation.VERTICAL, false, true, false);
        chart.setBackgroundPaint(Color.yellow);
        chart.getTitle().setPaint(Color.red);

        final CategoryPlot p = chart.getCategoryPlot();

        BarRenderer renderer = (BarRenderer) p.getRenderer();
        DecimalFormat sdf = new DecimalFormat("#,##0");
        renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", sdf));
        p.setRenderer(renderer);// w  w  w .  j a  v a 2 s.c om
        renderer.setBasePositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER));
        renderer.setItemLabelsVisible(true);
        chart.getCategoryPlot().setRenderer(renderer);

        p.setRangeGridlinePaint(Color.blue);
        ChartFrame frame = new ChartFrame("barchart", chart);
        frame.setVisible(true);
        frame.setLocation(250, 100);
        frame.setSize(800, 600);
    } else if (vpil.getSelectedIndex() == 2) {
        int row = tabelData.getSelectedRow();
        String jan = (tabelData.getModel().getValueAt(row, 1)).toString();
        String feb = (tabelData.getModel().getValueAt(row, 2)).toString();
        String mar = (tabelData.getModel().getValueAt(row, 3)).toString();
        String apr = (tabelData.getModel().getValueAt(row, 4)).toString();
        String mei = (tabelData.getModel().getValueAt(row, 5)).toString();
        String jun = (tabelData.getModel().getValueAt(row, 6)).toString();
        String jul = (tabelData.getModel().getValueAt(row, 7)).toString();
        String agus = (tabelData.getModel().getValueAt(row, 8)).toString();
        String sept = (tabelData.getModel().getValueAt(row, 9)).toString();
        String okt = (tabelData.getModel().getValueAt(row, 10)).toString();
        String nov = (tabelData.getModel().getValueAt(row, 11)).toString();
        String des = (tabelData.getModel().getValueAt(row, 12)).toString();
        DefaultPieDataset pieDataset = new DefaultPieDataset();
        pieDataset.setValue("Januari", new Integer(jan));
        pieDataset.setValue("Februari", new Integer(feb));
        pieDataset.setValue("Maret", new Integer(mar));
        pieDataset.setValue("April", new Integer(apr));
        pieDataset.setValue("Mei", new Integer(mei));
        pieDataset.setValue("Juni", new Integer(jun));
        pieDataset.setValue("Juli", new Integer(jul));
        pieDataset.setValue("Agustus", new Integer(agus));
        pieDataset.setValue("September", new Integer(sept));
        pieDataset.setValue("Oktober", new Integer(okt));
        pieDataset.setValue("November", new Integer(nov));
        pieDataset.setValue("Desember", new Integer(des));
        JFreeChart chart = ChartFactory.createPieChart("STATISTIK HASIL DIGNOSA", pieDataset, true, true, true);
        //        PiePlot3D P = (PiePlot3D)chart.getPlot();
        PiePlot P = (PiePlot) chart.getPlot();
        //P.setForegroundAlpha(TOP_ALIGNMENT);
        ChartFrame frame = new ChartFrame("STATISTIK HASIL DIGNOSA", chart);
        frame.setVisible(true);
        frame.setLocation(250, 100);
        frame.setSize(800, 600);
    } else {

    }

}

From source file:com.pusksesmas.form_statistik.statistik_keuangan_administrasi.java

private void tabelDataMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tabelDataMouseClicked

    if (vpil.getSelectedIndex() == 1) {
        int row = tabelData.getSelectedRow();
        String jan = (tabelData.getModel().getValueAt(row, 0)).toString();
        String feb = (tabelData.getModel().getValueAt(row, 1)).toString();
        String mar = (tabelData.getModel().getValueAt(row, 2)).toString();
        String apr = (tabelData.getModel().getValueAt(row, 3)).toString();
        String mei = (tabelData.getModel().getValueAt(row, 4)).toString();
        String jun = (tabelData.getModel().getValueAt(row, 5)).toString();
        String jul = (tabelData.getModel().getValueAt(row, 6)).toString();
        String agus = (tabelData.getModel().getValueAt(row, 7)).toString();
        String sept = (tabelData.getModel().getValueAt(row, 8)).toString();
        String okt = (tabelData.getModel().getValueAt(row, 9)).toString();
        String nov = (tabelData.getModel().getValueAt(row, 10)).toString();
        String des = (tabelData.getModel().getValueAt(row, 11)).toString();

        DefaultCategoryDataset pieDataset = new DefaultCategoryDataset();
        //        pieDataset.setValue("Diagnosa", new Integer(jan));
        pieDataset.setValue(new Integer(jan), "", "Januari");
        pieDataset.setValue(new Integer(feb), "", "Februari");
        pieDataset.setValue(new Integer(mar), "", "Maret");
        pieDataset.setValue(new Integer(apr), "", "April");
        pieDataset.setValue(new Integer(mei), "", "Mei");
        pieDataset.setValue(new Integer(jun), "", "Juni");
        pieDataset.setValue(new Integer(jul), "", "Juli");
        pieDataset.setValue(new Integer(agus), "", "Agustus");
        pieDataset.setValue(new Integer(sept), "", "September");
        pieDataset.setValue(new Integer(okt), "", "Oktober");
        pieDataset.setValue(new Integer(nov), "", "November");
        pieDataset.setValue(new Integer(des), "", "Desember");
        JFreeChart chart = ChartFactory.createBarChart3D("STATISTIK KEUANGAN ADMINISTRASI", "BULAN", "JUMLAH",
                (CategoryDataset) pieDataset, PlotOrientation.VERTICAL, false, true, false);
        chart.setBackgroundPaint(Color.yellow);
        chart.getTitle().setPaint(Color.red);

        final CategoryPlot p = chart.getCategoryPlot();

        BarRenderer renderer = (BarRenderer) p.getRenderer();
        DecimalFormat sdf = new DecimalFormat("RP #,##0");
        renderer.setItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", sdf));
        p.setRenderer(renderer);//  www.j av  a  2  s . c o  m
        renderer.setBasePositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_LEFT));
        renderer.setItemLabelsVisible(true);
        chart.getCategoryPlot().setRenderer(renderer);

        p.setRangeGridlinePaint(Color.blue);
        p.setBackgroundPaint(Color.white);
        ChartFrame frame = new ChartFrame("barchart", chart);
        frame.setVisible(true);
        frame.setLocation(250, 100);
        frame.setSize(800, 600);
    } else if (vpil.getSelectedIndex() == 2) {
        int row = tabelData.getSelectedRow();
        String jan = (tabelData.getModel().getValueAt(row, 0)).toString();
        String feb = (tabelData.getModel().getValueAt(row, 1)).toString();
        String mar = (tabelData.getModel().getValueAt(row, 2)).toString();
        String apr = (tabelData.getModel().getValueAt(row, 3)).toString();
        String mei = (tabelData.getModel().getValueAt(row, 4)).toString();
        String jun = (tabelData.getModel().getValueAt(row, 5)).toString();
        String jul = (tabelData.getModel().getValueAt(row, 6)).toString();
        String agus = (tabelData.getModel().getValueAt(row, 7)).toString();
        String sept = (tabelData.getModel().getValueAt(row, 8)).toString();
        String okt = (tabelData.getModel().getValueAt(row, 9)).toString();
        String nov = (tabelData.getModel().getValueAt(row, 10)).toString();
        String des = (tabelData.getModel().getValueAt(row, 11)).toString();
        DefaultPieDataset pieDataset = new DefaultPieDataset();
        pieDataset.setValue("Januari", new Integer(jan));
        pieDataset.setValue("Februari", new Integer(feb));
        pieDataset.setValue("Maret", new Integer(mar));
        pieDataset.setValue("April", new Integer(apr));
        pieDataset.setValue("Mei", new Integer(mei));
        pieDataset.setValue("Juni", new Integer(jun));
        pieDataset.setValue("Juli", new Integer(jul));
        pieDataset.setValue("Agustus", new Integer(agus));
        pieDataset.setValue("September", new Integer(sept));
        pieDataset.setValue("Oktober", new Integer(okt));
        pieDataset.setValue("November", new Integer(nov));
        pieDataset.setValue("Desember", new Integer(des));
        JFreeChart chart = ChartFactory.createPieChart("STATISTIK KEUANGAN ADMINISTRASI", pieDataset, true,
                true, true);
        //        PiePlot3D P = (PiePlot3D)chart.getPlot();
        PiePlot P = (PiePlot) chart.getPlot();
        //P.setForegroundAlpha(TOP_ALIGNMENT);
        ChartFrame frame = new ChartFrame("STATISTIK KEUANGAN ADMINISTRASI", chart);
        frame.setVisible(true);
        frame.setLocation(250, 100);
        frame.setSize(800, 600);
    } else {

    }

}