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:view.tankDepthDetails.BarrChart.java

/**
 * Creates new form BarrChart/*w ww .j  a  v a2 s  . co  m*/
 */
public BarrChart() {
    initComponents();

    DefaultCategoryDataset dcd = new DefaultCategoryDataset();
    float s = 8;
    dcd.setValue(s, "Marks", "Dumindu");
    dcd.setValue(88.80, "Marks", "lakal");
    dcd.setValue(78.80, "Marks", "Charitha");
    dcd.setValue(7.80, "Marks", "lahiru");
    dcd.setValue(76.80, "Marks", "mahin");
    dcd.setValue(90.80, "Marks", "gin");

    JFreeChart Jchart = ChartFactory.createBarChart("Tank Level Records", "Time", "Tank Level", dcd,
            PlotOrientation.VERTICAL, true, true, false);
    CategoryPlot plot = Jchart.getCategoryPlot();
    plot.setRangeGridlinePaint(java.awt.Color.black);

    ChartFrame chartfra = new ChartFrame("Tank Level Records", Jchart, true);
    //   chartfra.setVisible(true);
    chartfra.setSize(400, 500);

    ChartPanel chartPanel = new ChartPanel(Jchart);

    jPanel2.removeAll();
    jPanel2.add(chartPanel);
    jPanel2.updateUI();

}

From source file:bbank.CurrentStockWindow.java

/**
 * Creates new form CurrentStockWindow//from w  w w  .j a  va 2 s.co m
 */
public CurrentStockWindow() {
    initComponents();
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    BloodStock.CalculateTotalBlood();
    dataset.addValue(BloodStock.total_A_accepted, "", "Total Accepted A");
    dataset.addValue(BloodStock.total_A_rejected, "", "Total Rejected A");
    dataset.addValue(BloodStock.total_B_accepted, "", "Total Accepted B");
    dataset.addValue(BloodStock.total_B_rejected, "", "Total Rejected B");
    dataset.addValue(BloodStock.total_O_accepted, "", "Total Accepted O");
    dataset.addValue(BloodStock.total_O_rejected, "", "Total Rejected O");

    JFreeChart chart = ChartFactory.createBarChart("Current Total Blood Stock", "Blood type", "Amount (litres)",
            dataset, PlotOrientation.VERTICAL, false, false, false);
    CategoryPlot catPlot = chart.getCategoryPlot();
    catPlot.setRangeGridlinePaint(Color.BLACK);

    ChartPanel chartpanel = new ChartPanel(chart);
    jPanel1.removeAll();
    jPanel1.add(chartpanel);
    jPanel1.validate();
}

From source file:UserInterface.JFreeChart.java

public JFreeChart(VitalSign vs, JPanel upc) {
    initComponents();//from   w ww . j av a 2 s.co  m
    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(450, 350);
}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart("Bar Chart Demo 9", null, "Value", categorydataset,
            PlotOrientation.VERTICAL, false, true, false);
    TextTitle texttitle = jfreechart.getTitle();
    texttitle.setBorder(0.0D, 0.0D, 1.0D, 0.0D);
    texttitle.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.red, 350F, 0.0F, Color.white, true));
    texttitle.setExpandToFitSpace(true);
    jfreechart.setBackgroundPaint(new GradientPaint(0.0F, 0.0F, Color.yellow, 350F, 0.0F, Color.white, true));
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setNoDataMessage("NO DATA!");
    categoryplot.setBackgroundPaint(null);
    categoryplot.setInsets(new RectangleInsets(10D, 5D, 5D, 5D));
    categoryplot.setOutlinePaint(Color.black);
    categoryplot.setRangeGridlinePaint(Color.gray);
    categoryplot.setRangeGridlineStroke(new BasicStroke(1.0F));
    Paint apaint[] = createPaint();
    CustomBarRenderer custombarrenderer = new CustomBarRenderer(apaint);
    custombarrenderer.setGradientPaintTransformer(
            new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL));
    categoryplot.setRenderer(custombarrenderer);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setRange(0.0D, 800D);/*w w w .  j av  a2s .c  o  m*/
    numberaxis.setTickMarkPaint(Color.black);
    return jfreechart;
}

From source file:is2pr3.HistogramDisplay.java

private JFreeChart createChart(DefaultCategoryDataset dataSet) {
    JFreeChart chart = ChartFactory.createBarChart("Histogram", "Domain", "N emails", dataSet,
            PlotOrientation.VERTICAL, false, rootPaneCheckingEnabled, rootPaneCheckingEnabled);
    return chart;
}

From source file:net.neurowork.cenatic.centraldir.model.graphs.BarchartGraphCreator.java

@Override
public JFreeChart createGraphChart(String title, String yAxis, Dataset data) {
    PlotOrientation orientation = PlotOrientation.VERTICAL;

    JFreeChart chart = ChartFactory.createBarChart(title, "", // x-axis label
            yAxis, // y-axis label
            (CategoryDataset) data, orientation, false, // legend displayed
            true, // tooltips displayed
            false); // no URLs*/

    CategoryPlot categoryPlot = chart.getCategoryPlot();
    CategoryAxis domainAxis = categoryPlot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    return chart;
}

From source file:paquete.Graficas.java

public void terminar() {
    datos.addValue(tcp, "TCP", "Paquetes");
    datos.addValue(udp, "UDP", "Paquetes");
    datos.addValue(icmp, "ICMP", "Paquetes");
    datos.addValue(igmp, "IGMP", "Paquetes");
    datos.addValue(arp, "ARP", "Paquetes");
    datos.addValue(llc, "LLC", "Paquetes");

    grafica = ChartFactory.createBarChart("Paquetes analizados", "", "", datos, PlotOrientation.VERTICAL, true,
            false, false);//from w ww.ja v  a  2s. c  om
    ChartPanel panel = new ChartPanel(grafica);

    JFrame Ventana = new JFrame("JFreeChart");
    Ventana.getContentPane().add(panel);
    Ventana.pack();
    Ventana.setVisible(true);
    Ventana.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
}

From source file:tusys.view.jPanelChart.java

/**
 * Creates new form jPanelChart/*from  w ww  .jav a 2s. c  o  m*/
 */

public jPanelChart(String chartTitle) {
    initComponents();
    JFreeChart barChart = ChartFactory.createBarChart(chartTitle, "Category", "Score", createDataset(),
            PlotOrientation.VERTICAL, true, true, false);

    ChartPanel chartPanel = new ChartPanel(barChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(560, 367));
    add(chartPanel);
}

From source file:org.jw.service.factory.StatisticsChartFactory.java

public static JFreeChart createBarChart(CategoryDataset dataset, String title, String categoryAxisLabel,
        String valueAxisLabel) {/*from   w  w  w .ja v a2  s.  c o m*/
    JFreeChart chart = ChartFactory.createBarChart(title, categoryAxisLabel, valueAxisLabel, dataset,
            PlotOrientation.VERTICAL, true, true, true);
    return chart;
}

From source file:TelasBanzos.TelaRelatorioAproveitamento.java

/**
 * Creates new form TelaNovoOrcamento/*  ww w.  j a v a  2  s .c  o m*/
 */
public TelaRelatorioAproveitamento() {
    initComponents();

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    dataset.setValue(80, "0", "Nota");
    dataset.setValue(70, "0", "Frequncia");

    JFreeChart chart = ChartFactory.createBarChart("Aproveitamento", "Aproveitamento", "", dataset,
            PlotOrientation.VERTICAL, false, true, false);

    //colocar cor nas barras
    CategoryPlot plot = chart.getCategoryPlot();
    BarRenderer render = (BarRenderer) plot.getRenderer();
    render.setSeriesPaint(0, Color.blue);

    ChartPanel myChartPanel = new ChartPanel(chart, true);
    pnGraf.add(myChartPanel);

    setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("BanzosIcon.png")));//para setar um icone na janela
}