Search in sources :

Example 1 with ExtendedCategoryAxis

use of org.jfree.chart.axis.ExtendedCategoryAxis in project opennms by OpenNMS.

the class ChartUtils method addSubLabels.

/**
 * @param barChart TODO
 * @param subLabelClass
 */
private static void addSubLabels(JFreeChart barChart, String subLabelClass) {
    ExtendedCategoryAxis subLabels;
    CategoryPlot plot = barChart.getCategoryPlot();
    try {
        subLabels = (ExtendedCategoryAxis) Class.forName(subLabelClass).newInstance();
        List<?> cats = plot.getCategories();
        for (int i = 0; i < cats.size(); i++) {
            subLabels.addSubLabel((Comparable<?>) cats.get(i), cats.get(i).toString());
        }
        plot.setDomainAxis(subLabels);
    } catch (InstantiationException e) {
        LOG.error("getBarChart: Couldn't instantiate configured CategorySubLabels class: {}", subLabelClass, e);
    } catch (IllegalAccessException e) {
        LOG.error("getBarChart: Couldn't instantiate configured CategorySubLabels class: {}", subLabelClass, e);
    } catch (ClassNotFoundException e) {
        LOG.error("getBarChart: Couldn't instantiate configured CategorySubLabels class: {}", subLabelClass, e);
    }
}
Also used : ExtendedCategoryAxis(org.jfree.chart.axis.ExtendedCategoryAxis) CategoryPlot(org.jfree.chart.plot.CategoryPlot) Paint(java.awt.Paint)

Aggregations

Paint (java.awt.Paint)1 ExtendedCategoryAxis (org.jfree.chart.axis.ExtendedCategoryAxis)1 CategoryPlot (org.jfree.chart.plot.CategoryPlot)1