List of usage examples for org.jfree.data.time TimeSeries TimeSeries
public TimeSeries(Comparable name, String domain, String range)
From source file:org.jfree.chart.demo.XYBarChartDemo1.java
private static IntervalXYDataset createDataset() { TimeSeries timeseries = new TimeSeries("Executions", "Year", "Count"); try {//from w ww.j a v a2 s. co m timeseries.add(new Year(1976), new Integer(0)); timeseries.add(new Year(1977), new Integer(1)); timeseries.add(new Year(1978), new Integer(0)); timeseries.add(new Year(1979), new Integer(2)); timeseries.add(new Year(1980), new Integer(0)); timeseries.add(new Year(1981), new Integer(1)); timeseries.add(new Year(1982), new Integer(2)); timeseries.add(new Year(1983), new Integer(5)); timeseries.add(new Year(1984), new Integer(21)); timeseries.add(new Year(1985), new Integer(18)); timeseries.add(new Year(1986), new Integer(18)); timeseries.add(new Year(1987), new Integer(25)); timeseries.add(new Year(1988), new Integer(11)); timeseries.add(new Year(1989), new Integer(16)); timeseries.add(new Year(1990), new Integer(23)); timeseries.add(new Year(1991), new Integer(14)); timeseries.add(new Year(1992), new Integer(31)); timeseries.add(new Year(1993), new Integer(38)); timeseries.add(new Year(1994), new Integer(31)); timeseries.add(new Year(1995), new Integer(56)); timeseries.add(new Year(1996), new Integer(45)); timeseries.add(new Year(1997), new Integer(74)); timeseries.add(new Year(1998), new Integer(68)); timeseries.add(new Year(1999), new Integer(98)); timeseries.add(new Year(2000), new Integer(85)); timeseries.add(new Year(2001), new Integer(66)); timeseries.add(new Year(2002), new Integer(71)); timeseries.add(new Year(2003), new Integer(65)); timeseries.add(new Year(2004), new Integer(59)); timeseries.add(new Year(2005), new Integer(60)); } catch (Exception exception) { System.err.println(exception.getMessage()); } TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(timeseries); return timeseriescollection; }
From source file:org.jfree.chart.demo.XYBarChartDemo5.java
private static IntervalXYDataset createDataset() { TimeSeries timeseries = new TimeSeries("Budget", "Year", "$ Million"); try {/* ww w. j av a2s. c o m*/ timeseries.add(new Year(1980), -74D); timeseries.add(new Year(1981), -79D); timeseries.add(new Year(1982), -128D); timeseries.add(new Year(1983), -208D); timeseries.add(new Year(1984), -185D); timeseries.add(new Year(1985), -212D); timeseries.add(new Year(1986), -221D); timeseries.add(new Year(1987), -150D); timeseries.add(new Year(1988), -155D); timeseries.add(new Year(1989), -153D); timeseries.add(new Year(1990), -221D); timeseries.add(new Year(1991), -269D); timeseries.add(new Year(1992), -290D); timeseries.add(new Year(1993), -255D); timeseries.add(new Year(1994), -203D); timeseries.add(new Year(1995), -164D); timeseries.add(new Year(1996), -107D); timeseries.add(new Year(1997), -22D); timeseries.add(new Year(1998), 69D); timeseries.add(new Year(1999), 126D); timeseries.add(new Year(2000), 236D); timeseries.add(new Year(2001), 128D); timeseries.add(new Year(2002), -158D); timeseries.add(new Year(2003), -378D); timeseries.add(new Year(2004), -412D); } catch (Exception exception) { System.err.println(exception.getMessage()); } TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(timeseries); return timeseriescollection; }
From source file:Operacional.Janela2.java
private IntervalXYDataset updateDataset(List<String> l, String d) { IntervalXYDataset i;// www .j av a 2s . c o m TimeSeries timeseries = new TimeSeries("Recebimento", "Year", "Count"); String[] aux; if (d.equals("ano")) { try { System.out.println("AQUI"); for (String s : l) { aux = splitAno(s); System.out.println(aux[0] + " " + aux[1]); timeseries.add(new Year(Integer.parseInt(aux[0])), Float.parseFloat(aux[1])); } } catch (Exception exception) { System.err.println(exception.getMessage()); } } else { try { System.out.println("AQUI"); for (String s : l) { aux = splitMes(s); System.out.println(aux[0] + " " + aux[1] + " " + aux[2]); timeseries.add(new Month(Integer.parseInt(aux[0]), Integer.parseInt(aux[1])), Float.parseFloat(aux[2])); } } catch (Exception exception) { System.err.println(exception.getMessage()); } } TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(timeseries); return timeseriescollection; }
From source file:Operacional.Janela2.java
private static IntervalXYDataset createDataset() { TimeSeries timeseries = new TimeSeries("Recebimento", "Year", "Count"); try {/* ww w. java 2s .c o m*/ timeseries.add(new Month(12, 1975), new Integer(1)); timeseries.add(new Month(11, 1975), new Integer(1)); timeseries.add(new Month(10, 1975), new Integer(1)); timeseries.add(new Month(9, 1975), new Integer(1)); } catch (Exception exception) { System.err.println(exception.getMessage()); } TimeSeriesCollection timeseriescollection = new TimeSeriesCollection(timeseries); //timeseriescollection.setDomainIsPointsInTime(false); return timeseriescollection; }
From source file:jgnash.ui.report.compiled.RunningAccountBalanceChart.java
private TimeSeriesCollection createTimeSeriesCollection(final Account account) { if (subAccountCheckBox.isSelected()) { LocalDate start = DateUtils.getFirstDayOfTheMonth(startDateField.getLocalDate()); LocalDate stop = DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate()); List<LocalDate> list = DateUtils.getLastDayOfTheMonths(start, stop); TimeSeries t = new TimeSeries(rb.getString("Column.Month"), rb.getString("Column.Month"), rb.getString("Column.Balance")); // For every month, calculate the total amount for (LocalDate date : list) { LocalDate d = DateUtils.getLastDayOfTheMonth(date); // Get the total amount for the account and every sub accounts // for the specified date BigDecimal bd_TotalAmount = calculateTotal(d, account, account.getCurrencyNode()); // Include it in the graph t.add(new Month(DateUtils.asDate(date)), bd_TotalAmount); }//from w w w . j a v a 2s.com return new TimeSeriesCollection(t); } List<LocalDate> list = Collections.emptyList(); int count = account.getTransactionCount(); if (count > 0) { final LocalDate start = account.getTransactionAt(0).getLocalDate(); final LocalDate stop = account.getTransactionAt(count - 1).getLocalDate(); list = DateUtils.getLastDayOfTheMonths(start, stop); } TimeSeries t = new TimeSeries(rb.getString("Column.Month"), rb.getString("Column.Month"), rb.getString("Column.Balance")); AccountType type = account.getAccountType(); for (final LocalDate date : list) { // get balance for the whole month LocalDate d = DateUtils.getLastDayOfTheMonth(date); BigDecimal balance = AccountBalanceDisplayManager.convertToSelectedBalanceMode(type, account.getBalance(d)); t.add(new Month(DateUtils.asDate(date)), balance); } return new TimeSeriesCollection(t); }
From source file:jgnash.ui.report.compiled.MonthlyAccountBalanceChart.java
private TimeSeriesCollection createTimeSeriesCollection(final Account account) { List<LocalDate> dates = Collections.emptyList(); if (subAccountCheckBox.isSelected()) { // Getting the dates to calculate final LocalDate start = startDateField.getLocalDate().with(TemporalAdjusters.firstDayOfMonth()); final LocalDate stop = endDateField.getLocalDate().with(TemporalAdjusters.lastDayOfMonth()); dates = DateUtils.getLastDayOfTheMonths(start, stop); TimeSeries t = new TimeSeries(rb.getString("Column.Month"), rb.getString("Column.Month"), rb.getString("Column.Balance")); // For every month, calculate the total amount for (LocalDate date : dates) { final LocalDate d = date.with(TemporalAdjusters.lastDayOfMonth()); final LocalDate s = date.with(TemporalAdjusters.firstDayOfMonth()); // Get the total amount for the account and every sub accounts for the specified date // and include it in the chart t.add(new Month(DateUtils.asDate(date)), calculateTotal(s, d, account, account.getCurrencyNode())); }/*w w w . j ava 2s . c om*/ return new TimeSeriesCollection(t); } int count = account.getTransactionCount(); if (count > 0) { LocalDate start = account.getTransactionAt(0).getLocalDate(); LocalDate stop = account.getTransactionAt(count - 1).getLocalDate(); dates = DateUtils.getLastDayOfTheMonths(start, stop); } TimeSeries t = new TimeSeries(rb.getString("Column.Month"), rb.getString("Column.Month"), rb.getString("Column.Balance")); AccountType type = account.getAccountType(); for (LocalDate localDate : dates) { // get balance for the whole month LocalDate d = localDate.with(TemporalAdjusters.lastDayOfMonth()); LocalDate s = localDate.with(TemporalAdjusters.firstDayOfMonth()); BigDecimal balance = AccountBalanceDisplayManager.convertToSelectedBalanceMode(type, account.getBalance(s, d)); t.add(new Month(DateUtils.asDate(localDate)), balance); } return new TimeSeriesCollection(t); }
From source file:jgnash.ui.report.compiled.MonthlyAccountBalanceChartCompare.java
private TimeSeriesCollection createTimeSeriesCollection(final Account account, final Account a2) { //always use this method //if (subAccountCheckBox.isApproved()) { // Getting the dates to calculate LocalDate start = startDateField.getLocalDate().with(TemporalAdjusters.firstDayOfMonth()); LocalDate stop = endDateField.getLocalDate().with(TemporalAdjusters.lastDayOfMonth()); List<LocalDate> list = DateUtils.getLastDayOfTheMonths(start, stop); TimeSeries t = new TimeSeries(rb.getString("Column.Month"), rb.getString("Column.Month"), rb.getString("Column.Balance")); TimeSeries t2 = new TimeSeries(rb.getString("Column.Month"), rb.getString("Column.Month"), rb.getString("Column.Balance")); // For every month, calculate the total amount for (final LocalDate localDate : list) { final LocalDate d = localDate.with(TemporalAdjusters.lastDayOfMonth()); final LocalDate s = localDate.with(TemporalAdjusters.firstDayOfMonth()); // Get the total amount for the account and every sub accounts // for the specified date //BigDecimal bd_TotalAmount = calculateTotal(s, d, account, account.getCurrencyNode()); BigDecimal bd_TotalAmount = calculateTotal(s, d, account, subAccountCheckBox.isSelected(), account.getCurrencyNode()); // Include it in the graph t.add(new Month(DateUtils.asDate(localDate)), totalModulus(bd_TotalAmount, account.getAccountType())); if (jcb_compare.isSelected()) { bd_TotalAmount = calculateTotal(s, d, a2, subAccountCheckBox.isSelected(), account.getCurrencyNode()); t2.add(new Month(DateUtils.asDate(localDate)), totalModulus(bd_TotalAmount, a2.getAccountType())); }// ww w . j ava2 s . c om } TimeSeriesCollection tsc = new TimeSeriesCollection(); tsc.addSeries(t); if (jcb_compare.isSelected()) { tsc.addSeries(t2); } return tsc; /* return new TimeSeriesCollection(t); } int count = account.getTransactionCount(); if (count > 0) { Date start = account.getTransactionAt(0).getDate(); Date stop = account.getTransactionAt(count - 1).getDate(); list = DateUtils.getLastDayOfTheMonths(start, stop); } TimeSeries t = new TimeSeries(rb.getString("Column.Month"), rb.getString("Column.Month"), rb.getString("Column.Balance")); AccountType type = account.getAccountType(); for (Date aList : list) { // get balance for the whole month Date d = DateUtils.getLastDayOfTheMonth(aList); Date s = DateUtils.getFirstDayOfTheMonth(aList); BigDecimal balance = AccountBalanceDisplayManager.convertToSelectedBalanceMode(type, account.getBalance(s, d)); t.add(new Month(aList), balance); } return new TimeSeriesCollection(t); */ }
From source file:org.jfree.data.time.junit.TimeSeriesTest.java
/** * Tests a specific bug report where null arguments in the constructor * cause the equals() method to fail. Fixed for 0.9.21. *//* w ww. j a va 2 s.c om*/ public void testEquals2() { TimeSeries s1 = new TimeSeries("Series", null, null); TimeSeries s2 = new TimeSeries("Series", null, null); assertTrue(s1.equals(s2)); }