Search in sources :

Example 41 with CategoryItemRenderer

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

the class CommonBarChartAction method setPlotColor.

private void setPlotColor(CategoryPlot plot, List<String> names, List<String> colors) throws Exception {
    Paint[] paints = new Paint[colors.size()];
    for (int ix = 0; ix < names.size(); ix++) {
        paints[ix] = Color.decode(colors.get(ix));
    }
    CategoryItemRenderer renderer = new CustomRenderer(paints);
    plot.setRenderer(renderer);
}
Also used : CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) Paint(java.awt.Paint) Paint(java.awt.Paint)

Example 42 with CategoryItemRenderer

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

the class AreaChart method configureIndividualColors.

private void configureIndividualColors(CategoryPlot plot, CategoryDataset catData) {
    CategoryItemRenderer rend = plot.getRenderer();
    for (int i = 0; i < catData.getRowCount(); i++) {
        String colorKey = "c" + (i + 1);
        String color = getParameter(colorKey);
        if (color != null)
            rend.setSeriesPaint(i, Color.decode("#" + color));
    }
}
Also used : CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) Paint(java.awt.Paint)

Example 43 with CategoryItemRenderer

use of org.jfree.chart.renderer.category.CategoryItemRenderer in project tdq-studio-se by Talend.

the class ChartDecorator method decorateBenfordLawChartByKCD.

/**
 * Decorate the benford law chart. in this method the line chart will be overlay on top of bar chart.
 *
 * @param dataset
 * @param barChart
 * @param title
 * @param categoryAxisLabel
 * @param dotChartLabels
 * @param formalValues
 * @return JFreeChart
 */
@SuppressWarnings("deprecation")
public static JFreeChart decorateBenfordLawChartByKCD(CategoryDataset dataset, Object customerDataset, JFreeChart barChart, String title, String categoryAxisLabel, List<String> dotChartLabels, double[] formalValues) {
    CategoryPlot barplot = barChart.getCategoryPlot();
    decorateBarChart(barChart, new BenfordLawLineAndShapeRenderer());
    // display percentage on top of the bar
    DecimalFormat df = new DecimalFormat(PERCENT_FORMAT);
    // $NON-NLS-1$
    barplot.getRenderer().setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{2}", df));
    barplot.getRenderer().setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_CENTER));
    // set the display of Y axis
    NumberAxis numAxis = (NumberAxis) barplot.getRangeAxis();
    numAxis.setNumberFormatOverride(df);
    CategoryDataset lineDataset = getLineDataset(dotChartLabels, formalValues);
    JFreeChart lineChart = ChartFactory.createLineChart(null, title, categoryAxisLabel, lineDataset, PlotOrientation.VERTICAL, false, false, false);
    CategoryPlot plot = lineChart.getCategoryPlot();
    if (customerDataset != null) {
        barplot.setDataset(2, new EncapsulationCumstomerDataset(dataset, customerDataset));
    }
    // show the value on the right axis of the chart(keep the comment)
    // NumberAxis numberaxis = new NumberAxis(DefaultMessagesImpl.getString("TopChartFactory.Value"));
    // plot.setRangeAxis(10, numberaxis);
    NumberAxis vn = (NumberAxis) plot.getRangeAxis();
    vn.setNumberFormatOverride(df);
    // set points format
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setPaint(COLOR_LIST.get(1));
    renderer.setSeriesShape(1, new Rectangle2D.Double(-1.5, -1.5, 3, 3));
    // show the point shape
    renderer.setShapesVisible(true);
    // do not show the line
    renderer.setBaseLinesVisible(false);
    // add the bar chart into the line chart
    CategoryItemRenderer barChartRender = barplot.getRenderer();
    barplot.setDataset(0, lineDataset);
    barplot.setRenderer(0, plot.getRenderer());
    barplot.setDataset(1, dataset);
    barplot.setRenderer(1, barChartRender);
    return barChart;
}
Also used : LineAndShapeRenderer(org.jfree.chart.renderer.category.LineAndShapeRenderer) StandardCategoryItemLabelGenerator(org.jfree.chart.labels.StandardCategoryItemLabelGenerator) NumberAxis(org.jfree.chart.axis.NumberAxis) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) DecimalFormat(java.text.DecimalFormat) Rectangle2D(java.awt.geom.Rectangle2D) CategoryPlot(org.jfree.chart.plot.CategoryPlot) JFreeChart(org.jfree.chart.JFreeChart) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) CategoryDataset(org.jfree.data.category.CategoryDataset) EncapsulationCumstomerDataset(org.talend.dataprofiler.chart.util.EncapsulationCumstomerDataset) ItemLabelPosition(org.jfree.chart.labels.ItemLabelPosition)

Example 44 with CategoryItemRenderer

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

the class WatchDogView method createStackedBarChart.

private JFreeChart createStackedBarChart(CategoryDataset dataset, String title, String xAxisName, String yAxisName) {
    JFreeChart chart = ChartFactory.createStackedBarChart3D(title, xAxisName, yAxisName, dataset);
    setLegendInvisible(chart);
    CategoryPlot plot = chart.getCategoryPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, makeColorTransparent(Color.green));
    renderer.setSeriesPaint(1, makeColorTransparent(Color.red));
    renderer.setSeriesPaint(2, makeColorTransparent(Color.blue));
    return chart;
}
Also used : CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) JFreeChart(org.jfree.chart.JFreeChart) CategoryPlot(org.jfree.chart.plot.CategoryPlot)

Example 45 with CategoryItemRenderer

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

the class WatchDogView method createStackedBarChart.

private JFreeChart createStackedBarChart(CategoryDataset dataset, String title, String xAxisName, String yAxisName) {
    JFreeChart chart = ChartFactory.createStackedBarChart3D(title, xAxisName, yAxisName, dataset);
    chart.getLegend().setVisible(false);
    CategoryPlot plot = chart.getCategoryPlot();
    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, makeColorTransparent(JBColor.GREEN));
    renderer.setSeriesPaint(1, makeColorTransparent(JBColor.RED));
    renderer.setSeriesPaint(2, makeColorTransparent(JBColor.BLUE));
    return chart;
}
Also used : CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) JFreeChart(org.jfree.chart.JFreeChart) CategoryPlot(org.jfree.chart.plot.CategoryPlot)

Aggregations

CategoryItemRenderer (org.jfree.chart.renderer.category.CategoryItemRenderer)70 CategoryPlot (org.jfree.chart.plot.CategoryPlot)36 Test (org.junit.Test)32 CategoryAxis (org.jfree.chart.axis.CategoryAxis)23 CategoryDataset (org.jfree.data.category.CategoryDataset)20 AbstractCategoryItemRenderer (org.jfree.chart.renderer.category.AbstractCategoryItemRenderer)14 Paint (java.awt.Paint)13 NumberAxis (org.jfree.chart.axis.NumberAxis)13 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)13 BarRenderer (org.jfree.chart.renderer.category.BarRenderer)12 DefaultCategoryItemRenderer (org.jfree.chart.renderer.category.DefaultCategoryItemRenderer)12 StandardCategoryURLGenerator (org.jfree.chart.urls.StandardCategoryURLGenerator)12 StandardCategoryToolTipGenerator (org.jfree.chart.labels.StandardCategoryToolTipGenerator)11 ValueAxis (org.jfree.chart.axis.ValueAxis)10 CategoryToolTipGenerator (org.jfree.chart.labels.CategoryToolTipGenerator)10 CategoryURLGenerator (org.jfree.chart.urls.CategoryURLGenerator)10 LineAndShapeRenderer (org.jfree.chart.renderer.category.LineAndShapeRenderer)9 JFreeChart (org.jfree.chart.JFreeChart)6 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)5 Rectangle2D (java.awt.geom.Rectangle2D)4