Search in sources :

Example 6 with DateAxis

use of org.jfree.chart.axis.DateAxis 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;
}
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) ClusteredXYBarRenderer(org.jfree.chart.renderer.xy.ClusteredXYBarRenderer) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) LocalDate(java.time.LocalDate) JFreeChart(org.jfree.chart.JFreeChart)

Example 7 with DateAxis

use of org.jfree.chart.axis.DateAxis 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 8 with DateAxis

use of org.jfree.chart.axis.DateAxis in project jgnash by ccavanaugh.

the class SecurityHighLowChart method createHighLowChart.

private static JFreeChart createHighLowChart(String title, String timeAxisLabel, String valueAxisLabel, AbstractXYDataset data, boolean legend) {
    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false);
    HighLowRenderer renderer = new HighLowRenderer();
    renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator());
    XYPlot plot = new XYPlot(data, timeAxis, valueAxis, renderer);
    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) HighLowItemLabelGenerator(org.jfree.chart.labels.HighLowItemLabelGenerator) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) ValueAxis(org.jfree.chart.axis.ValueAxis) HighLowRenderer(org.jfree.chart.renderer.xy.HighLowRenderer) JFreeChart(org.jfree.chart.JFreeChart)

Example 9 with DateAxis

use of org.jfree.chart.axis.DateAxis in project cubrid-manager by CUBRID.

the class StatusMonitorViewPart method createChart.

/**
	 * Creates chart unit
	 * 
	 * @param unitNumber the number of unit
	 * @return JFreeChart
	 */
private JFreeChart createChart(int unitNumber) {
    String currentLbl = "Current";
    current[unitNumber] = new TimeSeries(currentLbl);
    current[unitNumber].setMaximumItemAge(18000000);
    String minLbl = "Min";
    minimum[unitNumber] = new TimeSeries(minLbl);
    minimum[unitNumber].setMaximumItemAge(18000000);
    String maxLbl = "Max";
    maximum[unitNumber] = new TimeSeries(maxLbl);
    maximum[unitNumber].setMaximumItemAge(18000000);
    String avgLbl = "Avg";
    average[unitNumber] = new TimeSeries(avgLbl);
    average[unitNumber].setMaximumItemAge(18000000);
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    timeseriescollection.addSeries(current[unitNumber]);
    timeseriescollection.addSeries(minimum[unitNumber]);
    timeseriescollection.addSeries(maximum[unitNumber]);
    timeseriescollection.addSeries(average[unitNumber]);
    DateAxis dateaxis = new DateAxis("");
    NumberAxis numberaxis = new NumberAxis("");
    dateaxis.setTickLabelFont(new Font("SansSerif", 0, 10));
    dateaxis.setLabelFont(new Font("SansSerif", 0, 7));
    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
    xylineandshaperenderer.setSeriesPaint(0, new Color(146, 208, 80));
    xylineandshaperenderer.setSeriesPaint(1, new Color(166, 166, 166));
    xylineandshaperenderer.setSeriesPaint(2, new Color(74, 126, 187));
    xylineandshaperenderer.setSeriesPaint(3, new Color(255, 51, 0));
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2F, 0, 2));
    xylineandshaperenderer.setSeriesStroke(3, new BasicStroke(2F, 0, 2));
    XYPlot xyplot = new XYPlot(timeseriescollection, dateaxis, numberaxis, xylineandshaperenderer);
    xyplot.setBackgroundPaint(Color.BLACK);
    xyplot.setDomainGridlinePaint(new Color(130, 130, 130));
    xyplot.setRangeGridlinePaint(new Color(130, 130, 130));
    dateaxis.setFixedAutoRange(300000d);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setTickLabelsVisible(true);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    JFreeChart chart = new JFreeChart(monitorList.get(unitNumber).getChartTitle(), new Font("SansSerif", 1, 15), xyplot, false);
    return chart;
}
Also used : BasicStroke(java.awt.BasicStroke) DateAxis(org.jfree.chart.axis.DateAxis) TimeSeries(org.jfree.data.time.TimeSeries) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) Color(java.awt.Color) Font(java.awt.Font) JFreeChart(org.jfree.chart.JFreeChart)

Example 10 with DateAxis

use of org.jfree.chart.axis.DateAxis in project cubrid-manager by CUBRID.

the class CombinedBarTimeSeriesChart method createSeriesChart.

/**
	 * Create the series chart
	 * 
	 * @return an instance of series chart
	 */
private JFreeChart createSeriesChart() {
    if (isAreaRender) {
        seriesdataset = createTableSeriesDataset();
    } else {
        seriesdataset = createTimeSeriesDataset();
    }
    JFreeChart chart = ChartFactory.createTimeSeriesChart("", "", "", seriesdataset, false, false, false);
    chart.setBorderVisible(false);
    chart.setBorderStroke(new BasicStroke(0.0f));
    //plot
    XYPlot xyplot = (XYPlot) chart.getPlot();
    xyplot.setOutlineVisible(false);
    RectangleInsets rectangleInsets = new RectangleInsets();
    xyplot.setAxisOffset(rectangleInsets);
    xyplot.setDomainGridlineStroke(new BasicStroke(0.4f));
    xyplot.setRangeGridlineStroke(new BasicStroke(0.4f));
    xyplot.setBackgroundPaint(Color.BLACK);
    xyplot.setDomainGridlinePaint(new Color(0, 128, 64));
    xyplot.setRangeGridlinePaint(new Color(0, 128, 64));
    if (isAreaRender) {
        XYAreaRenderer2 render = new StackedXYAreaRenderer2();
        render.setSeriesPaint(0, Color.GREEN);
        render.setSeriesPaint(1, Color.RED);
        xyplot.setRenderer(render);
    } else {
        XYLineAndShapeRenderer render = (XYLineAndShapeRenderer) xyplot.getRenderer();
        render.setSeriesPaint(0, Color.GREEN);
        render.setSeriesPaint(1, Color.RED);
    }
    //dateAxis
    DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis();
    dateaxis.setFixedAutoRange(300000d);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setVisible(isShowSeriesAxis);
    numberaxis = (NumberAxis) xyplot.getRangeAxis();
    numberaxis.setVisible(isShowSeriesAxis);
    numberaxis.setRange(0 - 0.5, barMax + 0.5);
    return chart;
}
Also used : BasicStroke(java.awt.BasicStroke) StackedXYAreaRenderer2(org.jfree.chart.renderer.xy.StackedXYAreaRenderer2) DateAxis(org.jfree.chart.axis.DateAxis) XYPlot(org.jfree.chart.plot.XYPlot) Color(java.awt.Color) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) RectangleInsets(org.jfree.ui.RectangleInsets) JFreeChart(org.jfree.chart.JFreeChart) XYAreaRenderer2(org.jfree.chart.renderer.xy.XYAreaRenderer2) StackedXYAreaRenderer2(org.jfree.chart.renderer.xy.StackedXYAreaRenderer2)

Aggregations

DateAxis (org.jfree.chart.axis.DateAxis)39 XYPlot (org.jfree.chart.plot.XYPlot)33 JFreeChart (org.jfree.chart.JFreeChart)30 SimpleDateFormat (java.text.SimpleDateFormat)21 NumberAxis (org.jfree.chart.axis.NumberAxis)18 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)13 TimeSeriesCollection (org.jfree.data.time.TimeSeriesCollection)13 Color (java.awt.Color)10 DateFormat (java.text.DateFormat)8 Date (java.util.Date)7 Map (java.util.Map)7 ValueAxis (org.jfree.chart.axis.ValueAxis)7 StandardXYToolTipGenerator (org.jfree.chart.labels.StandardXYToolTipGenerator)7 BasicStroke (java.awt.BasicStroke)5 TreeMap (java.util.TreeMap)5 DateTickUnit (org.jfree.chart.axis.DateTickUnit)5 TimeSeries (org.jfree.data.time.TimeSeries)5 ChartCompositePart (com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartCompositePart)4 HistoryComposite (com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite)4 ShowSetting (com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting)4