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:com.etest.view.tq.charts.GraphicalInventoryBarChart.java

public GraphicalInventoryBarChart() {
    setModal(true);//from   ww w.j a  v  a 2s  .  c  o  m

    VerticalLayout v = new VerticalLayout();
    v.setMargin(true);

    //        Panel panel = new Panel();
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (Curriculum c : cs.getAllCurriculum()) {
        for (int i = 0; i < 2; i++) {
            if (i == 0) {
                dataset.addValue(rs.getTotalCasesBySubject(c.getCurriculumId()), "Cases", c.getSubject());
            } else {
                dataset.addValue(rs.getTotalItemsBySubject(c.getCurriculumId()), "Items", c.getSubject());
            }
        }
    }

    JFreeChart chart = ChartFactory.createBarChart("Inventory of Items and Cases", "Subjects", "", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    CategoryPlot plot = chart.getCategoryPlot();
    BarRenderer renderer = (BarRenderer) plot.getRenderer();

    Color color;

    for (int i = 0; i < dataset.getRowCount(); i++) {
        if (i % 2 == 0) {
            renderer.setSeriesPaint(i, new Color(0, 0, 255));
        } else {
            renderer.setSeriesPaint(i, new Color(255, 0, 0));
        }
    }

    //        JFreeChartWrapper wrapper = new JFreeChartWrapper(chart){
    //            
    //            @Override
    //            public void attach(){
    //                super.attach();
    //                setResource("src", getSource());
    //            }
    //            
    //        };

    v.addComponent(new ReportChartWrapper(chart, null, null));
    v.setWidthUndefined();
    v.setHeightUndefined();

    setContent(v);
    getContent().setWidthUndefined();
    getContent().setHeightUndefined();
    center();
}

From source file:de.fub.maps.project.detector.model.statistics.BarChartPanel.java

/**
 * Creates new form StatisticSegmentLengthBarChart
 *//*from   w  w  w.ja  v a  2  s  .  c o  m*/
public BarChartPanel() {
    initComponents();
    barChart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.VERTICAL, true, true,
            true);
    plot = barChart.getCategoryPlot();

    BarRenderer barRenderer = new BarRenderer();
    barRenderer.setMaximumBarWidth(.05);
    barRenderer.setBasePaint(Color.BLUE);
    barRenderer.setAutoPopulateSeriesPaint(false);
    barRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    barRenderer.setBarPainter(new StandardBarPainter());
    barRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
            StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, new CustomNumberFormat()));
    barRenderer.setBaseItemLabelsVisible(true);
    plot.setRenderer(barRenderer);
    plot.getDomainAxis().setMaximumCategoryLabelLines(3);
    plot.setBackgroundPaint(Color.white);
    barChart.setBackgroundPaint(Color.white);
    plot.setRangeGridlinesVisible(true);
    plot.getDomainAxis().setMaximumCategoryLabelLines(3);
    chartPanel = new ChartPanel(barChart, false);
    chartPanel.setVerticalAxisTrace(false);
    chartPanel.setDisplayToolTips(true);
    chartPanel.setBackground(Color.white);
    add(chartPanel, BorderLayout.CENTER);
}

From source file:org.codehaus.mojo.dashboard.report.plugin.chart.BarChartRenderer.java

public void createChart() {
    CategoryDataset categorydataset = (CategoryDataset) this.datasetStrategy.getDataset();
    report = ChartFactory.createBarChart(this.datasetStrategy.getTitle(), this.datasetStrategy.getYAxisLabel(),
            this.datasetStrategy.getXAxisLabel(), categorydataset, PlotOrientation.HORIZONTAL, true, true,
            false);//  w  w  w  .  j a  v  a2  s  .  c  o m
    // report.setBackgroundPaint( Color.lightGray );
    report.setPadding(new RectangleInsets(5.0d, 5.0d, 5.0d, 5.0d));
    CategoryPlot categoryplot = (CategoryPlot) report.getPlot();
    categoryplot.setBackgroundPaint(Color.white);
    categoryplot.setRangeGridlinePaint(Color.lightGray);
    categoryplot.setDomainGridlinePaint(Color.lightGray);
    categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    if (datasetStrategy instanceof CoberturaBarChartStrategy
            || datasetStrategy instanceof CloverBarChartStrategy
            || datasetStrategy instanceof MultiCloverBarChartStrategy) {
        numberaxis.setRange(0.0D, BarChartRenderer.NUMBER_AXIS_RANGE);
        numberaxis.setNumberFormatOverride(NumberFormat.getPercentInstance());
    } else {
        numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }
    numberaxis.setLowerMargin(0.0D);
    CategoryAxis axis = categoryplot.getDomainAxis();
    axis.setLowerMargin(0.02); // two percent
    axis.setCategoryMargin(0.10); // ten percent
    axis.setUpperMargin(0.02); // two percent
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setItemMargin(0.10);
    barrenderer.setDrawBarOutline(false);
    barrenderer.setBaseItemLabelsVisible(true);
    if (datasetStrategy instanceof CoberturaBarChartStrategy
            || datasetStrategy instanceof CloverBarChartStrategy
            || datasetStrategy instanceof MultiCloverBarChartStrategy) {
        barrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}",
                NumberFormat.getPercentInstance(Locale.getDefault())));
    } else {
        barrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    }

    int height = (categorydataset.getColumnCount() * ChartUtils.STANDARD_BARCHART_ENTRY_HEIGHT
            * categorydataset.getRowCount());
    if (height > ChartUtils.MINIMUM_HEIGHT) {
        super.setHeight(height);
    } else {
        super.setHeight(ChartUtils.MINIMUM_HEIGHT);
    }

    Paint[] paints = this.datasetStrategy.getPaintColor();

    for (int i = 0; i < categorydataset.getRowCount() && i < paints.length; i++) {
        barrenderer.setSeriesPaint(i, paints[i]);
    }

}

From source file:edu.emory.library.tast.database.graphs.GraphTypeBar.java

public JFreeChart createChart(Object[] data) {

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    JFreeChart chart = ChartFactory.createBarChart(null, getSelectedIndependentVariable().getLabel(),
            TastResource.getText("components_charts_barvalue"), dataset, PlotOrientation.VERTICAL, true, true,
            false);//from  ww w .ja v  a 2  s . c  om

    CategoryPlot plot = chart.getCategoryPlot();
    plot.getDomainAxis().setMaximumCategoryLabelLines(5);
    plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
    chart.setBackgroundPaint(Color.white);

    Format formatter = getSelectedIndependentVariable().getFormat();

    List allDataSeries = getDataSeries();
    for (int j = 0; j < allDataSeries.size(); j++) {

        DataSeries dataSearies = (DataSeries) allDataSeries.get(j);
        String dataSeriesLabel = dataSearies.formatForDisplay();

        for (int i = 0; i < data.length; i++) {
            Object[] row = (Object[]) data[i];

            String cat = formatter == null ? row[0].toString() : formatter.format(row[0]);

            dataset.addValue((Number) row[j + 1], dataSeriesLabel, cat);
        }
    }

    LegendItemCollection legendItems = chart.getPlot().getLegendItems();
    for (int i = 0; i < legendItems.getItemCount(); i++) {
        LegendItem legendItem = legendItems.get(i);
        DataSeries dataSearies = (DataSeries) allDataSeries.get(i);
        if (legendItem.getFillPaint() instanceof Color) {
            dataSearies.setColor(((Color) legendItem.getFillPaint()));
        }
    }

    return chart;

}

From source file:org.sakaiproject.evaluation.tool.reporting.EvalLikertChartBuilder.java

@SuppressWarnings("deprecation")
public JFreeChart makeLikertChart() {

    DefaultCategoryDataset likertDataset = new DefaultCategoryDataset();

    for (int i = 0; i < responses.length; i++) {
        likertDataset.addValue(values[i], "Responses", responses[i]);
    }/*from w ww  . j  av a 2s . c o  m*/

    JFreeChart chart = ChartFactory.createBarChart(null, // "Likert Chart", // Chart title
            null, // "Choices", // domain axis label
            null, // "# of Responses", // range axis label
            likertDataset, PlotOrientation.HORIZONTAL, false, // show legend
            false, // show tooltips
            false // show URLs
    );

    // Set the background colours
    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);

    // Configure the bar colors and display
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setSeriesPaint(0, new Color(244, 252, 212));
    renderer.setDrawBarOutline(true);
    renderer.setOutlinePaint(new Color(34, 35, 237));
    renderer.setOutlineStroke(new BasicStroke(0.5f));
    renderer.setBaseItemLabelsVisible(true);
    if (showPercentages) {
        renderer.setBaseItemLabelGenerator(new LikertPercentageItemLabelGenerator(this.responseCount));
    } else {
        renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    }
    // Turn off the Top Value Axis
    ValueAxis rangeAxis = plot.getRangeAxis();
    rangeAxis.setVisible(false);
    rangeAxis.setUpperMargin(0.35);
    rangeAxis.resizeRange(1.1f);

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setMaximumCategoryLabelWidthRatio(0.4f);
    domainAxis.setMaximumCategoryLabelLines(2);

    // Set the font for the labels
    Font labelFont = new Font("Serif", Font.PLAIN, 6);

    CategoryItemRenderer itemRenderer = plot.getRenderer();
    itemRenderer.setBaseItemLabelFont(labelFont);

    plot.setOutlinePaint(null);

    domainAxis.setLabelFont(labelFont);
    domainAxis.setTickLabelFont(labelFont);
    rangeAxis.setLabelFont(labelFont);
    rangeAxis.setTickLabelFont(labelFont);

    return chart;
}

From source file:com.MainChart.java

public MainChart(String applicationTitle, String chartTitle) throws IOException {
    super(applicationTitle);
    this.multiHashtable = new Hashtable<>();
    // This will create the dataset 
    // PieDataset dataset = createDataset();
    // based on the dataset we create the chart
    final JFreeChart chart = ChartFactory.createBarChart("GPA Analysis By Country", // chart title
            "Country", // domain axis label
            "GPA", // range axis label
            createDataset(), // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips?
            false // URLs?
    );//from w  ww .j  a  va2  s .c  o  m

    chart.setBackgroundPaint(Color.white);
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    plot.setBackgroundPaint(SystemColor.inactiveCaption);//change background color

    //set  bar chart color

    //CategoryItemRenderer renderer = new CustomRenderer(); 
    //plot.setRenderer(renderer);
    // we put the chart into a panel
    ChartPanel chartPanel = new ChartPanel(chart);
    // default size
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
    // add it to our application
    setContentPane(chartPanel);

}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart(null, null, null, categorydataset,
            PlotOrientation.HORIZONTAL, false, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    TextTitle texttitle = new TextTitle(
            "Figure 7 | I. Resources - The site offers users relevant, informative and educational resources");
    texttitle.setHorizontalAlignment(HorizontalAlignment.LEFT);
    texttitle.setBackgroundPaint(Color.red);
    texttitle.setPaint(Color.white);
    jfreechart.setTitle(texttitle);/*w  w  w.  j a  v  a2 s  . co m*/
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setOutlinePaint(null);
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setDomainGridlinePosition(CategoryAnchor.END);
    categoryplot.setDomainGridlineStroke(new BasicStroke(0.5F));
    categoryplot.setDomainGridlinePaint(Color.black);
    categoryplot.setRangeGridlinesVisible(false);
    categoryplot.clearRangeMarkers();
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setVisible(false);
    categoryaxis.setCategoryMargin(0.5D);
    categoryplot.getRangeAxis().setVisible(false);
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setSeriesPaint(0, new Color(156, 164, 74));
    barrenderer.setDrawBarOutline(false);
    barrenderer.setBaseItemLabelsVisible(true);
    barrenderer.setBaseItemLabelFont(new Font("SansSerif", 1, 10));
    ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3,
            TextAnchor.CENTER_RIGHT);
    barrenderer.setBasePositiveItemLabelPosition(itemlabelposition);
    CategoryTextAnnotation categorytextannotation = new CategoryTextAnnotation("1. White papers are available.",
            "Category 1", 0.0D);
    categorytextannotation.setFont(new Font("SansSerif", 1, 12));
    categorytextannotation.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation);
    CategoryTextAnnotation categorytextannotation1 = new CategoryTextAnnotation(
            "2. White papers enhance users understanding of the firm and its expertise.", "Category 2", 0.0D);
    categorytextannotation1.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation1.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation1.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation1);
    CategoryTextAnnotation categorytextannotation2 = new CategoryTextAnnotation(
            "3. White papers are relevant to the firm's prospects and clients.", "Category 3", 0.0D);
    categorytextannotation2.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation2.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation2.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation2);
    CategoryTextAnnotation categorytextannotation3 = new CategoryTextAnnotation(
            "4. White papers are relevant to the firm's positioning.", "Category 4", 0.0D);
    categorytextannotation3.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation3.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation3.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation3);
    CategoryTextAnnotation categorytextannotation4 = new CategoryTextAnnotation(
            "5. Case studies are available.", "Category 5", 0.0D);
    categorytextannotation4.setFont(new Font("SansSerif", 1, 12));
    categorytextannotation4.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation4.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation4);
    CategoryTextAnnotation categorytextannotation5 = new CategoryTextAnnotation(
            "6. Case studies enhance users understanding of the firm and its expertise.", "Category 6", 0.0D);
    categorytextannotation5.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation5.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation5.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation5);
    CategoryTextAnnotation categorytextannotation6 = new CategoryTextAnnotation(
            "7. Case studies are relevant to the firm's prospects and clients.", "Category 7", 0.0D);
    categorytextannotation6.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation6.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation6.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation6);
    CategoryTextAnnotation categorytextannotation7 = new CategoryTextAnnotation(
            "8. White papers are relevant to the firm's positioning.", "Category 8", 0.0D);
    categorytextannotation7.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation7.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation7.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation7);
    CategoryTextAnnotation categorytextannotation8 = new CategoryTextAnnotation(
            "9. Case studies are available.", "Category 9", 0.0D);
    categorytextannotation8.setFont(new Font("SansSerif", 1, 12));
    categorytextannotation8.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation8.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation8);
    CategoryTextAnnotation categorytextannotation9 = new CategoryTextAnnotation(
            "10. Case studies enhance users understanding of the firm and its expertise.", "Category 10", 0.0D);
    categorytextannotation9.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation9.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation9.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation9);
    CategoryTextAnnotation categorytextannotation10 = new CategoryTextAnnotation(
            "11. Case studies are relevant to the firm's prospects and clients.", "Category 11", 0.0D);
    categorytextannotation10.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation10.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation10.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation10);
    CategoryTextAnnotation categorytextannotation11 = new CategoryTextAnnotation(
            "12. White papers are relevant to the firm's positioning.", "Category 12", 0.0D);
    categorytextannotation11.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation11.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation11.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation11);
    CategoryTextAnnotation categorytextannotation12 = new CategoryTextAnnotation(
            "13. Users can easily access resources based on viewer interest.", "Category 13", 0.0D);
    categorytextannotation12.setFont(new Font("SansSerif", 1, 12));
    categorytextannotation12.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation12.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation12);
    CategoryTextAnnotation categorytextannotation13 = new CategoryTextAnnotation(
            "14. Access to additional hyperlinks enhances users's ability to find relevant information.",
            "Category 14", 0.0D);
    categorytextannotation13.setFont(new Font("SansSerif", 1, 12));
    categorytextannotation13.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation13.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation13);
    CategoryTextAnnotation categorytextannotation14 = new CategoryTextAnnotation("15. OVERALL EFFECTIVENESS.",
            "Overall", 0.0D);
    categorytextannotation14.setFont(new Font("SansSerif", 1, 12));
    categorytextannotation14.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation14.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation14);
    return jfreechart;
}

From source file:gui.statistic.JChartPanel.java

protected static JFreeChart createChart() {
    categoryDataset = new DefaultCategoryDataset();
    //categoryDataset.addValue(20, "", "A");
    //categoryDataset.addValue(35, "", "A");
    //categoryDataset.addValue(40, "", "B");
    //categoryDataset.addValue(60, "", "B");

    JFreeChart chart = ChartFactory.createBarChart("", // Title
            "Belegungen", // X-Axis label
            "Werte", // Y-Axis label
            categoryDataset, // Dataset
            PlotOrientation.VERTICAL, false, true, false // Show legend
    );/*from  ww  w  .  ja  v a2 s. c  o  m*/

    chart.setBackgroundPaint(Color.WHITE);

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.WHITE);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    //plot.setDomainCrosshairVisible(true);
    //plot.setRangeCrosshairVisible(true);

    return chart;

}

From source file:org.neo4j.bench.chart.JFreeBarChart.java

@Override
protected JFreeChart createChart(AbstractDataset dataset) {
    JFreeChart chart = ChartFactory.createBarChart("Performance chart", "Bench case", "Time(s)",
            (DefaultCategoryDataset) dataset, PlotOrientation.VERTICAL, true, true, false);

    rotateCategoryAxis(chart, Math.PI / 4.0);
    CategoryPlot plot = chart.getCategoryPlot();
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setItemLabelGenerator(new CategoryItemLabelGenerator() {
        public String generateColumnLabel(CategoryDataset dataset, int column) {
            return "col" + column;
        }/*from www  .  j a v a 2s.c om*/

        public String generateLabel(CategoryDataset dataset, int row, int column) {
            return "" + dataset.getValue(row, column).intValue();
        }

        public String generateRowLabel(CategoryDataset dataset, int row) {
            return "row" + row;
        }
    });
    renderer.setBaseItemLabelPaint(Color.black);
    renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.INSIDE12,
            TextAnchor.CENTER_RIGHT, TextAnchor.CENTER_RIGHT, -Math.PI / 2.0));
    renderer.setItemLabelsVisible(true);

    return chart;
}

From source file:se.backede.jeconomix.forms.budget.BudgetOutcomePanel.java

private void setChart(JPanel panel, BudgetOutcomeModel model, CategoryTypeEnum category) {
    JFreeChart barChart = ChartFactory.createBarChart(category.name() + " budget vs outcome", "", "",
            createDataset(model), PlotOrientation.HORIZONTAL, true, true, false);

    barChart.setTitle(new org.jfree.chart.title.TextTitle(
            WordUtils.capitalizeFully(category.name()) + " budget vs outcome",
            new java.awt.Font("Courier New", java.awt.Font.PLAIN, 12)));

    ChartPanel chartPanel = new ChartPanel(barChart);
    chartPanel.setPreferredSize(new java.awt.Dimension(panel.getWidth(), panel.getHeight()));
    panel.setLayout(new BorderLayout());
    panel.add(chartPanel, BorderLayout.NORTH);
}