Search in sources :

Example 1 with XYBarRenderer

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;
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) NumberAxis(org.jfree.chart.axis.NumberAxis) DateTickUnit(org.jfree.chart.axis.DateTickUnit) XYPlot(org.jfree.chart.plot.XYPlot) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) LocalDate(java.time.LocalDate) XYBarRenderer(org.jfree.chart.renderer.xy.XYBarRenderer) JFreeChart(org.jfree.chart.JFreeChart)

Example 2 with XYBarRenderer

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;
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) NumberAxis(org.jfree.chart.axis.NumberAxis) DateTickUnit(org.jfree.chart.axis.DateTickUnit) XYPlot(org.jfree.chart.plot.XYPlot) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) SimpleDateFormat(java.text.SimpleDateFormat) LocalDate(java.time.LocalDate) XYBarRenderer(org.jfree.chart.renderer.xy.XYBarRenderer) JFreeChart(org.jfree.chart.JFreeChart)

Example 3 with XYBarRenderer

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));
    }
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) GridBagConstraints(java.awt.GridBagConstraints) NumberAxis(org.jfree.chart.axis.NumberAxis) ChartPanel(org.jfree.chart.ChartPanel) Insets(java.awt.Insets) XYPlot(org.jfree.chart.plot.XYPlot) Dimension(java.awt.Dimension) XYBarRenderer(org.jfree.chart.renderer.xy.XYBarRenderer) JFreeChart(org.jfree.chart.JFreeChart) Paint(java.awt.Paint)

Example 4 with XYBarRenderer

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;
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) XYPlot(org.jfree.chart.plot.XYPlot) PhaseChartColorer(net.sourceforge.processdash.ui.lib.chart.PhaseChartColorer) Color(java.awt.Color) JFreeChart(org.jfree.chart.JFreeChart) XYBarRenderer(org.jfree.chart.renderer.xy.XYBarRenderer) SymbolAxis(org.jfree.chart.axis.SymbolAxis)

Example 5 with XYBarRenderer

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));
}
Also used : PlotOrientation(org.jfree.chart.plot.PlotOrientation) XYBarRenderer(org.jfree.chart.renderer.xy.XYBarRenderer) NumberFormat(java.text.NumberFormat)

Aggregations

XYBarRenderer (org.jfree.chart.renderer.xy.XYBarRenderer)5 JFreeChart (org.jfree.chart.JFreeChart)4 DateAxis (org.jfree.chart.axis.DateAxis)4 XYPlot (org.jfree.chart.plot.XYPlot)4 NumberAxis (org.jfree.chart.axis.NumberAxis)3 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 LocalDate (java.time.LocalDate)2 DateTickUnit (org.jfree.chart.axis.DateTickUnit)2 StandardXYToolTipGenerator (org.jfree.chart.labels.StandardXYToolTipGenerator)2 TimeSeriesCollection (org.jfree.data.time.TimeSeriesCollection)2 Color (java.awt.Color)1 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 Insets (java.awt.Insets)1 Paint (java.awt.Paint)1 NumberFormat (java.text.NumberFormat)1 Date (java.util.Date)1 PhaseChartColorer (net.sourceforge.processdash.ui.lib.chart.PhaseChartColorer)1 ChartPanel (org.jfree.chart.ChartPanel)1