use of org.jfree.chart.renderer.xy.XYBarRenderer in project jgnash by ccavanaugh.
the class MonthlyAccountBalanceChart method createVerticalXYBarChart.
private JFreeChart createVerticalXYBarChart(Account a) {
DateFormat df = new SimpleDateFormat("MM/yy");
TimeSeriesCollection data = createTimeSeriesCollection(a);
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"));
StandardXYToolTipGenerator tooltipGenerator = new StandardXYToolTipGenerator("{1}, {2}", df, NumberFormat.getNumberInstance());
XYBarRenderer renderer = new XYBarRenderer(0.2);
renderer.setBaseToolTipGenerator(tooltipGenerator);
XYPlot plot = new XYPlot(data, dateAxis, valueAxis, renderer);
String title = rb.getString("Title.AccountBalance") + " - " + a.getPathName();
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
chart.setBackgroundPaint(null);
return chart;
}
use of org.jfree.chart.renderer.xy.XYBarRenderer in project jgnash by ccavanaugh.
the class RunningAccountBalanceChart method createVerticalXYBarChart.
private JFreeChart createVerticalXYBarChart(Account a) {
DateFormat df = new SimpleDateFormat("MM/yy");
TimeSeriesCollection data = createTimeSeriesCollection(a);
DateAxis dateAxis = new DateAxis(rb.getString("Column.Date"));
dateAxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH, 1, df));
dateAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
LocalDate start = DateUtils.getFirstDayOfTheMonth(startDateField.getLocalDate());
LocalDate end = DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate());
dateAxis.setRange(DateUtils.asDate(start), DateUtils.asDate(end));
NumberAxis valueAxis = new NumberAxis(rb.getString("Column.Balance"));
StandardXYToolTipGenerator tooltipGenerator = new StandardXYToolTipGenerator("{1}, {2}", df, NumberFormat.getNumberInstance());
XYBarRenderer renderer = new XYBarRenderer(0.2);
renderer.setBaseToolTipGenerator(tooltipGenerator);
XYPlot plot = new XYPlot(data, dateAxis, valueAxis, renderer);
String title = rb.getString("Title.EndMonthBalance") + " - " + a.getPathName();
JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
chart.setBackgroundPaint(null);
return chart;
}
use of org.jfree.chart.renderer.xy.XYBarRenderer in project processdash by dtuma.
the class ScheduleBalancingDialog method addChartToPanel.
private void addChartToPanel(JPanel panel, int gridY) {
// create a dataset for displaying schedule data
chartData = new ChartData();
updateChart();
// customize a renderer for displaying schedules
XYBarRenderer renderer = new XYBarRenderer();
renderer.setUseYInterval(true);
renderer.setBaseToolTipGenerator(chartData);
renderer.setDrawBarOutline(true);
// use an inverted, unadorned numeric Y-axis
NumberAxis yAxis = new NumberAxis();
yAxis.setInverted(true);
yAxis.setTickLabelsVisible(false);
yAxis.setTickMarksVisible(false);
yAxis.setUpperMargin(0);
// use a Date-based X-axis
DateAxis xAxis = new DateAxis();
// create an XY plot to display the data
XYPlot plot = new XYPlot(chartData, xAxis, yAxis, renderer);
plot.setOrientation(PlotOrientation.VERTICAL);
plot.setRangeGridlinesVisible(false);
plot.setNoDataMessage(TaskScheduleDialog.resources.getString("Chart.No_Data_Message"));
// create a chart and a chart panel
JFreeChart chart = new JFreeChart(plot);
chart.removeLegend();
ChartPanel chartPanel = new ChartPanel(chart, false);
chartPanel.setInitialDelay(50);
chartPanel.setDismissDelay(60000);
chartPanel.setMinimumDrawHeight(40);
chartPanel.setMinimumDrawWidth(40);
chartPanel.setMaximumDrawHeight(3000);
chartPanel.setMaximumDrawWidth(3000);
chartPanel.setPreferredSize(new Dimension(300, gridY * 25));
// add the chart to the dialog content pane
GridBagConstraints c = new GridBagConstraints();
c.gridy = gridY;
c.gridwidth = 4;
c.weightx = 2;
c.weighty = 1;
c.fill = GridBagConstraints.BOTH;
c.insets = new Insets(10, 0, 0, 0);
panel.add(chartPanel, c);
// colors with the schedule rows so they can act as a legend
for (int i = scheduleRows.size(); i-- > 0; ) {
ScheduleTableRow oneRow = scheduleRows.get(i);
oneRow.addColoredIcon(renderer.lookupSeriesPaint(i));
}
}
use of org.jfree.chart.renderer.xy.XYBarRenderer in project processdash by dtuma.
the class TimeLogPhaseWaterfallChart method createChart.
private JFreeChart createChart(IntervalXYDataset dataset, ProcessUtil process, List<String> phases, GapSkipTracker gaps) {
JFreeChart result = ChartFactory.createXYBarChart(null, null, true, null, dataset, PlotOrientation.VERTICAL, false, true, false);
XYPlot xyplot = (XYPlot) result.getPlot();
DateAxis dateAxis = new DateAxis(null);
dateAxis.setTickMarksVisible(false);
dateAxis.setTickLabelsVisible(false);
dateAxis.setLowerMargin(0.01);
dateAxis.setUpperMargin(0.01);
setupGaps(gaps, dateAxis, xyplot);
xyplot.setDomainAxis(dateAxis);
String[] phaseNameList = new String[phases.size()];
for (int i = 0; i < phaseNameList.length; i++) phaseNameList[i] = Translator.translate(phases.get(i));
SymbolAxis symbolaxis = new SymbolAxis(null, phaseNameList);
symbolaxis.setGridBandsVisible(false);
xyplot.setRangeAxis(symbolaxis);
final XYBarRenderer renderer = (XYBarRenderer) xyplot.getRenderer();
renderer.setUseYInterval(true);
renderer.setDrawBarOutline(true);
renderer.setBaseOutlinePaint(Color.black);
new PhaseChartColorer(process, phases) {
public void setItemColor(Object key, int pos, Color c) {
renderer.setSeriesPaint(pos, c);
}
}.run();
int exceptionSeries = dataset.getSeriesCount() - 1;
renderer.setSeriesPaint(exceptionSeries, EXCEPTION_PAINT);
renderer.setSeriesFillPaint(exceptionSeries, EXCEPTION_PAINT);
renderer.setSeriesOutlinePaint(exceptionSeries, EXCEPTION_PAINT);
renderer.setBaseToolTipGenerator(new TooltipGenerator());
xyplot.setBackgroundPaint(Color.white);
xyplot.setDomainGridlinesVisible(false);
xyplot.setRangeGridlinePaint(Color.lightGray);
xyplot.setDrawingSupplier(DRAWING_SUPPLIER_FACTORY.newDrawingSupplier());
result.setAntiAlias(false);
result.setTextAntiAlias(true);
parameters.put("title", resources.getString("Title"));
return result;
}
use of org.jfree.chart.renderer.xy.XYBarRenderer in project Openfire by igniterealtime.
the class GraphEngine method createTimeBarChart.
/**
* Generates a generic Time Bar Chart.
*
* @param title the title of the Chart.
* @param valueLabel the X Axis Label.
* @param data the data to populate with.
* @return the generated Chart.
*/
private JFreeChart createTimeBarChart(String title, String color, String valueLabel, XYDataset data) {
PlotOrientation orientation = PlotOrientation.VERTICAL;
DateAxis xAxis = generateTimeAxis();
NumberAxis yAxis = new NumberAxis(valueLabel);
NumberFormat formatter = NumberFormat.getNumberInstance(JiveGlobals.getLocale());
formatter.setMaximumFractionDigits(2);
formatter.setMinimumFractionDigits(0);
yAxis.setNumberFormatOverride(formatter);
yAxis.setAutoRangeIncludesZero(true);
return createChart(title, data, xAxis, yAxis, orientation, new XYBarRenderer(), GraphDefinition.getDefinition(color));
}
Aggregations