Example usage for org.jfree.chart.plot CategoryPlot setRangeZeroBaselinePaint

List of usage examples for org.jfree.chart.plot CategoryPlot setRangeZeroBaselinePaint

Introduction

In this page you can find the example usage for org.jfree.chart.plot CategoryPlot setRangeZeroBaselinePaint.

Prototype

public void setRangeZeroBaselinePaint(Paint paint) 

Source Link

Document

Sets the paint for the zero baseline plotted against the range axis and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:de.dekarlab.moneybuilder.view.AnalyticsView.java

/**
 * Create pie chart.//from   w w w  .  j av  a2s  . c o m
 * 
 * @param dataset
 * @param title
 * @return
 */
protected JFreeChart createBarChart(final CategoryDataset dataset, final String title) {
    final JFreeChart chart = ChartFactory.createBarChart("", // chart title
            App.getGuiProp("report.period.lbl"), // domain axis label
            App.getGuiProp("report.value.lbl"), // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips
            false // urls
    );

    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setNoDataMessage(App.getGuiProp("report.nodata.msg"));
    plot.setBackgroundPaint(Color.white);
    ((NumberAxis) plot.getRangeAxis()).setAutoRangeIncludesZero(false);
    ((CategoryAxis) plot.getDomainAxis()).setMaximumCategoryLabelLines(10);
    ((CategoryAxis) plot.getDomainAxis()).setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeZeroBaselinePaint(Color.black);
    plot.setRangeZeroBaselineVisible(true);
    int color = 0;
    ((BarRenderer) plot.getRenderer()).setBarPainter(new StandardBarPainter());
    CategoryItemRenderer renderer = plot.getRenderer();
    for (int ser = 0; ser < dataset.getColumnCount(); ser++) {
        renderer.setSeriesPaint(ser, COLORS[color]);
        renderer.setSeriesItemLabelGenerator(ser,
                new StandardCategoryItemLabelGenerator("{2}", NumberFormat.getInstance(Locale.GERMAN)));
        renderer.setSeriesItemLabelsVisible(ser, true);
        color++;
        if (COLORS.length == color) {
            color = 0;
        }
    }
    return chart;
}

From source file:srvclientmonitor.frmMain.java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    JPanel panel = new JPanel();
    getContentPane().add(panel);/*  www. j  a  va  2  s .  co  m*/
    DefaultCategoryDataset data = new DefaultCategoryDataset();
    //DefaultPieDataset data = new DefaultPieDataset();  //Para el Grafico PIE

    data.addValue(20, "OSP", "HOY");
    data.addValue(99, "ETL", "HOY");
    data.addValue(25, "LOR", "HOY");
    data.addValue(12, "MOV", "HOY");

    // Creando el Grafico
    //JFreeChart chart = ChartFactory.createPieChart(
    //JFreeChart chart = ChartFactory.createBarChart("Ejemplo Rapido de Grafico en un ChartFrame", "Mes", "Valor", data);

    JFreeChart chart = ChartFactory.createBarChart("", "", "", data, PlotOrientation.VERTICAL, false, false,
            false);
    chart.setBackgroundPaint(Color.BLACK);
    chart.setTitle("");

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setRangePannable(true);
    plot.setRangeGridlinesVisible(false);
    plot.setBackgroundAlpha(1);
    plot.setBackgroundPaint(Color.BLACK);
    plot.setForegroundAlpha(1);
    plot.setDomainCrosshairPaint(Color.WHITE);
    plot.setNoDataMessagePaint(Color.WHITE);
    plot.setOutlinePaint(Color.WHITE);
    plot.setRangeCrosshairPaint(Color.WHITE);
    plot.setRangeMinorGridlinePaint(Color.WHITE);
    plot.setRangeZeroBaselinePaint(Color.WHITE);

    //        Paint p = new GradientPaint(0, 0, Color.white, 1000, 0, Color.green);
    //        plot.setBackgroundPaint(p);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLabelPaint(Color.WHITE);
    rangeAxis.setAxisLinePaint(Color.WHITE);
    rangeAxis.setTickLabelPaint(Color.WHITE);
    rangeAxis.setVerticalTickLabels(true);

    //ChartUtilities.applyCurrentTheme(chart);

    // Crear el Panel del Grafico con ChartPanel
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setSize(300, 150);
    chartPanel.setBackground(Color.BLACK);
    chartPanel.setOpaque(false);
    chartPanel.setDomainZoomable(true);
    this.jPanel1.setSize(300, 200);
    this.jPanel1.setBackground(Color.DARK_GRAY);
    this.jPanel1.add(chartPanel);

}

From source file:de.dekarlab.moneybuilder.view.AnalyticsView.java

/**
 * Create pie chart.//from  ww w .  j a  v a  2  s  . c om
 * 
 * @param dataset
 * @param title
 * @return
 */
protected JFreeChart createLineChart(final CategoryDataset dataset, final String title) {
    final JFreeChart chart = ChartFactory.createLineChart("", // chart title
            App.getGuiProp("report.period.lbl"), // domain axis label
            App.getGuiProp("report.value.lbl"), // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );
    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setNoDataMessage(App.getGuiProp("report.nodata.msg"));
    plot.setBackgroundPaint(Color.white);
    plot.setBackgroundPaint(Color.white);
    ((NumberAxis) plot.getRangeAxis()).setAutoRangeIncludesZero(false);
    ((CategoryAxis) plot.getDomainAxis()).setMaximumCategoryLabelLines(10);
    ((CategoryAxis) plot.getDomainAxis()).setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.gray);
    plot.setRangeGridlinePaint(Color.gray);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeZeroBaselinePaint(Color.black);
    plot.setRangeZeroBaselineVisible(true);
    int color = 0;
    CategoryItemRenderer renderer = plot.getRenderer();
    for (int ser = 0; ser < dataset.getColumnCount(); ser++) {
        renderer.setSeriesPaint(ser, COLORS[color]);
        renderer.setSeriesStroke(ser, new BasicStroke(4));
        StandardCategoryItemLabelGenerator gen = new StandardCategoryItemLabelGenerator("{2}",
                NumberFormat.getInstance(Locale.GERMAN)) {
            private static final long serialVersionUID = 1L;

            public String generateLabel(CategoryDataset dataset, int series, int item) {
                if (item % 3 == 0) {
                    return super.generateLabelString(dataset, series, item);
                } else {
                    return null;
                }
            }
        };

        renderer.setSeriesItemLabelGenerator(ser, gen);
        renderer.setSeriesItemLabelsVisible(ser, true);

        color++;
        if (COLORS.length == color) {
            color = 0;
        }
    }
    return chart;
}