use of org.jfree.chart.plot.CategoryPlot in project adempiere by adempiere.
the class MChart method createStackedBarChart.
private JFreeChart createStackedBarChart() {
JFreeChart chart = ChartFactory.createStackedBarChart(// chart title
getName(), // domain axis label
getDomainLabel(), // range axis label
getRangeLabel(), // data
getCategoryDataset(), X_AD_Chart.CHARTORIENTATION_Horizontal.equals(getChartOrientation()) ? PlotOrientation.HORIZONTAL : // orientation
PlotOrientation.VERTICAL, // include legend
isDisplayLegend(), // tooltips?
true, // URLs?
true);
BarRenderer renderer = new BarRenderer();
renderer.setBarPainter(new StandardBarPainter());
CategoryPlot plot = chart.getCategoryPlot();
plot.setRenderer(renderer);
setupCategoryChart(chart);
return chart;
}
use of org.jfree.chart.plot.CategoryPlot in project adempiere by adempiere.
the class CRPDetail method createChart.
/**
* Create Chart based on UOM
*
* @param dataset
* @param title
* @param uom
* @return JFreeChart Chart based On UOM
*/
public JFreeChart createChart(CategoryDataset dataset, String title, MUOM uom) {
JFreeChart chart = ChartFactory.createBarChart3D(title, // X-Axis label
Msg.translate(Env.getCtx(), "Day"), Msg.translate(Env.getCtx(), // Y-Axis
(uom == null) ? "" : uom.getName()), // Dataset
dataset, // orientation
PlotOrientation.VERTICAL, // include legend
true, // tooltips?
true, // URLs?
false);
chart.setBackgroundPaint(Color.WHITE);
chart.setAntiAlias(true);
chart.setBorderVisible(true);
CategoryPlot plot = chart.getCategoryPlot();
plot.setRangeGridlinesVisible(true);
plot.setRangeGridlinePaint(Color.GRAY);
plot.setDomainGridlinesVisible(true);
plot.setDomainGridlinePaint(Color.GRAY);
BarRenderer3D barrenderer = (BarRenderer3D) plot.getRenderer();
barrenderer.setDrawBarOutline(false);
barrenderer.setBaseItemLabelGenerator(new LabelGenerator());
barrenderer.setBaseItemLabelsVisible(true);
barrenderer.setSeriesPaint(0, new Color(10, 80, 150, 128));
barrenderer.setSeriesPaint(1, new Color(180, 60, 50, 128));
ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER);
barrenderer.setPositiveItemLabelPosition(itemlabelposition);
CategoryAxis domainAxis = plot.getDomainAxis();
domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0));
return chart;
}
use of org.jfree.chart.plot.CategoryPlot in project bamboobsc by billchen198318.
the class CommonBarChartAction method fillChart.
private void fillChart(String title, String categoryLabel, String valueLabel, List<String> names, List<Float> values, List<String> colors, boolean horizontal) throws Exception {
DefaultCategoryDataset data = new DefaultCategoryDataset();
for (int ix = 0; ix < names.size(); ix++) {
data.addValue(values.get(ix), "", names.get(ix));
}
this.chart = ChartFactory.createBarChart3D(// title
title, categoryLabel, valueLabel, data, (horizontal ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL), false, false, false);
CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
CategoryAxis categoryAxis = plot.getDomainAxis();
categoryAxis.setLabelFont(new Font("", Font.TRUETYPE_FONT, 9));
categoryAxis.setTickLabelFont(new Font("", Font.TRUETYPE_FONT, 9));
NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis();
numberAxis.setLabelFont(new Font("", Font.TRUETYPE_FONT, 9));
this.setPlotColor(plot, names, colors);
this.chart.setTitle(new TextTitle(title, new Font("", Font.TRUETYPE_FONT, 9)));
}
use of org.jfree.chart.plot.CategoryPlot 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);
}
}
use of org.jfree.chart.plot.CategoryPlot in project webanno by webanno.
the class MonitoringPage method createProgressChart.
private JFreeChart createProgressChart(Map<String, Integer> chartValues, int aMaxValue, boolean aIsPercentage) {
// fill dataset
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
if (aMaxValue > 0) {
for (String chartValue : chartValues.keySet()) {
dataset.setValue(chartValues.get(chartValue), "Completion", chartValue);
}
}
// create chart
JFreeChart chart = ChartFactory.createBarChart(null, null, null, dataset, PlotOrientation.HORIZONTAL, false, false, false);
CategoryPlot plot = chart.getCategoryPlot();
plot.setOutlineVisible(false);
plot.setBackgroundPaint(null);
plot.setNoDataMessage("No data");
plot.setInsets(new RectangleInsets(UnitType.ABSOLUTE, 0, 20, 0, 20));
if (aMaxValue > 0) {
plot.getRangeAxis().setRange(0.0, aMaxValue);
((NumberAxis) plot.getRangeAxis()).setNumberFormatOverride(new DecimalFormat("0"));
// as 0 0 1 1 1 - NumberTickUnit automatically determines the range
if (!aIsPercentage && aMaxValue <= 10) {
TickUnits standardUnits = new TickUnits();
NumberAxis tick = new NumberAxis();
tick.setTickUnit(new NumberTickUnit(1));
standardUnits.add(tick.getTickUnit());
plot.getRangeAxis().setStandardTickUnits(standardUnits);
}
} else {
plot.getRangeAxis().setVisible(false);
plot.getDomainAxis().setVisible(false);
}
BarRenderer renderer = new BarRenderer();
renderer.setBarPainter(new StandardBarPainter());
renderer.setShadowVisible(false);
// renderer.setGradientPaintTransformer(new
// StandardGradientPaintTransformer(
// GradientPaintTransformType.HORIZONTAL));
renderer.setSeriesPaint(0, Color.BLUE);
chart.getCategoryPlot().setRenderer(renderer);
return chart;
}
Aggregations