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:Data.PoliticalGraph.java

private JFreeChart makeGraph() {
    return ChartFactory.createBarChart("Tweets", "Partisan", "Percent", createDataset(),
            PlotOrientation.VERTICAL, false, false, false);

}

From source file:Data.SentimentGraph.java

private JFreeChart makeGraph() {
    return ChartFactory.createBarChart("Tweets", "Sentiment", "Percent", createDataset(),
            PlotOrientation.VERTICAL, false, false, false);

}

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);/*  w  w w .  j a  v  a  2s .  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:src.Barchart.java

public Barchart(String windowTitle, String chartTitle, String nombreChart, String nombreMetrica,
        ArrayList<String> barras, ArrayList<Double> valorBarras, String tiposValor) {
    super(windowTitle);
    JFreeChart barChart = ChartFactory.createBarChart(chartTitle, nombreChart, nombreMetrica,
            createDataset(barras, valorBarras, tiposValor), PlotOrientation.VERTICAL, true, true, false);
    this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    ChartPanel chartPanel = new ChartPanel(barChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    setContentPane(chartPanel);//from  w  w w. j av a  2  s  .com
}

From source file:Graphic.Employee.java

public Employee(List<Float> valeurs, List<String> nom) {
    dataset = new DefaultCategoryDataset();
    for (int i = 0; i < valeurs.size(); i++) {
        dataset.addValue(valeurs.get(i), "heure travaille", nom.get(i));
    }//from  w  ww  . ja  v  a2 s.c  o m

    diagramme = ChartFactory.createBarChart("Temps travaill par les chauffeurs", "Chauffeur",
            "Heure travaille", dataset, PlotOrientation.HORIZONTAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(diagramme);
    chartPanel.setFillZoomRectangle(true);
    chartPanel.setMouseWheelEnabled(true);
    chartPanel.setPreferredSize(new Dimension(1200, 600));
    add(chartPanel);

}

From source file:Diagramas.BarChart_AWT.java

public BarChart_AWT(String applicationTitle, String chartTitle) throws IOException {
    super(applicationTitle);
    JFreeChart barChart = ChartFactory.createBarChart(chartTitle, "Category", "Score", createDataset(),
            PlotOrientation.VERTICAL, true, true, false);

    int width = 640; /* Width of the image */
    int height = 480; /* Height of the image */
    File BarChart = new File("BarChart.png");
    ChartUtilities.saveChartAsPNG(BarChart, barChart, width, height);

    ChartPanel chartPanel = new ChartPanel(barChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    setContentPane(chartPanel);/* w w w  . jav a2  s .c om*/
}

From source file:Reportes.BarChart.java

public ChartPanel reporteEmpleados(DefaultCategoryDataset data) {
    JFreeChart JFchart = ChartFactory.createBarChart("Reporte de empleados", "Sedes", "Cantidad", data,
            PlotOrientation.VERTICAL, true, true, true);
    /*/*from  w  w  w.  j  ava2 s .co m*/
    CategoryPlot plot = new CategoryPlot();
            
    ChartFrame chartFrame = new ChartFrame("Reporte de empleadoos", JFchart, false);
    chartFrame.setSize(300, 300);
    chartFrame.setVisible(true);
    */

    CategoryPlot categoryP = JFchart.getCategoryPlot();
    BarRenderer renderer = (BarRenderer) categoryP.getRenderer();
    renderer.setMaximumBarWidth(0.35);
    Color color = new Color(67, 165, 208);
    renderer.setSeriesPaint(0, color);

    ChartPanel panel = new ChartPanel(JFchart, true, true, true, false, false);

    panel.setSize(ancho, alto);

    return panel;
}

From source file:net.sqs2.omr.result.chart.BarChart.java

public static void write(OutputStream outputStream, int width, int height, Legend legend,
        StatisticsResult statisticsResult) {
    // (1)create dataset
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (FormArea formArea : legend.formAreaList) {
        int itemIndex = formArea.getItemIndex();
        String key = legend.questionIndex + "," + itemIndex;
        dataset.addValue(statisticsResult.getCount(key), "", formArea.getItemLabel());
    }//from  w w  w.j  a  v  a 2  s  . c o m

    if (legend.primaryFormArea.isSelectSingle()) {
        int count = statisticsResult.getCount(legend.questionIndex + ",-1");
        dataset.addValue(count, "", ChartConstants.NO_ANSWER);
    }

    // String title = StringUtil.join(formAreaList.get(0).getHints(), "\n");
    String title = "";
    JFreeChart chart = ChartFactory.createBarChart(title, "", ChartConstants.NO_ANSWER, dataset,
            PlotOrientation.HORIZONTAL, false, true, false);
    try {
        ChartUtilities.writeChartAsPNG(outputStream, chart, width, height);
    } catch (IOException ioEx) {
        ioEx.printStackTrace();
    }
}

From source file:Servidor.java

private void inicializarGraficosBarras() {
    datosBarras = new DefaultCategoryDataset();
    chart = ChartFactory.createBarChart("Grfica de barras.", "Candidatos", "Votos Obtenidos", datosBarras,
            PlotOrientation.VERTICAL, true, true, false);
    frame = new ChartFrame("Vista", chart);
    frame.pack();/*  w  w w.  j  a  va  2s . c  o m*/
    frame.setVisible(true);

}

From source file:Charts.BarChart.java

private JFreeChart makeJFreeChart(String title, String x, String y) {
    final JFreeChart barChart = ChartFactory.createBarChart(title, // chart title
            x, // x axis label
            y, // y axis label
            this.createDataset(), // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );//  w ww. j  a va 2 s  . c  o m
    return barChart;
}