Example usage for org.jfree.chart ChartFactory createHistogram

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

Introduction

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

Prototype

public static JFreeChart createHistogram(String title, String xAxisLabel, String yAxisLabel,
        IntervalXYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips,
        boolean urls) 

Source Link

Document

Creates a histogram chart.

Usage

From source file:com.compomics.cell_coord.gui.controller.computation.ComputationDataController.java

/**
 *
 * @param track/*ww  w . j a v  a2  s .c  o m*/
 */
private void plotDeltaX(Track track) {
    Double[] deltaXValues = ComputationUtils.transpose2DArray(track.getSteps())[0];
    double[] values = ArrayUtils.toPrimitive(ComputationUtils.excludeNullValues(deltaXValues));
    HistogramDataset histogramDataset = new HistogramDataset();
    histogramDataset.addSeries("", values, 2);
    String title = "delta_x_values for track: " + track.getTrackid();
    JFreeChart jFreeChart = ChartFactory.createHistogram(title, "delta_x", "count", histogramDataset,
            PlotOrientation.VERTICAL, true, true, true);
    ChartPanel chartPanel = new ChartPanel(jFreeChart);
    computationDataPanel.getDeltaxPlotPanel().removeAll();
    computationDataPanel.getDeltaxPlotPanel().add(chartPanel, gridBagConstraints);
    computationDataPanel.getDeltaxPlotPanel().revalidate();
    computationDataPanel.getDeltaxPlotPanel().repaint();
}

From source file:task5.deneme.java

private ChartPanel createChartPanel() {
    dataset = new HistogramDataset();
    final int w = img.getWidth();
    final int h = img.getHeight();

    JFreeChart chart = ChartFactory.createHistogram("Histogram", "Value", "Count", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setBarPainter(new StandardXYBarPainter());
    double redd[] = new double[red.size()];
    for (int i = 0; i < red.size(); i++) {
        redd[i] = (int) r[i];
    }//from   w  w  w  .  ja v  a2s. com
    dataset.addSeries("Red", redd, 256);

    double greenn[] = new double[green.size()];
    for (int i = 0; i < green.size(); i++) {
        greenn[i] = (int) g[i];
    }
    dataset.addSeries("Green", greenn, 256);

    double bluee[] = new double[blue.size()];
    for (int i = 0; i < blue.size(); i++) {
        bluee[i] = (int) b[i];
    }
    dataset.addSeries("Blue", bluee, 256);

    Paint[] paintArray = { new Color(0x80ff0000, true), new Color(0x8000ff00, true),
            new Color(0x800000ff, true) };

    plot.setDrawingSupplier(
            new DefaultDrawingSupplier(paintArray, DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
                    DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));
    ChartPanel panel = new ChartPanel(chart);
    panel.setMouseWheelEnabled(true);
    return panel;
}

From source file:org.gephi.ui.utils.ChartsUtils.java

/**
 * Build new histogram from the given numbers array using a default title and xLabel.
 * String dataName will be used for yLabel.
 * @param numbers Numbers for the histogram
 * @param dataName Name of the numbers data
 * @param divisions Divisions for the histogram
 * @return Prepared histogram/*from ww  w  .  j  a  va  2 s . c o m*/
 */
public static JFreeChart buildHistogram(final Number[] numbers, final String dataName, final int divisions) {
    if (numbers == null || numbers.length == 0) {
        return null;
    }

    HistogramDataset dataset = new HistogramDataset();
    dataset.setType(HistogramType.FREQUENCY);
    double[] doubleNumbers = new double[numbers.length];
    for (int i = 0; i < doubleNumbers.length; i++) {
        doubleNumbers[i] = numbers[i].doubleValue();
    }

    dataset.addSeries(dataName, doubleNumbers, divisions > 0 ? divisions : 10);//Use 10 divisions if divisions number is invalid.

    JFreeChart histogram = ChartFactory.createHistogram(getMessage("ChartsUtils.report.histogram.title"),
            dataName, getMessage("ChartsUtils.report.histogram.yLabel"), dataset, PlotOrientation.VERTICAL,
            true, true, false);

    return histogram;
}

From source file:com.rapidminer.gui.plotter.charts.HistogramChart.java

@Override
protected void updatePlotter() {
    prepareData();/*from w w w . ja  va  2  s . co m*/

    String maxClassesProperty = ParameterService
            .getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_COLORS_CLASSLIMIT);
    int maxClasses = 20;
    try {
        if (maxClassesProperty != null) {
            maxClasses = Integer.parseInt(maxClassesProperty);
        }
    } catch (NumberFormatException e) {
        // LogService.getGlobal().log("Deviation plotter: cannot parse property 'rapidminer.gui.plotter.colors.classlimit', using maximal 20 different classes.",
        // LogService.WARNING);
        LogService.getRoot().log(Level.WARNING,
                "com.rapidminer.gui.plotter.charts.HistogramChart.parsing_property_error");
    }
    int categoryCount = this.histogramDataset.getSeriesCount();
    boolean createLegend = categoryCount > 0 && categoryCount < maxClasses && this.drawLegend;

    JFreeChart chart = ChartFactory.createHistogram(null, // title
            "Value", "Frequency", histogramDataset, PlotOrientation.VERTICAL, createLegend, true, // tooltips
            false); // urls

    XYPlot plot = chart.getXYPlot();
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setBackgroundPaint(Color.WHITE);
    plot.setForegroundAlpha(this.opaqueness);

    XYBarRenderer renderer = new XYBarRenderer();
    if (histogramDataset.getSeriesCount() == 1) {
        renderer.setSeriesPaint(0, ColorProvider.reduceColorBrightness(Color.RED));
        renderer.setSeriesFillPaint(0, ColorProvider.reduceColorBrightness(Color.RED));
    } else {
        for (int i = 0; i < histogramDataset.getSeriesCount(); i++) {
            Color color = getColorProvider(true)
                    .getPointColor((double) i / (double) (histogramDataset.getSeriesCount() - 1));
            renderer.setSeriesPaint(i, color);
            renderer.setSeriesFillPaint(i, color);
        }
    }
    renderer.setBarPainter(new RapidXYBarPainter());
    // renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setDrawBarOutline(true);
    renderer.setShadowVisible(false);
    plot.setRenderer(renderer);

    plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD);
    plot.getRangeAxis().setTickLabelFont(LABEL_FONT);

    plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD);
    plot.getDomainAxis().setTickLabelFont(LABEL_FONT);
    setRange(plot.getDomainAxis());

    // display correct x-Axis labels
    int count = histogramDataset.getSeriesCount();
    if (count > 0) {
        String key = histogramDataset.getSeriesKey(0).toString();
        int index = this.dataTable.getColumnIndex(key);
        if (index >= 0) {
            // Correctly displays nominal values on x-axis
            if (count == 1 && this.dataTable.isNominal(index)) {
                String[] values = new String[dataTable.getNumberOfValues(index)];
                for (int i = 0; i < values.length; i++) {
                    values[i] = dataTable.mapIndex(index, i);
                }
                plot.setDomainAxis(new SymbolAxis(key, values));
            }
            // Correctly displays dates on x-axis
            if (this.dataTable.isDateTime(index)) {
                boolean applyDateAxis = true;
                if (count > 1) {
                    for (int i = 1; i < count; i++) {
                        index = this.dataTable.getColumnIndex(histogramDataset.getSeriesKey(i).toString());
                        if (index < 0 || !this.dataTable.isDateTime(index)) {
                            applyDateAxis = false;
                            break;
                        }
                    }
                }
                if (applyDateAxis) {
                    DateAxis dateAxis = new DateAxis();
                    dateAxis.setDateFormatOverride(Tools.DATE_TIME_FORMAT.get());
                    plot.setDomainAxis(dateAxis);
                }
            }
        }

        // rotate labels
        if (isLabelRotating()) {
            plot.getDomainAxis().setTickLabelsVisible(true);
            plot.getDomainAxis().setVerticalTickLabels(true);
        }
    }

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

    // legend settings
    LegendTitle legend = chart.getLegend();
    if (legend != null) {
        legend.setPosition(RectangleEdge.TOP);
        legend.setFrame(BlockBorder.NONE);
        legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
        legend.setItemFont(LABEL_FONT);
    }

    AbstractChartPanel panel = getPlotterPanel();
    if (panel == null) {
        panel = createPanel(chart);
    } else {
        panel.setChart(chart);
    }

    // Disable zooming for Histogram-Charts
    panel.setRangeZoomable(false);
    panel.setDomainZoomable(false);

    // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
    panel.getChartRenderingInfo().setEntityCollection(null);
}

From source file:org.jgrasstools.gears.ui.OmsMatrixCharter.java

private JFreeChart doBarChart() {
    XYSeriesCollection collection = getSeriesCollection();
    XYBarDataset xyBarDataset = new XYBarDataset(collection, minInterval);
    PlotOrientation orientation = PlotOrientation.VERTICAL;
    if (doHorizontal) {
        orientation = PlotOrientation.HORIZONTAL;
    }//  w w  w.  j  a v  a  2s  .c om
    JFreeChart chart = ChartFactory.createHistogram(inTitle, inLabels[0], inLabels[1], xyBarDataset,
            orientation, doLegend, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setForegroundAlpha(0.85f);
    NumberAxis yAxis = (NumberAxis) plot.getRangeAxis();
    yAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());
    double delta = (max - min) * 0.1;
    yAxis.setRange(min, max + delta);
    yAxis.setMinorTickCount(4);
    yAxis.setMinorTickMarksVisible(true);
    if (inFormats != null && inFormats.length > 0 && inFormats[1].trim().length() > 0) {
        yAxis.setNumberFormatOverride(new DecimalFormat(inFormats[1]));
    }

    if (inFormats != null && inFormats.length > 0 && inFormats[0].trim().length() > 0) {
        ValueAxis domainAxis = plot.getDomainAxis();
        if (domainAxis instanceof NumberAxis) {
            NumberAxis xAxis = (NumberAxis) domainAxis;
            xAxis.setNumberFormatOverride(new DecimalFormat(inFormats[0]));
        }
    }

    XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setBarPainter(new StandardXYBarPainter());
    renderer.setShadowVisible(false);

    if (inColors != null) {
        String[] colorSplit = inColors.split(";");
        for (int i = 0; i < colorSplit.length; i++) {
            String[] split = colorSplit[i].split(",");
            int r = (int) Double.parseDouble(split[0]);
            int g = (int) Double.parseDouble(split[1]);
            int b = (int) Double.parseDouble(split[2]);
            renderer.setSeriesPaint(i, new Color(r, g, b));
        }
    }

    return chart;
}

From source file:playground.anhorni.surprice.analysis.ModeSharesEventHandler.java

private JFreeChart getTraveledXYsHistogram(final int numberOfBins) {
    String title = this.xy + " distribution by mode";
    String xLabel = "distance (m)";
    if (this.xy.equals("times")) {
        xLabel = "time (s)";
    }//from   ww w.  ja va  2s.  c  om
    String yLabel = "number of trips";
    boolean legend = true;
    boolean tooltips = false;
    boolean urls = false;
    HistogramDataset data = this.getHistogramDataset(numberOfBins);

    JFreeChart chart = ChartFactory.createHistogram(title, xLabel, yLabel, data, PlotOrientation.VERTICAL,
            legend, tooltips, urls);
    return chart;
}

From source file:com.compomics.cell_coord.gui.controller.computation.ComputationDataController.java

/**
 *
 * @param track/*from w ww .j a va2s.  com*/
 */
private void plotDeltaY(Track track) {
    Double[] deltaYValues = ComputationUtils.transpose2DArray(track.getSteps())[1];
    double[] values = ArrayUtils.toPrimitive(ComputationUtils.excludeNullValues(deltaYValues));
    HistogramDataset histogramDataset = new HistogramDataset();
    histogramDataset.addSeries("", values, 2);
    String title = "delta_y_values for track: " + track.getTrackid();
    JFreeChart jFreeChart = ChartFactory.createHistogram(title, "delta_y", "count", histogramDataset,
            PlotOrientation.VERTICAL, true, true, true);
    ChartPanel chartPanel = new ChartPanel(jFreeChart);
    computationDataPanel.getDeltayPlotPanel().removeAll();
    computationDataPanel.getDeltayPlotPanel().add(chartPanel, gridBagConstraints);
    computationDataPanel.getDeltayPlotPanel().revalidate();
    computationDataPanel.getDeltayPlotPanel().repaint();
}

From source file:se.sics.kompics.p2p.monitor.cyclon.server.CyclonMonitorServer.java

private void printAlivePeers(StringBuilder sb, boolean showPeers) {

    long t0 = System.currentTimeMillis();
    GraphUtil g = new GraphUtil(alivePeers);
    long t1 = System.currentTimeMillis();

    double id, od, cc, pl, istd;
    int diameter;

    id = g.getMeanInDegree();//from w w w  .  j ava 2s  .  co m
    istd = g.getInDegreeStdDev();
    od = g.getMeanOutDegree();
    cc = g.getMeanClusteringCoefficient();
    pl = g.getMeanPathLength();
    diameter = g.getDiameter();
    int netSize = g.getNetworkSize();

    sb.append("<h2 align=\"center\" class=\"style2\">");
    sb.append("View of Cyclon Random Overlay:</h2>");
    sb.append("<table width=\"400\" border=\"1\" align=\"center\"><tr>");
    sb.append("<th class=\"style2\" width=\"250\" scope=\"col\">Metric");
    sb.append("</th><th class=\"style2\"");
    sb.append(" width=\"150\" scope=\"col\">Value</th></tr><tr>");

    sb.append("<td>Network size</td><td><div align=\"center\">");
    sb.append(netSize).append("</div></td></tr>");
    sb.append("<td>Disconnected node pairs</td><td><div align=\"center\">");
    sb.append(g.getInfinitePathCount()).append("/");
    sb.append(netSize * (netSize - 1)).append("</div></td></tr>");
    sb.append("<td>Diameter</td><td><div align=\"center\">");
    sb.append(diameter).append("</div></td></tr>");
    sb.append("<td>Average path length</td><td><div align=\"center\">");
    sb.append(String.format("%.4f", pl)).append("</div></td></tr>");
    sb.append("<td>Clustering-coefficient</td><td><div align=\"center\">");
    sb.append(String.format("%.4f", cc)).append("</div></td></tr>");
    sb.append("<td>Average in-degree</td><td><div align=\"center\">");
    sb.append(String.format("%.4f", id)).append("</div></td></tr>");
    sb.append("<td>In-degree standard deviation</td><td><div align=\"center\">");
    sb.append(String.format("%.4f", istd)).append("</div></td></tr>");
    sb.append("<td>Average out-degree</td><td><div align=\"center\">");
    sb.append(String.format("%.4f", od)).append("</div></td></tr>");
    sb.append("</table>");

    // print in-degree distribution
    HistogramDataset dataset = new HistogramDataset();
    double[] values = g.getInDegrees();
    int min = (int) g.getMinInDegree(), max = (int) g.getMaxInDegree();
    int bins = max - min;
    bins = bins < 1 ? 1 : bins;
    dataset.addSeries("In-degree distribution", values, bins, min, max);
    JFreeChart chart = ChartFactory.createHistogram(null, null, null, dataset, PlotOrientation.VERTICAL, true,
            false, false);
    // chart.getXYPlot().setForegroundAlpha(0.95f);
    BufferedImage image = chart.createBufferedImage(800, 300);

    String imageString = "";
    try {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        ImageIO.write(image, "png", out);
        out.close();
        Base64 bencoder = new Base64();
        imageString = new String(bencoder.encode(out.toByteArray()));
        imageString = "data:image/png;base64," + imageString;
    } catch (IOException e) {
        sb.append(e);
    }

    sb.append("<br><div align=\"center\"><img src=\"").append(imageString);
    sb.append("\" alt=\"In-degree distribution " + "\" /></div><br>");

    sb.append("<div align=\"center\">It took ").append(t1 - t0);
    sb.append("ms to compute these statistics.<br>");

    // refresh form
    sb.append("<form method=\"get\" name=\"rfrshFrm\" id=\"rfrshFrm\">");
    sb.append("<label>Show peers ");
    sb.append("<input name=\"peers\" type=\"checkbox\" id=\"peers\" />");
    // sb.append("checked=\"").append("false").append("\" />");
    sb.append("<input type=\"submit\" value=\"Refresh\" />");
    sb.append("</form></div>");

    if (!showPeers) {
        return;
    }

    sb.append("<h2 align=\"center\" class=\"style2\">");
    sb.append("Individual peers:</h2>");
    sb.append("<table width=\"1300\" border=\"1\" align=\"center\"><tr>");
    sb.append("<th class=\"style2\" width=\"50\" scope=\"col\">Count</th>");
    sb.append("<th class=\"style2\" width=\"50\" scope=\"col\">Peer</th>");
    sb.append("<th class=\"style2\" width=\"800\" scope=\"col\">Neighbors</th>");
    sb.append("<th class=\"style2\" width=\"50\" scope=\"col\">In Degree</th>");
    sb.append("<th class=\"style2\" width=\"50\" scope=\"col\">Out Degree</th>");
    sb.append("<th class=\"style2\" width=\"100\" scope=\"col\">Cluestering Coefficient</th>");
    sb.append("<th class=\"style2\" width=\"50\" scope=\"col\">Age</th>");
    sb.append("<th class=\"style2\" width=\"100\" scope=\"col\">Freshness</th></tr>");

    int count = 1;

    for (OverlayAddress address : alivePeers.keySet()) {
        CyclonNeighbors neighbors = alivePeers.get(address);

        List<CyclonNodeDescriptor> descriptors = neighbors.getDescriptors();
        Collections.sort(descriptors);

        sb.append("<tr>");
        sb.append("<td><div align=\"center\">").append(count++);
        // sb.append("(").append(g.map.get(address)).append(")");
        sb.append("</div></td>");

        // print peer address
        sb.append("</div></td><td bgcolor=\"#99CCFF\"><div align=\"center\">");
        appendPeerLink(sb, address);
        sb.append("</div></td>");

        // print neighbors
        if (descriptors != null) {
            sb.append("<td><div align=\"left\">");
            sb.append("[");
            Iterator<CyclonNodeDescriptor> iter = descriptors.iterator();
            while (iter.hasNext()) {
                appendPeerLink(sb, iter.next().getCyclonAddress());
                if (iter.hasNext()) {
                    sb.append(", ");
                }
            }
            sb.append("]");
        } else {
            sb.append("<td bgcolor=\"#FFCCFF\"><div align=\"left\">");
            sb.append("[empty]");
        }
        sb.append("</div></td>");

        int v = g.getNodeIndexByAddress(address);

        // print in-degree
        sb.append("<td><div align=\"center\">").append(g.getInDegree(v));
        sb.append("</div></td>");
        // print out-degree
        sb.append("<td><div align=\"center\">").append(g.getOutDegree(v));
        sb.append("</div></td>");
        // print clustering coefficient

        // directedGraph

        sb.append("<td><div align=\"center\">").append(String.format("%.4f", g.getClustering(v)));
        sb.append("</div></td>");

        long now = System.currentTimeMillis();
        OverlayViewEntry viewEntry = view.get(address);

        // print age
        sb.append("<td><div align=\"right\">");
        sb.append(durationToString(now - viewEntry.getAddedAt()));
        sb.append("</div></td>");

        // print freshness
        sb.append("<td><div align=\"right\">");
        sb.append(durationToString(now - viewEntry.getRefreshedAt()));
        sb.append("</div></td>");

        sb.append("</tr>");
    }
    sb.append("</table>");
}

From source file:herbie.running.analysis.ModeSharesEventHandler.java

public JFreeChart getTraveledDistancesHistogram(final int numberOfBins) {
    String title = "Traveled distances distribution by mode";
    String xLabel = "Distance (m)";
    String yLabel = "Number of trips";
    boolean legend = true;
    boolean tooltips = false;
    boolean urls = false;
    //XYSeriesCollection data = new XYSeriesCollection();
    HistogramDataset data = getHistogramDataset(numberOfBins);
    double step = this.maxDistance / numberOfBins;

    //for (String mode : this.rawData.keySet()) {
    //   data.addSeries(getTraveledDistancesHistogram(mode, step));
    //}//from  ww  w.  j  a v  a 2 s .  co m

    JFreeChart chart = ChartFactory.createHistogram(title, xLabel, yLabel, data, PlotOrientation.VERTICAL,
            legend, tooltips, urls);
    chart.getXYPlot().setForegroundAlpha(0.5F);

    return chart;
}

From source file:com.rapidminer.gui.plotter.charts.HistogramColorChart.java

@Override
protected void updatePlotter() {
    prepareData();/*from w  w w . ja  v a 2 s.  co  m*/

    String maxClassesProperty = ParameterService
            .getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_COLORS_CLASSLIMIT);
    int maxClasses = 20;
    try {
        if (maxClassesProperty != null) {
            maxClasses = Integer.parseInt(maxClassesProperty);
        }
    } catch (NumberFormatException e) {
        // LogService.getGlobal().log("Deviation plotter: cannot parse property 'rapidminer.gui.plotter.colors.classlimit', using maximal 20 different classes.",
        // LogService.WARNING);
        LogService.getRoot().log(Level.WARNING,
                "com.rapidminer.gui.plotter.charts.HistogramColorChart.parsing_property_error");
    }

    JFreeChart chart = null;
    if (nominal) {
        // ** nominal **
        int categoryCount = this.categoryDataset.getRowCount();
        boolean createLegend = categoryCount > 0 && categoryCount < maxClasses && this.drawLegend;

        String domainName = valueColumn >= 0 ? this.dataTable.getColumnName(valueColumn) : "Value";

        chart = ChartFactory.createBarChart(null, // title
                domainName, "Frequency", categoryDataset, PlotOrientation.VERTICAL, createLegend, true, // tooltips
                false); // urls

        CategoryPlot plot = chart.getCategoryPlot();
        plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
        plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
        plot.setBackgroundPaint(Color.WHITE);
        plot.setForegroundAlpha(this.opaqueness);

        BarRenderer renderer = new BarRenderer();
        if (categoryDataset.getRowCount() == 1) {
            renderer.setSeriesPaint(0, Color.RED);
            renderer.setSeriesFillPaint(0, Color.RED);
        } else {
            for (int i = 0; i < categoryDataset.getRowCount(); i++) {
                Color color = getColorProvider(true)
                        .getPointColor((double) i / (double) (categoryDataset.getRowCount() - 1));
                renderer.setSeriesPaint(i, color);
                renderer.setSeriesFillPaint(i, color);
            }
        }
        renderer.setBarPainter(new RapidBarPainter());
        renderer.setDrawBarOutline(true);
        plot.setRenderer(renderer);

        plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD);
        plot.getRangeAxis().setTickLabelFont(LABEL_FONT);

        plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD);
        plot.getDomainAxis().setTickLabelFont(LABEL_FONT);

        // rotate labels
        if (isLabelRotating()) {
            plot.getDomainAxis().setTickLabelsVisible(true);
            plot.getDomainAxis().setCategoryLabelPositions(
                    CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0d));
        }
    } else {
        // ** numerical **
        int categoryCount = this.histogramDataset.getSeriesCount();
        boolean createLegend = categoryCount > 0 && categoryCount < maxClasses && this.drawLegend;

        String domainName = valueColumn >= 0 ? this.dataTable.getColumnName(valueColumn) : "Value";
        chart = ChartFactory.createHistogram(null, // title
                domainName, "Frequency", histogramDataset, PlotOrientation.VERTICAL, createLegend, true, // tooltips
                false); // urls

        XYPlot plot = chart.getXYPlot();
        plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
        plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
        plot.setBackgroundPaint(Color.WHITE);
        plot.setForegroundAlpha(this.opaqueness);

        XYBarRenderer renderer = new XYBarRenderer();
        if (histogramDataset.getSeriesCount() == 1) {
            renderer.setSeriesPaint(0, Color.RED);
            renderer.setSeriesFillPaint(0, Color.RED);
        } else {
            for (int i = 0; i < histogramDataset.getSeriesCount(); i++) {
                Color color = getColorProvider(true)
                        .getPointColor((double) i / (double) (histogramDataset.getSeriesCount() - 1));
                renderer.setSeriesPaint(i, color);
                renderer.setSeriesFillPaint(i, color);
            }
        }
        renderer.setBarPainter(new RapidXYBarPainter());
        renderer.setDrawBarOutline(true);
        plot.setRenderer(renderer);

        plot.getRangeAxis().setLabelFont(LABEL_FONT_BOLD);
        plot.getRangeAxis().setTickLabelFont(LABEL_FONT);

        plot.getDomainAxis().setLabelFont(LABEL_FONT_BOLD);
        plot.getDomainAxis().setTickLabelFont(LABEL_FONT);

        // Correctly displays dates on x-axis
        if (datetime) {
            DateAxis dateAxis = new DateAxis();
            dateAxis.setDateFormatOverride(Tools.DATE_TIME_FORMAT.get());
            plot.setDomainAxis(dateAxis);
        }

        // range axis
        Range range = getRangeForDimension(valueColumn);
        if (range != null) {
            plot.getDomainAxis().setRange(range);
        }

        // rotate labels
        if (isLabelRotating()) {
            plot.getDomainAxis().setTickLabelsVisible(true);
            plot.getDomainAxis().setVerticalTickLabels(true);
        }

        if (histogramDataset.getSeriesCount() == 1) {
            String key = histogramDataset.getSeriesKey(0).toString();
            int index = this.dataTable.getColumnIndex(key);
            if (index >= 0) {
                if (this.dataTable.isNominal(index)) {
                    String[] values = new String[dataTable.getNumberOfValues(index)];
                    for (int i = 0; i < values.length; i++) {
                        values[i] = dataTable.mapIndex(index, i);
                    }
                    plot.setDomainAxis(new SymbolAxis(key, values));

                    // rotate labels
                    if (isLabelRotating()) {
                        plot.getDomainAxis().setTickLabelsVisible(true);
                        plot.getDomainAxis().setVerticalTickLabels(true);
                    }
                }
            }
        }
    }

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

    // legend settings
    LegendTitle legend = chart.getLegend();
    if (legend != null) {
        legend.setPosition(RectangleEdge.TOP);
        legend.setFrame(BlockBorder.NONE);
        legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
        legend.setItemFont(LABEL_FONT);
    }

    AbstractChartPanel panel = getPlotterPanel();
    if (panel == null) {
        panel = createPanel(chart);
    } else {
        panel.setChart(chart);
    }

    // Disable zooming for Histogram-Charts
    panel.setRangeZoomable(false);
    panel.setDomainZoomable(false);

    // ATTENTION: WITHOUT THIS WE GET SEVERE MEMORY LEAKS!!!
    panel.getChartRenderingInfo().setEntityCollection(null);
}