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

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

Introduction

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

Prototype

public void setDomainGridlinePaint(Paint paint) 

Source Link

Document

Sets the paint used to draw the grid-lines (if any) against the domain axis and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:org.jfree.chart.demo.BarChartDemo11.java

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Open Source Projects By Licence", "Licence",
            "Project Count", categorydataset, PlotOrientation.HORIZONTAL, false, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setRangeGridlinePaint(Color.white);
    categoryplot.getDomainAxis().setMaximumCategoryLabelWidthRatio(0.4F);
    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));
    barrenderer.setSeriesPaint(0, gradientpaint);
    return jfreechart;
}

From source file:org.jfree.chart.demo.ItemLabelDemo3.java

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Item Label Demo 3", "Category", "Value",
            categorydataset, PlotOrientation.VERTICAL, false, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setRangeGridlinePaint(Color.white);
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setVisible(false);/*from   w w w .  j a va 2  s.  co m*/
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setUpperMargin(0.14999999999999999D);
    CategoryItemRenderer categoryitemrenderer = categoryplot.getRenderer();
    StandardCategoryItemLabelGenerator standardcategoryitemlabelgenerator = new StandardCategoryItemLabelGenerator(
            "{1}", NumberFormat.getInstance());
    categoryitemrenderer.setBaseItemLabelGenerator(standardcategoryitemlabelgenerator);
    categoryitemrenderer.setBaseItemLabelFont(new Font("SansSerif", 0, 12));
    categoryitemrenderer.setBaseItemLabelsVisible(true);
    categoryitemrenderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER,
            TextAnchor.CENTER, TextAnchor.CENTER, -1.5707963267948966D));
    return jfreechart;
}

From source file:statistic.ca.gui.Charts.java

public static JFreeChart createBarChart(ChartData data) {
    if (data.getDiagramType().equals("bar")) {
        chart = ChartFactory.createBarChart(data.getTitle(), // Title
                data.getYAxisLabel(), // X-Axis label
                "", // Y-Axis label
                data.getCDataSet(), // CategoryDataset
                PlotOrientation.VERTICAL, false, true, false // Show legend
        );/*from   w w  w .j a v  a  2 s.c om*/
        CategoryPlot plot = (CategoryPlot) chart.getPlot();
        plot.setBackgroundPaint(Color.LIGHT_GRAY);
        plot.setDomainGridlinePaint(Color.WHITE);
        plot.setRangeGridlinePaint(Color.WHITE);
        plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    }

    if (data.getDiagramType().equals("pie")) {
        chart = ChartFactory.createPieChart(data.getTitle(), // Title
                data.getPieDataSet(), false, true, false);
    }

    chart.setBackgroundPaint(Color.WHITE);

    return chart;
}

From source file:org.jfree.chart.demo.GradientPaintTransformerDemo1.java

private static JFreeChart createChart(String s, CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart(s, null, "Value", categorydataset,
            PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setRangeGridlinePaint(Color.white);
    categoryplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setItemMargin(0.02D);//  ww w .ja  v  a 2s  .com
    return jfreechart;
}

From source file:org.jfree.chart.demo.BarChartDemo10.java

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Bar Chart Demo", "Category", "Value", categorydataset,
            PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    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));
    return jfreechart;
}

From source file:br.unicamp.cst.util.ChartViewerUtil.java

public static synchronized ChartPanel createChart(DefaultCategoryDataset dataset, String title,
        String categoryAxisLabel, String valueAxisLabel, PlotOrientation chartType) {

    final JFreeChart chart = ChartFactory.createBarChart(title, categoryAxisLabel, valueAxisLabel, dataset,
            chartType, true, true, false);

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    chart.setBackgroundPaint(Color.lightGray);

    ChartPanel localChartPanel = new ChartPanel(chart);
    localChartPanel.setVisible(true);/*  w w w.  j a v  a 2 s.  c om*/
    localChartPanel.setDomainZoomable(true);

    return localChartPanel;
}

From source file:org.jfree.chart.demo.BoxAndWhiskerChartDemo1.java

private static JFreeChart createChart(BoxAndWhiskerCategoryDataset boxandwhiskercategorydataset) {
    JFreeChart jfreechart = ChartFactory.createBoxAndWhiskerChart("Box and Whisker Chart Demo 1", "Category",
            "Value", boxandwhiskercategorydataset, true);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    jfreechart.setBackgroundPaint(Color.white);
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setRangeGridlinePaint(Color.white);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return jfreechart;
}

From source file:gui.statistic.JChartPanel.java

protected static JFreeChart createChart() {
    categoryDataset = new DefaultCategoryDataset();
    //categoryDataset.addValue(20, "", "A");
    //categoryDataset.addValue(35, "", "A");
    //categoryDataset.addValue(40, "", "B");
    //categoryDataset.addValue(60, "", "B");

    JFreeChart chart = ChartFactory.createBarChart("", // Title
            "Belegungen", // X-Axis label
            "Werte", // Y-Axis label
            categoryDataset, // Dataset
            PlotOrientation.VERTICAL, false, true, false // Show legend
    );/* w w  w . j  a  va 2 s. c o m*/

    chart.setBackgroundPaint(Color.WHITE);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.WHITE);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    //plot.setDomainCrosshairVisible(true);
    //plot.setRangeCrosshairVisible(true);

    return chart;

}

From source file:service.chart.FitnessChart.java

/**
 * Utworz wykres funkcji fitness dla najlepszego osobnika w danej iteracji algorytmu genetycznego 
 * na podstawie zestawu danych/*w ww. j  a v a  2 s  .com*/
 * 
 * @param categoryDataset Zestaw danych
 * @return Wykres funkcji fitness
 */
private static JFreeChart createChart(CategoryDataset categoryDataset) {

    JFreeChart chart = ChartFactory.createLineChart("Best fitness function value", // title
            "Iteration", // x-axis label
            "Fitness", // y-axis label
            categoryDataset, // data
            PlotOrientation.VERTICAL, true, // create legend?
            true, // generate tooltips?
            false // generate URLs?
    );

    chart.setBackgroundPaint(Color.white);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    CategoryItemRenderer r = plot.getRenderer();
    if (r instanceof LineAndShapeRenderer) {
        LineAndShapeRenderer renderer = (LineAndShapeRenderer) r;
        renderer.setBaseShapesVisible(false);
        renderer.setBaseShapesFilled(true);
    }

    return chart;
}

From source file:org.jfree.chart.demo.ScatterRendererDemo1.java

private static JFreeChart createChart(MultiValueCategoryDataset multivaluecategorydataset) {
    CategoryPlot categoryplot = new CategoryPlot(multivaluecategorydataset, new CategoryAxis("Category"),
            new NumberAxis("Value"), new ScatterRenderer());
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setDomainGridlinePaint(Color.white);
    categoryplot.setRangeGridlinePaint(Color.white);
    categoryplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D));
    JFreeChart jfreechart = new JFreeChart("ScatterRendererDemo1", categoryplot);
    ChartUtilities.applyCurrentTheme(jfreechart);
    return jfreechart;
}