Example usage for org.jfree.chart ChartFactory createBarChart3D

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

Introduction

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

Prototype

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

Source Link

Document

Creates a bar chart with a 3D effect.

Usage

From source file:clienteProfessor.ClickerOne_Resultados.java

public void criaGrafico() {
    CategoryDataset cds = createDataset();
    String titulo = "Resultado da aula: " + jComboBoxAulas.getSelectedItem();
    String eixoy = "Quantidade de escolhas";
    String txt_legenda = "Legenda:";
    boolean legenda = true;
    boolean tooltips = true;
    boolean urls = true;
    JFreeChart graf = ChartFactory.createBarChart3D(titulo, txt_legenda, eixoy, cds, PlotOrientation.VERTICAL,
            legenda, tooltips, urls);/*from w  w w.  j av  a  2s. co  m*/
    //JFreeChart graf = ChartFactory.createBarChart3D(titulo, txt_legenda, eixoy, cds, PlotOrientation.VERTICAL, legenda, tooltips, urls);
    ChartPanel myChartPanel = new ChartPanel(graf, true);
    myChartPanel.setSize(jPanel1.getWidth(), jPanel1.getHeight());
    myChartPanel.setVisible(true);
    myChartPanel.setFont(new Font("Arial", Font.PLAIN, 25));
    myChartPanel.setBackground(this.getBackground());
    jPanel1.removeAll();
    jPanel1.add(myChartPanel);
    jPanel1.revalidate();
    jPanel1.repaint();
}

From source file:org.psystems.dicom.browser.server.stat.StatDailyLoadChartServlet.java

public JFreeChart getChart(CategoryDataset dataset) {
    // create the chart...
    final JFreeChart chart = ChartFactory.createBarChart3D(" ", // chart title
            "", // domain axis label
            " (.)", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );/*ww  w  .  jav  a 2  s.  c o m*/

    //      #44639C;

    TextTitle title = new TextTitle("  ", labelFont);
    //      Paint paint = title.getPaint();
    title.setPaint(new Color(68, 99, 156));
    chart.setTitle(title);

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    // final IntervalMarker target = new IntervalMarker(2000000, 3000000);
    // target.setLabel(" ");
    // target.setLabelFont(new Font("SansSerif", Font.ITALIC, 11));
    // target.setLabelAnchor(RectangleAnchor.LEFT);
    // target.setLabelTextAnchor(TextAnchor.CENTER_LEFT);
    // target.setPaint(new Color(222, 222, 255, 128));
    // plot.addRangeMarker(target, Layer.BACKGROUND);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setTickLabelFont(labelFont);

    // disable bar outlines...
    final BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setItemMargin(0.10);

    // set up gradient paints for series...
    final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.blue);
    final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray);
    final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray);
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 4.0)
    // CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)
    );
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;
}

From source file:UserInterface.DoctorRole.ViewDonorReport.java

public void Graph() {
    dataset = new DefaultCategoryDataset();
    if (vitalSigndir.getVitalSignDir().isEmpty()) {
        for (VitalSign vs : vitalSigndir.getVitalSignDir()) {

            dataset.addValue(Float.parseFloat(vs.getBloodPressure()), "Blood Pressure", vs.getTimestamp());
            dataset.addValue(Float.parseFloat(vs.getBloodPlatlets()), "Blood Platelets", vs.getTimestamp());
            dataset.addValue(Float.parseFloat(vs.getHemoglobinLevel()), "Hemoglobin Level", vs.getTimestamp());
            //dataset.addValue(vs.getWeight(), "Weight", vs.getTimestamp());

        }//from  ww  w .  j av  a 2s  . com

        JFreeChart chartFactory = ChartFactory.createBarChart3D("VitalSign", "Time", "VitalSign", dataset,
                PlotOrientation.VERTICAL, true, true, false);

        BarRenderer renderer = null;
        CategoryPlot plot = chartFactory.getCategoryPlot();
        renderer = new BarRenderer();
        ChartFrame frame = new ChartFrame("Bar Chart for VitalSign", chartFactory);
        frame.setVisible(true);
        frame.setSize(700, 320);
    }

}

From source file:com.controlj.addon.gwttree.server.GraphServlet.java

/**<!====== getChart ======================================================>
   Generates the chart.  Note that most of these options are not required
   for a simple chart, but we wanted to try to get a particular look that
   matched another charting package, so we went to some trouble to set
   a lot of non-standard options.  In particular, the OpaqueBarRenderer3D
   is a non-standard renderer that gives much better looking 3D bars.
<!=======================================================================>*/
private static JFreeChart getChart(DefaultCategoryDataset dataset) {
    JFreeChart chart = ChartFactory.createBarChart3D("Integration Over Time", "24 Hour Period", "", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.black);
    chart.getTitle().setPaint(Color.white);
    chart.getTitle().setFont(new Font("Verdana", Font.BOLD, 20));
    chart.setAntiAlias(true);//from   w ww . ja  v a2s  . co m
    chart.setTextAntiAlias(true);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setForegroundAlpha(1);
    OpaqueBarRenderer3D renderer = new OpaqueBarRenderer3D();
    renderer.setItemMargin(0.1);
    plot.setRenderer(renderer);

    renderer.setSeriesPaint(0, new Color(116, 225, 118));
    renderer.setSeriesPaint(1, new Color(245, 107, 107));
    renderer.setSeriesPaint(2, new Color(250, 187, 107));
    renderer.setSeriesPaint(3, new Color(72, 72, 238));
    renderer.setSeriesPaint(4, new Color(184, 32, 157));
    renderer.setDrawBarOutline(false);

    Font small = new Font("Verdana", Font.PLAIN, 12);
    Font big = new Font("Verdana", Font.BOLD, 14);

    renderer.setItemLabelPaint(Color.white);
    plot.getDomainAxis().setTickLabelPaint(Color.white);
    plot.getDomainAxis().setTickLabelFont(small);
    plot.getDomainAxis().setLabelPaint(Color.white);
    plot.getDomainAxis().setLabelFont(big);
    plot.getDomainAxis().setCategoryMargin(0.2);

    plot.getRangeAxis().setTickLabelPaint(Color.white);
    plot.getRangeAxis().setTickLabelFont(small);
    plot.getRangeAxis().setLabelPaint(Color.white);
    plot.getRangeAxis().setLabelFont(big);
    plot.setBackgroundPaint(Color.black);

    chart.getLegend().setBackgroundPaint(Color.black);
    chart.getLegend().setItemPaint(Color.white);
    chart.getLegend().setItemFont(big);

    return chart;
}

From source file:org.karndo.graphs.CustomChartFactory.java

/**
 * Creates a chart of the selected PiracyEvent data graphed by event 
 * status. Presently uses a very basic method of graphing this data by 
 * using the static CreateBarChart3D method available in class
 * org.jfree.chart.ChartFactory.    /* ww  w.j a  v a 2  s. co m*/
 * 
 * @param data the selected PiracyEvent data to graph.
 * @return A JFreeChart object representing a graph of the selected 
 * PiracyEvent data against event status.
 */
public JFreeChart createHistogramStatus(LinkedList<PiracyEvent> data) {
    //the data to plot
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    LinkedHashMap<String, MutableInt> freqs_cats = new LinkedHashMap<String, MutableInt>();

    for (PiracyEvent ev : data) {
        if (!freqs_cats.containsKey(ev.getStatus())) {
            freqs_cats.put(ev.getStatus(), new MutableInt(1));
        } else {
            freqs_cats.get(ev.getStatus()).increment();
        }
    }

    Iterator itr = freqs_cats.keySet().iterator();
    while (itr.hasNext()) {
        String category = (String) itr.next();
        Integer i1 = freqs_cats.get(category).getValue();
        dataset.addValue(i1, "Piracy Incidents", category);
    }

    JFreeChart chart = ChartFactory.createBarChart3D("Piracy Incidents " + "by event status", "Event Status",
            "Frequency", dataset, PlotOrientation.VERTICAL, false, true, false);
    return chart;
}

From source file:edu.ucla.stat.SOCR.chart.demo.BarChart3DDemo1.java

/**
 * Creates a 3D bar chart./*from  w w w  . j  av  a2 s .co  m*/
 * 
 * @param dataset  the category dataset.
 * 
 * @return The chart.
 */
protected JFreeChart createChart(CategoryDataset dataset) {

    JFreeChart chart = ChartFactory.createBarChart3D(chartTitle, // chart title
            domainLabel, // domain axis label
            rangeLabel, // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

    CategoryPlot plot = chart.getCategoryPlot();
    plot.setDomainGridlinesVisible(true);
    CategoryAxis axis = plot.getDomainAxis();
    axis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 8.0));
    BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer();
    renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator());
    renderer.setDrawBarOutline(false);

    setCategorySummary(dataset);
    return chart;

}

From source file:org.eevolution.form.WCRP.java

private void jbInit() throws Exception {
    resourceLabel.setText(Msg.translate(Env.getCtx(), "S_Resource_ID"));
    dateFromLabel.setText(Msg.translate(Env.getCtx(), "DateFrom"));

    Rows rows = new Rows();
    Row row = null;//ww  w. j a  va2  s . c  om

    rows.setParent(northPanel);
    row = rows.newRow();
    row.appendChild(resourceLabel.rightAlign());
    row.appendChild(resource.getComponent());
    row.appendChild(dateFromLabel.rightAlign());
    row.appendChild(dateFrom.getComponent());
    centerPanel.appendChild(chartPanel);

    JFreeChart jchart = ChartFactory.createBarChart3D("", Msg.translate(Env.getCtx(), "Days"), // X-Axis label
            Msg.translate(Env.getCtx(), "Hours"), // Y-Axis label
            new DefaultCategoryDataset(), // Dataset
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );

    renderChart(jchart);

    confirmPanel.addActionListener(this);
}

From source file:giaodien.tongquan.TongQuan.java

public void GraphTop5MatHangBanChay() throws SQLException {

    PreparedStatement LAYTOP5 = con.prepareStatement(
            "SELECT chitiethoadonbanhang.MAHANGHOA, TENHANGHOA, sum(chitiethoadonbanhang.SOLUONG) as TongSoLuong"
                    + "                                        FROM chitiethoadonbanhang"
                    + "                                        INNER JOIN hanghoa ON hanghoa.MAHANGHOA = chitiethoadonbanhang.MAHANGHOA "
                    + "                                        group by MAHANGHOA order by sum(SOLUONG) desc limit 5");
    ResultSet rsLAYTOP5 = LAYTOP5.executeQuery();
    while (rsLAYTOP5.next()) {

        maHH = rsLAYTOP5.getString("TENHANGHOA");
        soluong = rsLAYTOP5.getInt("TongSoLuong");

        dataset1.setValue(soluong, "", maHH);
    }/*from   w  w w .  j  a  va  2  s. com*/

    JFreeChart chart1 = ChartFactory.createBarChart3D(null, null, null, dataset1, PlotOrientation.HORIZONTAL,
            false, false, false);
    CategoryPlot catePlot1 = chart1.getCategoryPlot();
    catePlot1.setRangeGridlinePaint(Color.BLACK);
    ((BarRenderer) catePlot1.getRenderer()).setBarPainter(new StandardBarPainter());

    BarRenderer r1 = (BarRenderer) chart1.getCategoryPlot().getRenderer();
    r1.setSeriesPaint(0, Color.BLUE);

    ChartPanel chartpanel1 = new ChartPanel(chart1);
    graph1.removeAll();
    graph1.add(chartpanel1, BorderLayout.CENTER);
    graph1.validate();
}

From source file:de.laures.cewolf.taglib.CewolfChartFactory.java

public static JFreeChart getChartInstance(String chartType, String title, String xAxisLabel, String yAxisLabel,
        Dataset data) throws ChartValidationException {
    // first check the dynamically registered chart types
    CewolfChartFactory factory = (CewolfChartFactory) factories.get(chartType);
    if (factory != null) {
        // custom factory found, use it
        return factory.getChartInstance(title, xAxisLabel, yAxisLabel, data);
    }//from w  w w  . j a v a 2s . c o  m

    switch (getChartTypeConstant(chartType)) {
    case XY:
        check(data, XYDataset.class, chartType);
        return ChartFactory.createXYLineChart(title, xAxisLabel, yAxisLabel, (XYDataset) data,
                PlotOrientation.VERTICAL, true, true, true);
    case PIE:
        check(data, PieDataset.class, chartType);
        return ChartFactory.createPieChart(title, (PieDataset) data, true, true, true);
    case AREA_XY:
        check(data, XYDataset.class, chartType);
        return ChartFactory.createXYAreaChart(title, xAxisLabel, yAxisLabel, (XYDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case SCATTER:
        check(data, XYDataset.class, chartType);
        return ChartFactory.createScatterPlot(title, xAxisLabel, yAxisLabel, (XYDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case AREA:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createAreaChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case HORIZONTAL_BAR:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createBarChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.HORIZONTAL, true, false, false);
    case HORIZONTAL_BAR_3D:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createBarChart3D(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.HORIZONTAL, true, false, false);
    case LINE:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createLineChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case STACKED_HORIZONTAL_BAR:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createStackedBarChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.HORIZONTAL, true, false, false);
    case STACKED_VERTICAL_BAR:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createStackedBarChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case STACKED_VERTICAL_BAR_3D:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createStackedBarChart3D(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case VERTICAL_BAR:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createBarChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case VERTICAL_BAR_3D:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createBarChart3D(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case TIME_SERIES:
        check(data, XYDataset.class, chartType);
        return ChartFactory.createTimeSeriesChart(title, xAxisLabel, yAxisLabel, (XYDataset) data, true, false,
                false);
    case CANDLE_STICK:
        check(data, OHLCDataset.class, chartType);
        return ChartFactory.createCandlestickChart(title, xAxisLabel, yAxisLabel, (OHLCDataset) data, true);
    case HIGH_LOW:
        check(data, OHLCDataset.class, chartType);
        return ChartFactory.createHighLowChart(title, xAxisLabel, yAxisLabel, (OHLCDataset) data, true);
    case GANTT:
        check(data, IntervalCategoryDataset.class, chartType);
        return ChartFactory.createGanttChart(title, xAxisLabel, yAxisLabel, (IntervalCategoryDataset) data,
                true, false, false);
    case WIND:
        check(data, WindDataset.class, chartType);
        return ChartFactory.createWindPlot(title, xAxisLabel, yAxisLabel, (WindDataset) data, true, false,
                false);
    //case SIGNAL :
    //  check(data, SignalsDataset.class, chartType);
    //  return ChartFactory.createSignalChart(title, xAxisLabel, yAxisLabel, (SignalsDataset) data, true);
    case VERRTICAL_XY_BAR:
        check(data, IntervalXYDataset.class, chartType);
        return ChartFactory.createXYBarChart(title, xAxisLabel, true, yAxisLabel, (IntervalXYDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case PIE_3D:
        check(data, PieDataset.class, chartType);
        return ChartFactory.createPieChart3D(title, (PieDataset) data, true, false, false);
    case METER:
        check(data, ValueDataset.class, chartType);
        MeterPlot plot = new MeterPlot((ValueDataset) data);
        JFreeChart chart = new JFreeChart(title, plot);
        return chart;
    case STACKED_AREA:
        check(data, CategoryDataset.class, chartType);
        return ChartFactory.createStackedAreaChart(title, xAxisLabel, yAxisLabel, (CategoryDataset) data,
                PlotOrientation.VERTICAL, true, false, false);
    case BUBBLE:
        check(data, XYZDataset.class, chartType);
        return ChartFactory.createBubbleChart(title, xAxisLabel, yAxisLabel, (XYZDataset) data,
                PlotOrientation.VERTICAL, true, false, false);

    case AUSTER_CICLOS:
        check(data, IntervalCategoryDataset.class, chartType);
        return ChartFactory.createAusterCiclosChart((IntervalCategoryDataset) data);

    default:
        throw new UnsupportedChartTypeException(chartType + " is not supported.");
    }
}

From source file:edu.ku.brc.specify.plugins.ipadexporter.ChartHelper.java

/**
 * @param list/*w  w  w . j a  v  a 2  s.c  o m*/
 * @param title
 * @param xAxisTitle
 * @param yAxisTitle
 * @param isVertical
 * @param width
 * @param height
 */
public JFreeChart createBarChart(final List<Object> list, final String title, final String xAxisTitle,
        final String yAxisTitle, final boolean isVertical, final int width, final int height) {
    DefaultCategoryDataset dataset = createDataSet(list);

    JFreeChart chart = ChartFactory.createBarChart3D(title, // chart title 
            xAxisTitle, // domain axis label 
            yAxisTitle, // range axis label 
            dataset, // data 
            isVertical ? PlotOrientation.VERTICAL : PlotOrientation.HORIZONTAL, true, // include legend 
            true, // tooltips? 
            false // URLs? 
    );

    CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
    categoryplot.setRangeGridlinePaint(Color.DARK_GRAY);
    categoryplot.setBackgroundPaint(null);

    return chart;
}