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;
}
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());
}
}
};
}
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));
}
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
}
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);
}
Aggregations