Example usage for org.jfree.chart ChartFactory createBarChart

List of usage examples for org.jfree.chart ChartFactory createBarChart

Introduction

In this page you can find the example usage for org.jfree.chart ChartFactory createBarChart.

Prototype

public static JFreeChart createBarChart(String title, String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) 

Source Link

Document

Creates a bar chart.

Usage

From source file:kata.pkg3.HistogramDisplay.java

private JFreeChart createChart(DefaultCategoryDataset dataset) {
    JFreeChart chart = ChartFactory.createBarChart(null, "DOMINIO", "N email", dataset,
            PlotOrientation.VERTICAL, true, //Muestra la leyenda en caso de tener mas datos
            true, //Pasas el raton por encima y te muestra los datos
            false); //Algo del Entorno Web
    return chart;

}

From source file:business.management.system.Chart.java

/**
 * Creates new form Chart//from w w w  . j av  a  2  s. co  m
 */
public Chart(CategoryDataset dataset) throws SQLException {
    initComponents();
    JFreeChart barChart = ChartFactory.createBarChart("Stock quote", "Category", "Score", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    JPanel panel = new JPanel();
    ChartPanel chartPanel = new ChartPanel(barChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    panel.add(chartPanel);
    setContentPane(panel);
    /*JFreeChart pieChart = ChartFactory.createPieChart(
     "Completed projects",           
     createPieDataset()     
     );
    ChartPanel chartPanel1 = new ChartPanel( pieChart );        
    chartPanel.setPreferredSize(new java.awt.Dimension( 560 , 367 ) );       
    panel.add(chartPanel1);
    setContentPane(panel); */
}

From source file:edu.esprit.pi.workshop.statistiques.BarChart.java

@Override
public JFreeChart construireChart2D() {
    graphe = ChartFactory.createBarChart("Pourcentage revenue par Dpartement", "Departement",
            "Pourcentage du revenu", createDataset(), PlotOrientation.VERTICAL, true, true, true);
    final CategoryPlot plot = graphe.getCategoryPlot();
    final CategoryAxis axis = plot.getDomainAxis();
    axis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0));
    final CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setItemLabelsVisible(true);
    return graphe;
}

From source file:com.thecoderscorner.groovychart.chart.BarChart.java

public JFreeChart createChart() {
    JFreeChart chart = ChartFactory.createBarChart(getTitle(), getCategoryAxisLabel(), getValueAxisLabel(),
            (CategoryDataset) getDataset(), getOrientation(), isLegend(), isTooltips(), isUrls());
    return setExtraProperties(chart);

}

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:userInterface.StateAdminRole.DecisionCartJPanel2.java

private static JFreeChart createChart1(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Order Statistics", "Hospital", "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;
}

From source file:my.demo.BarChart.java

public BarChart(String applicationTitle, String chartTitle, CategoryDataset dataset, JPanel jp) {
    super(applicationTitle);
    JFreeChart barChart = ChartFactory.createBarChart(chartTitle, "Type", "FScore", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(barChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(650, 350));

    setContentPane(chartPanel);/*from  w  ww .j  av  a2 s  .c o  m*/
    jp.add(chartPanel);

}

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

private static JFreeChart createChart(CategoryDataset dataset) {
    JFreeChart chart = ChartFactory.createBarChart("SubCategoryAxis Demo 1", "Category", "Value", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    SubCategoryAxis subCategoryAxis = new SubCategoryAxis(null);
    subCategoryAxis.addSubCategory("S1");
    subCategoryAxis.addSubCategory("S2");
    subCategoryAxis.addSubCategory("S3");
    plot.setDomainAxis(subCategoryAxis);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);
    NumberAxis valueAxis = (NumberAxis) plot.getRangeAxis();
    valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);// w  ww. j  a  v a2s  . com
    GradientPaint gradientpaint0 = 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));
    renderer.setSeriesPaint(0, gradientpaint0);
    renderer.setSeriesPaint(1, gradientpaint1);
    renderer.setSeriesPaint(2, gradientpaint2);
    return chart;
}

From source file:UserInterface.JFreeChartJPanel.java

public JFreeChartJPanel(VitalSign vs, JPanel upc) {
    initComponents();/*from w w w.  j  ava 2 s . c om*/

    this.vs = vs;
    this.upc = upc;

    int rr = (vs.getRespiratoryrate());
    int hr = vs.getHeartrate();
    int bp = vs.getBloodpressure();
    double w = vs.getWeight();
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(rr, "", "Respiratory Rate");
    dataset.setValue(hr, "", "Heart Rate");
    dataset.setValue(bp, "", "Blood Pressure");
    dataset.setValue(w, "", "Weight");

    //    
    org.jfree.chart.JFreeChart chart = ChartFactory.createBarChart("VitalSign", "Vital Signs", "Range", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setRangeGridlinePaint(Color.black);
    ChartFrame frame = new ChartFrame("Bar Chart for _---_", chart);
    frame.setVisible(true);
    frame.setSize(600, 600);
}

From source file:app.Histogram.java

public void createHistogram(List<WordStatistic> was) {
    final String series1 = "??? ";
    final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    was.sort(null);//ww w.  j a v a2 s  . c o m
    for (int i = 0; i < 40; i++) {
        dataset.addValue(was.get(i).getFrequency(), series1, was.get(i).getWord());
    }
    final JFreeChart chart = ChartFactory.createBarChart(
            "? ?? ? ?? ??   ?",
            "??? ",
            "? ?? ?? ", dataset,
            PlotOrientation.VERTICAL, false, true, false);
    histogramDesign(chart);
}