use of org.jfree.chart.plot.CategoryPlot in project adempiere by adempiere.
the class MChart method createBarChart.
private JFreeChart createBarChart() {
JFreeChart chart = ChartFactory.createBarChart(// 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 GraphBuilder method setupCategoryChart.
private void setupCategoryChart(JFreeChart chart) {
CategoryPlot plot = chart.getCategoryPlot();
CategoryItemRenderer renderer = plot.getRenderer();
renderer.setSeriesPaint(0, new Color(92 / 255f, 178 / 255f, 232 / 255f));
renderer.setSeriesPaint(1, new Color(56 / 255f, 97 / 255f, 119 / 255f));
renderer.setSeriesPaint(2, new Color(242 / 255f, 70 / 255f, 78 / 255f));
renderer.setSeriesPaint(3, Color.orange);
renderer.setSeriesPaint(4, new Color(147 / 255f, 196 / 255f, 51 / 255f));
renderer.setSeriesPaint(5, new Color(210 / 255f, 247 / 255f, 91 / 255f));
renderer.setSeriesPaint(6, new Color(129 / 255f, 235 / 255f, 249 / 255f));
renderer.setSeriesPaint(7, new Color(60 / 255f, 84 / 255f, 8 / 255f));
renderer.setSeriesPaint(8, new Color(0.8f, 0.8f, 0.8f));
}
use of org.jfree.chart.plot.CategoryPlot in project jgnash by ccavanaugh.
the class BudgetSparkline method getSparklineImage.
public static Icon getSparklineImage(final List<BigDecimal> amounts) {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
final boolean[] negate = new boolean[amounts.size()];
for (int i = 0; i < amounts.size(); i++) {
dataset.addValue(amounts.get(i), CATEGORY, i);
negate[i] = amounts.get(i).signum() == -1;
}
CategoryAxis xAxis = new CategoryAxis();
xAxis.setTickLabelsVisible(false);
xAxis.setTickMarksVisible(false);
xAxis.setAxisLineVisible(false);
xAxis.setVisible(false);
NumberAxis yAxis = new NumberAxis();
yAxis.setTickLabelsVisible(false);
yAxis.setTickMarksVisible(false);
yAxis.setAxisLineVisible(false);
yAxis.setNegativeArrowVisible(false);
yAxis.setPositiveArrowVisible(false);
yAxis.setAutoRangeIncludesZero(true);
yAxis.setAutoRange(true);
yAxis.setVisible(false);
BarRenderer renderer = new BarRenderer() {
@Override
public Paint getItemPaint(final int row, final int column) {
return negate[column] ? Color.RED : Color.BLACK;
}
};
renderer.setShadowVisible(false);
renderer.setBarPainter(new StandardBarPainter());
CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
plot.setInsets(INSETS);
plot.setDomainGridlinesVisible(false);
plot.setDomainCrosshairVisible(false);
plot.setRangeGridlinesVisible(false);
plot.setRangeCrosshairVisible(false);
plot.setBackgroundPaint(CLEAR);
JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
chart.setBorderVisible(false);
chart.setBackgroundPaint(CLEAR);
Icon icon = EMPTY_ICON;
try {
byte[] image = ENCODER.encode(chart.createBufferedImage(DEFAULT_WIDTH, DEFAULT_HEIGHT, BufferedImage.BITMASK, null));
icon = new ImageIcon(image);
} catch (IOException ex) {
Logger.getLogger(BudgetSparkline.class.getName()).log(Level.SEVERE, null, ex);
}
return icon;
}
use of org.jfree.chart.plot.CategoryPlot in project processdash by dtuma.
the class CGIChartBase method setupCategoryChart.
protected void setupCategoryChart(JFreeChart chart) {
if (!(chart.getPlot() instanceof CategoryPlot))
return;
CategoryPlot cp = chart.getCategoryPlot();
CategoryAxis catAxis = cp.getDomainAxis();
ValueAxis otherAxis = cp.getRangeAxis();
if (!chromeless) {
String catAxisLabel = data.getColName(0);
if (catAxisLabel == null)
catAxisLabel = Translator.translate("Project/Task");
String otherAxisLabel = Translator.translate(getSetting("units"));
if ((otherAxisLabel == null || otherAxisLabel.length() == 0) && data.numCols() == 1)
otherAxisLabel = data.getColName(1);
if (otherAxisLabel == null)
otherAxisLabel = Translator.translate("Value");
String catLabels = getParameter("categoryLabels");
catAxis.setLabel(catAxisLabel);
otherAxis.setLabel(otherAxisLabel);
if ("vertical".equalsIgnoreCase(catLabels))
catAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
else if ("none".equalsIgnoreCase(catLabels))
catAxis.setTickLabelsVisible(false);
}
if (data.numCols() == 1 && getParameter("noSkipLegend") == null) {
chart.removeLegend();
chart.getPlot().setInsets(new RectangleInsets(5, 2, 2, 5));
}
}
use of org.jfree.chart.plot.CategoryPlot in project gephi by gephi.
the class ChartsUtils method buildBoxPlot.
/**
* Build a new box-plot from an array of numbers using a default title and yLabel.
* String dataName will be used for xLabel.
* @param numbers Numbers for building box-plot
* @param dataName Name of the numbers data
* @return Prepared box-plot
*/
public static JFreeChart buildBoxPlot(final Number[] numbers, final String dataName) {
if (numbers == null || numbers.length == 0) {
return null;
}
DefaultBoxAndWhiskerCategoryDataset dataset = new DefaultBoxAndWhiskerCategoryDataset();
final ArrayList<Number> list = new ArrayList<>();
list.addAll(Arrays.asList(numbers));
final String valuesString = getMessage("ChartsUtils.report.box-plot.values");
dataset.add(list, valuesString, "");
final BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
renderer.setMeanVisible(false);
renderer.setFillBox(false);
renderer.setMaximumBarWidth(0.5);
final CategoryAxis xAxis = new CategoryAxis(dataName);
final NumberAxis yAxis = new NumberAxis(getMessage("ChartsUtils.report.box-plot.values-range"));
yAxis.setAutoRangeIncludesZero(false);
renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());
final CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
plot.setRenderer(renderer);
JFreeChart boxPlot = new JFreeChart(getMessage("ChartsUtils.report.box-plot.title"), plot);
return boxPlot;
}
Aggregations