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