Search in sources :

Example 6 with TimeSeries

use of org.jfree.data.time.TimeSeries in project jgnash by ccavanaugh.

the class RunningAccountBalanceChart method createTimeSeriesCollection.

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);
        }
        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);
}
Also used : Month(org.jfree.data.time.Month) TimeSeries(org.jfree.data.time.TimeSeries) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) LocalDate(java.time.LocalDate) AccountType(jgnash.engine.AccountType) BigDecimal(java.math.BigDecimal)

Example 7 with TimeSeries

use of org.jfree.data.time.TimeSeries in project cubrid-manager by CUBRID.

the class ChartCompositePart method updateChart.

/**
	 * Update the plot in chart from scratch.
	 *
	 */
public void updateChart() {
    XYPlot plot = (XYPlot) (getChart().getPlot());
    TimeSeriesCollection timeseriescollection = (TimeSeriesCollection) (plot.getDataset());
    timeseriescollection.removeAllSeries();
    XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) plot.getRenderer();
    seriesMap.clear();
    int number = 0;
    for (Map.Entry<String, String> entry : valueMap.entrySet()) {
        String key = entry.getKey();
        TimeSeries series = new TimeSeries(key);
        seriesMap.put(key, series);
        if (settingMap.get(key).isChecked()) {
            timeseriescollection.addSeries(series);
            RGB seriesRgb = settingMap.get(key).getSeriesRgb();
            float width = settingMap.get(key).getWidth();
            Color color = new Color(seriesRgb.red, seriesRgb.green, seriesRgb.blue);
            xylineandshaperenderer.setSeriesPaint(number, color);
            xylineandshaperenderer.setSeriesStroke(number, new BasicStroke(width, 0, 2));
            number++;
        }
    }
}
Also used : BasicStroke(java.awt.BasicStroke) TimeSeries(org.jfree.data.time.TimeSeries) XYPlot(org.jfree.chart.plot.XYPlot) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) Color(java.awt.Color) CommonUITool.trimPaintColor(com.cubrid.common.ui.spi.util.CommonUITool.trimPaintColor) RGB(org.eclipse.swt.graphics.RGB) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 8 with TimeSeries

use of org.jfree.data.time.TimeSeries 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 9 with TimeSeries

use of org.jfree.data.time.TimeSeries in project cubrid-manager by CUBRID.

the class CombinedBarTimeSeriesChart method createTimeSeriesDataset.

/**
	 * Creates a sample dataset.
	 * 
	 * @return Series 2.
	 */
private XYDataset createTimeSeriesDataset() {
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    seriesMap = new TreeMap<String, TimeSeries>();
    for (Map.Entry<String, String> entry : valueMap.entrySet()) {
        String key = entry.getKey();
        TimeSeries series = new TimeSeries(key);
        seriesMap.put(key, series);
        timeseriescollection.addSeries(series);
    }
    return timeseriescollection;
}
Also used : TimeSeries(org.jfree.data.time.TimeSeries) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 10 with TimeSeries

use of org.jfree.data.time.TimeSeries in project cubrid-manager by CUBRID.

the class CombinedBarTimeSeriesChart method updateFromScratch.

/**
	 * update series chart from scratch
	 * 
	 */
public void updateFromScratch() {
    if (isAreaRender) {
        ((TimeTableXYDataset) seriesdataset).clear();
    } else {
        ((TimeSeriesCollection) seriesdataset).removeAllSeries();
        if (seriesMap != null) {
            seriesMap.clear();
            for (Map.Entry<String, String> entry : valueMap.entrySet()) {
                String key = entry.getKey();
                TimeSeries series = new TimeSeries(key);
                seriesMap.put(key, series);
                ((TimeSeriesCollection) seriesdataset).addSeries(series);
            }
        }
    }
}
Also used : TimeTableXYDataset(org.jfree.data.time.TimeTableXYDataset) TimeSeries(org.jfree.data.time.TimeSeries) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) Map(java.util.Map) TreeMap(java.util.TreeMap)

Aggregations

TimeSeries (org.jfree.data.time.TimeSeries)53 TimeSeriesCollection (org.jfree.data.time.TimeSeriesCollection)37 XYPlot (org.jfree.chart.plot.XYPlot)11 Date (java.util.Date)10 JFreeChart (org.jfree.chart.JFreeChart)10 Month (org.jfree.data.time.Month)9 TimeSeriesDataItem (org.jfree.data.time.TimeSeriesDataItem)8 BasicStroke (java.awt.BasicStroke)7 Color (java.awt.Color)7 Map (java.util.Map)7 Day (org.jfree.data.time.Day)6 RegularTimePeriod (org.jfree.data.time.RegularTimePeriod)6 IOException (java.io.IOException)5 List (java.util.List)5 DateAxis (org.jfree.chart.axis.DateAxis)5 NumberAxis (org.jfree.chart.axis.NumberAxis)5 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)5 FixedMillisecond (org.jfree.data.time.FixedMillisecond)5 BufferedImage (java.awt.image.BufferedImage)4 SimpleDateFormat (java.text.SimpleDateFormat)4