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.Graph.java

private JFreeChart makeGraph() {
    return ChartFactory.createBarChart("Political View", "Party", "Tweets", createDataset(),
            PlotOrientation.VERTICAL, false, false, false);
}

From source file:moviedatas.View.BarChartView.java

@Override
public void newMovieSelected(Movie movie) {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.addValue(movie.getBudget(), "Budget", new Integer(1));
    dataset.addValue(movie.getGross(), "Gross", new Integer(1));
    JFreeChart barChart = ChartFactory.createBarChart("", "Movie", "Value (in $)", dataset, VERTICAL, true,
            true, false);/*from www . j  a  v  a 2 s.c o m*/
    cPanel.setChart(barChart);
    cPanel.updateUI();
}

From source file:org.apache.qpid.disttest.charting.chartbuilder.BarChartBuilder.java

@Override
protected JFreeChart createCategoryChart(String title, String xAxisTitle, String yAxisTitle,
        final Dataset dataset, PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips,
        boolean showUrls) {
    JFreeChart chart = ChartFactory.createBarChart(title, xAxisTitle, yAxisTitle, (CategoryDataset) dataset,
            plotOrientation, showLegend, showToolTips, showUrls);
    return chart;
}

From source file:com.sjsu.uidesign.ExecStatus.java

public ExecStatus() {
    super();//w w  w  .  j  a  v a  2 s  .c  o m
    super.setTitle("Task Execution Status");
    super.setSize(500, 500);
    super.setResizable(true);
    super.setLocationRelativeTo(null);

    JLabel usageImage = new JLabel();
    //usageImage.setIcon(new ImageIcon("Pie_3.png"));

    //usageImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/sjsu/uidesign/Bar_4.png"))); // NOI18N
    //add(usageImage);

    DefaultCategoryDataset barChartData = new DefaultCategoryDataset();
    barChartData.setValue(6, "Cache Cleanup", "Cache Cleanup");
    barChartData.setValue(8, "Antivirus Scan", "Antivirus Scan");
    barChartData.setValue(7, "Empty Recycle Bin", "Empty Recycle Bin");

    JFreeChart barChart = ChartFactory.createBarChart("Task Execution Status", "Task Name", "Status",
            createDataset(), PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot barChar = barChart.getCategoryPlot();
    barChar.setRangeGridlinePaint(Color.ORANGE);

    ChartPanel barPanel = new ChartPanel(barChart);

    JPanel panelChart = new JPanel();
    panelChart.removeAll();
    panelChart.add(barPanel, BorderLayout.CENTER);
    panelChart.validate();
    add(panelChart);
}

From source file:Graphics.Barchart.java

public void createGraphic(String titulo, int largura, int altura) {
    CategoryDataset data = this.createDataset();
    grafico = ChartFactory.createBarChart(titulo, xtitle, ytitle, data, PlotOrientation.HORIZONTAL, true, false,
            false);/*from  w ww  .  j  a va2  s.  c  om*/
    this.altura = altura;
    this.largura = largura;
    ChartPanel ch = new ChartPanel(grafico);
    ch.setSize(largura, altura);
    ch.setBounds(0, 0, largura, altura);
    this.setDefaultCloseOperation(javax.swing.JFrame.DISPOSE_ON_CLOSE);
    this.setContentPane(ch);
}

From source file:eu.delving.sip.base.ReportChartHelper.java

public static JPanel createPresenceChart(DataSet dataSet, String prefix, int[] presence, int totalRecords) {
    DefaultCategoryDataset data = new DefaultCategoryDataset();
    int index = 0;
    for (RecDef.Check check : RecDef.Check.values()) {
        data.addValue(presence[index], "Presence", check);
        index++;//from w w w.  jav a2s .co m
    }
    JFreeChart chart = ChartFactory.createBarChart(
            String.format("Field presence in %s / %s", dataSet.getSpec(), prefix), "Field",
            String.format("Record count of %d records", totalRecords), data, PlotOrientation.VERTICAL, false,
            true, false);
    chart.addSubtitle(new TextTitle("Field Presence"));
    return finishBarChart(chart, new Color(218, 112, 214));
}

From source file:userInterface.cdcRole.OverviewJPanel.java

private static JFreeChart createChart1(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Distribution of Vaccines", "Vaccine", "Quantity",
            categorydataset, PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setRangeCrosshairVisible(true);
    categoryplot.setRangeCrosshairPaint(Color.green);
    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.green, 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:charts.ErroresPorMilChart.java

private JFreeChart createChart(DefaultCategoryDataset dataset, String title) {
    JFreeChart chart = ChartFactory.createBarChart(title, "Tipo de Control", "Cantidad de Imagenes", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis();
    xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); // Inclinamos 45 grados las etiquetas del eje X
    plot.setBackgroundAlpha(0.5f);/*from w  w w .  ja v a2s  .co  m*/
    return chart;
}

From source file:dumbara.view.Chart1.java

public static void byIncome() {
    DefaultCategoryDataset objDataset = new DefaultCategoryDataset();
    try {/*from  w  ww . j  av  a  2 s  .  c  om*/
        Sale[] sale = SalesController.viewAllSales();
        for (Sale sale1 : sale) {
            objDataset.setValue(sale1.getIncome(), "Sales Progress", sale1.getSalesID());
        }
    } catch (ClassNotFoundException | SQLException ex) {
        Logger.getLogger(Chart1.class.getName()).log(Level.SEVERE, null, ex);
    }
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.MONTH, -1);
    Date result = cal.getTime();
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("E yyyy.MM.dd");
    String format = simpleDateFormat.format(result);
    Date date = new Date();
    String format1 = simpleDateFormat.format(date);

    JFreeChart objChart = ChartFactory.createBarChart(
            "Sales Comparisson by Sales ID from " + format + " to " + format1, "Sales ID", "Sales Income",
            objDataset, PlotOrientation.VERTICAL, true, true, false

    );
    ChartFrame frame = new ChartFrame("Data Analysis Wizard - v2.1.4", objChart);
    frame.pack();
    frame.setSize(1300, 600);
    frame.setVisible(true);
    frame.setLocationRelativeTo(null);
}

From source file:edu.wpi.cs.wpisuitetng.modules.requirementsmanager.view.charts.AbstractRequirementStatistics.java

protected JFreeChart buildBarChart(final String title, final String category, final String axisLabel) {
    final JFreeChart chart = ChartFactory.createBarChart(title, category, axisLabel,
            toCategoryDataset(category), PlotOrientation.VERTICAL, true, false, false);
    final CategoryPlot xyPlot = (CategoryPlot) chart.getPlot();
    final NumberAxis range = (NumberAxis) xyPlot.getRangeAxis();
    range.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    return chart;
}