private TimeSeriesCollection createTotalDataset() {
    List<BigDecimal> values = intervalReport.getValues();
    DateIterator dateIterator = intervalReport.dateIterator();
    List<BigDecimal> inventoryValues = intervalReport.getInventoryValues();
    List<BigDecimal> investmentValues = intervalReport.getInvestmentValues();
    TimeSeries s1 = new TimeSeries(getEditorInput().getName(), Day.class);
    TimeSeries s2 = new TimeSeries("Invested sum", Day.class);
    BigDecimal sum = BigDecimal.ZERO;
    Iterator<BigDecimal> iterator1 = inventoryValues.iterator();
    Iterator<BigDecimal> iterator2 = investmentValues.iterator();
    for (BigDecimal v : values) {
      sum = sum.add(v);
      de.tomsplayground.util.Day d = dateIterator.next();
      Day day = new Day(d.day, d.month + 1, d.year);
      BigDecimal v1 = sum.add(iterator1.next());
      s1.add(day, v1);
      BigDecimal v2 = iterator2.next();
      s2.add(day, v2);
    }
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(s1);
    dataset.addSeries(s2);

    return dataset;
  }
  @Override
  public void createPartControl(Composite parent) {
    Composite body = new Composite(parent, SWT.NONE);
    body.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    body.setLayout(new GridLayout());

    Account account = getAccount();
    intervalReport =
        new TimeIntervalReport(
            account, TimeIntervalReport.Interval.DAY, PriceProviderFactory.getInstance());
    intervalReport.addPropertyChangeListener(changeListener);

    String chartType = StringUtils.defaultString(account.getConfigurationValue(CHART_TYPE), "all");
    JFreeChart chart = createChart(chartType);
    chartFrame = new ChartComposite(body, SWT.NONE, chart, true);
    chartFrame.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    displayType = new Combo(body, SWT.READ_ONLY);
    for (TimeChart.RANGE r : TimeChart.RANGE.values()) {
      displayType.add(r.getName());
    }
    displayType.setText(chartType);
    displayType.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            Combo c = (Combo) e.getSource();
            String type = c.getItem(c.getSelectionIndex());
            timeChart.setChartType(type);
            dirty = true;
            firePropertyChange(IEditorPart.PROP_DIRTY);
          }
        });
  }
  private TimeSeriesCollection createGainLossDataset() {
    List<BigDecimal> values = intervalReport.getValues();
    DateIterator dateIterator = intervalReport.dateIterator();
    List<BigDecimal> inventoryValues = intervalReport.getInventoryValues();
    List<BigDecimal> investmentValues = intervalReport.getInvestmentValues();
    TimeSeries s3 = new TimeSeries("Saldo", Day.class);
    BigDecimal sum = BigDecimal.ZERO;
    Iterator<BigDecimal> iterator1 = inventoryValues.iterator();
    Iterator<BigDecimal> iterator2 = investmentValues.iterator();
    for (BigDecimal v : values) {
      sum = sum.add(v);
      de.tomsplayground.util.Day d = dateIterator.next();
      Day day = new Day(d.day, d.month + 1, d.year);
      BigDecimal v1 = sum.add(iterator1.next());
      BigDecimal v2 = iterator2.next();
      s3.add(day, v1.subtract(v2));
    }
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(s3);

    return dataset;
  }
 @Override
 public void dispose() {
   intervalReport.removePropertyChangeListener(changeListener);
   intervalReport.dispose();
   super.dispose();
 }