Search in sources :

Example 36 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 37 with CategoryItemRenderer

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

the class TOPChartService method createSelectionAdapterForButton.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.dataprofiler.service.ITOPChartService#createSelectionAdapterForButton()
     */
@Override
public Object createSelectionAdapterForButton(final Object chart, final boolean isCountAvg, final boolean isMinMax) {
    return new SelectionAdapter() {

        // $NON-NLS-1$
        private static final String SERIES_KEY_ID = "SERIES_KEY";

        @Override
        public void widgetSelected(SelectionEvent e) {
            Button checkBtn = (Button) e.getSource();
            int seriesid = (Integer) checkBtn.getData(SERIES_KEY_ID);
            if (isCountAvg) {
                XYPlot plot = ((JFreeChart) chart).getXYPlot();
                XYItemRenderer xyRenderer = plot.getRenderer();
                xyRenderer.setSeriesVisible(seriesid, checkBtn.getSelection());
            }
            if (isMinMax) {
                CategoryPlot plot = (CategoryPlot) ((JFreeChart) chart).getPlot();
                CategoryItemRenderer render = plot.getRenderer();
                render.setSeriesVisible(seriesid, checkBtn.getSelection());
            }
        }
    };
}
Also used : XYPlot(org.jfree.chart.plot.XYPlot) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) JFreeChart(org.jfree.chart.JFreeChart) CategoryPlot(org.jfree.chart.plot.CategoryPlot)

Example 38 with CategoryItemRenderer

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

the class ChartDecorator method decorateColumnDependency.

/**
 * DOC xqliu Comment method "decorateColumnDependency".
 *
 * @param chart
 */
public static void decorateColumnDependency(JFreeChart chart) {
    decorate(chart, PlotOrientation.HORIZONTAL);
    CategoryItemRenderer renderer = ((CategoryPlot) chart.getPlot()).getRenderer();
    renderer.setSeriesPaint(0, COLOR_LIST.get(1));
    renderer.setSeriesPaint(1, COLOR_LIST.get(2));
}
Also used : CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) CategoryPlot(org.jfree.chart.plot.CategoryPlot)

Example 39 with CategoryItemRenderer

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

the class ChartDecorator method decorateCategoryPlot.

/**
 * DOC bZhou Comment method "decorateCategoryPlot".
 *
 * @param chart
 */
public static void decorateCategoryPlot(JFreeChart chart, PlotOrientation orientation) {
    CategoryPlot plot = chart.getCategoryPlot();
    CategoryItemRenderer render = plot.getRenderer();
    CategoryAxis domainAxis = plot.getDomainAxis();
    // ADD msjian TDQ-5111 2012-4-9: set something look it well
    domainAxis.setCategoryMargin(0.1);
    domainAxis.setUpperMargin(0.05);
    domainAxis.setLowerMargin(0.05);
    domainAxis.setCategoryLabelPositionOffset(10);
    // TDQ-5111~
    ValueAxis valueAxis = plot.getRangeAxis();
    // $NON-NLS-1$
    Font font = new Font("Tahoma", Font.BOLD, BASE_ITEM_LABEL_SIZE);
    render.setBaseItemLabelFont(font);
    // MOD zshen 10998: change the font name 2010-01-16
    // $NON-NLS-1$
    font = new Font("sans-serif", Font.BOLD, BASE_LABEL_SIZE);
    domainAxis.setLabelFont(font);
    // $NON-NLS-1$
    font = new Font("sans-serif", Font.BOLD, BASE_LABEL_SIZE);
    valueAxis.setLabelFont(font);
    // $NON-NLS-1$
    font = new Font("sans-serif", Font.PLAIN, BASE_TICK_LABEL_SIZE);
    domainAxis.setTickLabelFont(font);
    valueAxis.setTickLabelFont(font);
    setLegendFont(chart);
    // $NON-NLS-1$
    font = new Font("sans-serif", Font.BOLD, BASE_TITLE_LABEL_SIZE);
    TextTitle title = chart.getTitle();
    if (title != null) {
        title.setFont(font);
    }
    font = null;
    if (render instanceof BarRenderer) {
        CategoryDataset dataset = chart.getCategoryPlot().getDataset();
        if (dataset != null) {
            int rowCount = dataset.getRowCount();
            List<?> columnKeys = dataset.getColumnKeys();
            if (!isContainCJKCharacter(columnKeys.toArray())) {
                // $NON-NLS-1$
                domainAxis.setTickLabelFont(new Font("Tahoma", Font.PLAIN, 10));
            }
            ((BarRenderer) render).setItemMargin(-0.40 * rowCount);
            // TDQ-12621 add Tooltip for Lable
            for (Object colKey : columnKeys) {
                domainAxis.addCategoryLabelToolTip(colKey.toString(), colKey.toString());
            }
        }
        domainAxis.setUpperMargin(0.1);
        // TDQ-12621 Only display in 1 line for the label, other chars will be displayed as "..."
        domainAxis.setMaximumCategoryLabelLines(1);
        // not do this when the bar is horizontal Orientation
        if (orientation == null) {
            ((BarRenderer) render).setMaximumBarWidth(0.2);
        }
    // TDQ-5111~
    }
// ~10998
}
Also used : TextTitle(org.jfree.chart.title.TextTitle) CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) CategoryAxis(org.jfree.chart.axis.CategoryAxis) ValueAxis(org.jfree.chart.axis.ValueAxis) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) CategoryDataset(org.jfree.data.category.CategoryDataset) BarRenderer(org.jfree.chart.renderer.category.BarRenderer) CategoryPlot(org.jfree.chart.plot.CategoryPlot) Font(java.awt.Font) Paint(java.awt.Paint)

Example 40 with CategoryItemRenderer

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

the class MChart method setupCategoryChart.

private void setupCategoryChart(JFreeChart chart) {
    CategoryPlot plot = chart.getCategoryPlot();
    CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis();
    xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
    CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, Color.RED);
    renderer.setSeriesPaint(1, Color.BLUE);
    renderer.setSeriesPaint(2, Color.YELLOW);
    renderer.setSeriesPaint(3, Color.GREEN);
    renderer.setSeriesPaint(4, Color.ORANGE);
    renderer.setSeriesPaint(5, Color.CYAN);
    renderer.setSeriesPaint(6, Color.MAGENTA);
    renderer.setSeriesPaint(7, Color.GRAY);
    renderer.setSeriesPaint(8, Color.PINK);
    plot.setRenderer(renderer);
}
Also used : CategoryItemRenderer(org.jfree.chart.renderer.category.CategoryItemRenderer) CategoryAxis(org.jfree.chart.axis.CategoryAxis) 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