Search in sources :

Example 1 with CategoryItemRenderer

use of org.jfree.chart.renderer.category.CategoryItemRenderer in project adempiere by adempiere.

the class GraphBuilder method setupCategoryChart.

private void setupCategoryChart(JFreeChart chart) {
    CategoryPlot plot = chart.getCategoryPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, new Color(92 / 255f, 178 / 255f, 232 / 255f));
    renderer.setSeriesPaint(1, new Color(56 / 255f, 97 / 255f, 119 / 255f));
    renderer.setSeriesPaint(2, new Color(242 / 255f, 70 / 255f, 78 / 255f));
    renderer.setSeriesPaint(3, Color.orange);
    renderer.setSeriesPaint(4, new Color(147 / 255f, 196 / 255f, 51 / 255f));
    renderer.setSeriesPaint(5, new Color(210 / 255f, 247 / 255f, 91 / 255f));
    renderer.setSeriesPaint(6, new Color(129 / 255f, 235 / 255f, 249 / 255f));
    renderer.setSeriesPaint(7, new Color(60 / 255f, 84 / 255f, 8 / 255f));
    renderer.setSeriesPaint(8, new Color(0.8f, 0.8f, 0.8f));
}
Also used : CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) Color(java.awt.Color) CategoryPlot(org.jfree.chart.plot.CategoryPlot)

Example 2 with CategoryItemRenderer

use of org.jfree.chart.renderer.category.CategoryItemRenderer in project qpid-broker-j by apache.

the class CategoryStrokeAndPaintApplier method setSeriesShape.

@Override
public void setSeriesShape(final int seriesIndex, final java.awt.Shape shape, final JFreeChart targetChart) {
    CategoryItemRenderer renderer = targetChart.getCategoryPlot().getRenderer();
    if (renderer instanceof LineAndShapeRenderer) {
        LineAndShapeRenderer lineAndShapeRenderer = (LineAndShapeRenderer) renderer;
        lineAndShapeRenderer.setSeriesShapesVisible(seriesIndex, true);
        lineAndShapeRenderer.setSeriesShape(seriesIndex, shape);
    }
}
Also used : LineAndShapeRenderer(org.jfree.chart.renderer.category.LineAndShapeRenderer) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer)

Example 3 with CategoryItemRenderer

use of org.jfree.chart.renderer.category.CategoryItemRenderer in project qpid-broker-j by apache.

the class StatisticalBarChartBuilder method createChartImpl.

@Override
public JFreeChart createChartImpl(String title, String xAxisTitle, String yAxisTitle, final Dataset dataset, PlotOrientation plotOrientation, boolean showLegend, boolean showToolTips, boolean showUrls) {
    CategoryAxis xAxis = new CategoryAxis(xAxisTitle);
    ValueAxis yAxis = new NumberAxis(yAxisTitle);
    CategoryItemRenderer renderer = new StatisticalBarRenderer();
    CategoryPlot plot = new CategoryPlot((StatisticalCategoryDataset) dataset, xAxis, yAxis, renderer);
    JFreeChart chart = new JFreeChart(title, new Font("Arial", Font.PLAIN, 10), plot, true);
    chart.getCategoryPlot().getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    return chart;
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) StatisticalBarRenderer(org.jfree.chart.renderer.category.StatisticalBarRenderer) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) CategoryAxis(org.jfree.chart.axis.CategoryAxis) ValueAxis(org.jfree.chart.axis.ValueAxis) CategoryPlot(org.jfree.chart.plot.CategoryPlot) JFreeChart(org.jfree.chart.JFreeChart) Font(java.awt.Font)

Example 4 with CategoryItemRenderer

use of org.jfree.chart.renderer.category.CategoryItemRenderer in project processdash by dtuma.

the class AreaChart method configureConsistentColors.

private void configureConsistentColors(CategoryPlot plot, CategoryDataset catData) {
    DefaultDrawingSupplier s = new DefaultDrawingSupplier();
    String skip = getParameter("consistentSkip");
    if (skip != null)
        for (int i = Integer.parseInt(skip); i-- > 0; ) s.getNextPaint();
    CategoryItemRenderer rend = plot.getRenderer();
    for (int i = 0; i < catData.getRowCount(); i++) {
        Paint paint = s.getNextPaint();
        rend.setSeriesPaint(i, paint);
    }
}
Also used : CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) Paint(java.awt.Paint) DefaultDrawingSupplier(org.jfree.chart.plot.DefaultDrawingSupplier) Paint(java.awt.Paint)

Example 5 with CategoryItemRenderer

use of org.jfree.chart.renderer.category.CategoryItemRenderer in project xwiki-platform by xwiki.

the class BarPlotFactory method create.

@Override
public Plot create(DataSource dataSource, ChartParams params) throws GenerateException, DataSourceException {
    Class rendererClass = params.getClass(ChartParams.RENDERER);
    if (rendererClass == null || CategoryItemRenderer.class.isAssignableFrom(rendererClass)) {
        CategoryItemRenderer renderer;
        if (rendererClass != null) {
            try {
                Constructor ctor = rendererClass.getConstructor(new Class[] {});
                renderer = (CategoryItemRenderer) ctor.newInstance(new Object[] {});
            } catch (Throwable e) {
                throw new GenerateException(e);
            }
        } else {
            renderer = new BarRenderer();
        }
        return CategoryPlotFactory.getInstance().create(dataSource, renderer, params);
    } else if (XYItemRenderer.class.isAssignableFrom(rendererClass)) {
        XYItemRenderer renderer;
        try {
            Constructor ctor = rendererClass.getConstructor(new Class[] {});
            renderer = (XYItemRenderer) ctor.newInstance(new Object[] {});
        } catch (Throwable e) {
            throw new GenerateException(e);
        }
        ChartCustomizer.customizeXYItemRenderer(renderer, params);
        return XYPlotFactory.getInstance().create(dataSource, renderer, params);
    } else {
        throw new GenerateException("Incompatible renderer class: " + rendererClass);
    }
}
Also used : CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) Constructor(java.lang.reflect.Constructor) BarRenderer(org.jfree.chart.renderer.category.BarRenderer) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) GenerateException(com.xpn.xwiki.plugin.charts.exceptions.GenerateException)

Aggregations

CategoryItemRenderer (org.jfree.chart.renderer.category.CategoryItemRenderer)17 CategoryPlot (org.jfree.chart.plot.CategoryPlot)9 JFreeChart (org.jfree.chart.JFreeChart)6 Paint (java.awt.Paint)4 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)4 GenerateException (com.xpn.xwiki.plugin.charts.exceptions.GenerateException)3 Constructor (java.lang.reflect.Constructor)3 CategoryAxis (org.jfree.chart.axis.CategoryAxis)3 Font (java.awt.Font)2 NumberAxis (org.jfree.chart.axis.NumberAxis)2 ValueAxis (org.jfree.chart.axis.ValueAxis)2 BarRenderer (org.jfree.chart.renderer.category.BarRenderer)2 LineAndShapeRenderer (org.jfree.chart.renderer.category.LineAndShapeRenderer)2 CategoryDataset (org.jfree.data.category.CategoryDataset)2 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)2 Color (java.awt.Color)1 Rectangle2D (java.awt.geom.Rectangle2D)1 DecimalFormat (java.text.DecimalFormat)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1