use of org.jfree.chart.renderer.xy.ClusteredXYBarRenderer in project jgnash by ccavanaugh.
the class MonthlyAccountBalanceChartCompare method createVerticalXYBarChart.
private JFreeChart createVerticalXYBarChart(final Account a, final Account a2) {
DateFormat df = new SimpleDateFormat("MM/yy");
TimeSeriesCollection data = createTimeSeriesCollection(a, a2);
DateAxis dateAxis = new DateAxis(rb.getString("Column.Date"));
dateAxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH, 1, df));
dateAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
// if (a.getTransactionCount() > 0) {
Date start = DateUtils.asDate(DateUtils.getFirstDayOfTheMonth(startDateField.getLocalDate()));
Date end = DateUtils.asDate(DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate()));
dateAxis.setRange(start, end);
// }
NumberAxis valueAxis = new NumberAxis(rb.getString("Column.Balance") + "-" + a.getCurrencyNode().getSymbol());
StandardXYToolTipGenerator tooltipGenerator = new StandardXYToolTipGenerator("{1}, {2}", df, NumberFormat.getNumberInstance());
ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer(0.2, false);
renderer.setBaseToolTipGenerator(tooltipGenerator);
XYPlot plot = new XYPlot(data, dateAxis, valueAxis, renderer);
String title;
if (jcb_compare.isSelected()) {
title = a.getPathName() + " vs " + a2.getPathName();
} else {
title = rb.getString("Title.AccountBalance") + " - " + a.getPathName();
}
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
chart.setBackgroundPaint(null);
return chart;
}
Aggregations