Search in sources :

Example 1 with ClientDataSeries

use of name.abuchen.portfolio.ui.views.dataseries.DataSeries.ClientDataSeries in project portfolio by buchen.

the class PerformanceChartSeriesBuilder method addClient.

private void addClient(DataSeries series, PerformanceIndex clientIndex, Aggregation.Period aggregationPeriod) {
    PerformanceIndex index = aggregationPeriod != null ? Aggregation.aggregate(clientIndex, aggregationPeriod) : clientIndex;
    switch((ClientDataSeries) series.getInstance()) {
        case TOTALS:
            ILineSeries lineSeries = getChart().addDateSeries(index.getDates(), index.getAccumulatedPercentage(), series.getLabel());
            configure(series, lineSeries);
            break;
        case DELTA_PERCENTAGE:
            String aggreagtionPeriodLabel = aggregationPeriod != null ? aggregationPeriod.toString() : Messages.LabelAggregationDaily;
            IBarSeries barSeries = getChart().addDateBarSeries(index.getDates(), index.getDeltaPercentage(), aggreagtionPeriodLabel);
            // update label, e.g. 'daily' to 'weekly'
            series.setLabel(aggreagtionPeriodLabel);
            configure(series, barSeries);
            break;
        default:
            break;
    }
}
Also used : IBarSeries(org.swtchart.IBarSeries) ClientDataSeries(name.abuchen.portfolio.ui.views.dataseries.DataSeries.ClientDataSeries) ILineSeries(org.swtchart.ILineSeries) PerformanceIndex(name.abuchen.portfolio.snapshot.PerformanceIndex)

Example 2 with ClientDataSeries

use of name.abuchen.portfolio.ui.views.dataseries.DataSeries.ClientDataSeries in project portfolio by buchen.

the class StatementOfAssetsSeriesBuilder method addClient.

private void addClient(DataSeries series, PerformanceIndex clientIndex) {
    double[] values;
    switch((ClientDataSeries) series.getInstance()) {
        case TOTALS:
            values = toDouble(clientIndex.getTotals(), Values.Amount.divider());
            break;
        case TRANSFERALS:
            values = toDouble(clientIndex.getTransferals(), Values.Amount.divider());
            break;
        case INVESTED_CAPITAL:
            values = toDouble(clientIndex.calculateInvestedCapital(), Values.Amount.divider());
            break;
        case ABSOLUTE_INVESTED_CAPITAL:
            values = toDouble(clientIndex.calculateAbsoluteInvestedCapital(), Values.Amount.divider());
            break;
        case ABSOLUTE_DELTA:
            values = toDouble(clientIndex.calculateDelta(), Values.Amount.divider());
            break;
        case ABSOLUTE_DELTA_ALL_RECORDS:
            values = toDouble(clientIndex.calculateAbsoluteDelta(), Values.Amount.divider());
            break;
        case TAXES:
            values = accumulateAndToDouble(clientIndex.getTaxes(), Values.Amount.divider());
            break;
        case DIVIDENDS:
            values = toDouble(clientIndex.getDividends(), Values.Amount.divider());
            break;
        case DIVIDENDS_ACCUMULATED:
            values = accumulateAndToDouble(clientIndex.getDividends(), Values.Amount.divider());
            break;
        case INTEREST:
            values = toDouble(clientIndex.getInterest(), Values.Amount.divider());
            break;
        case INTEREST_ACCUMULATED:
            values = accumulateAndToDouble(clientIndex.getInterest(), Values.Amount.divider());
            break;
        case INTEREST_CHARGE:
            values = toDouble(clientIndex.getInterestCharge(), Values.Amount.divider());
            break;
        case INTEREST_CHARGE_ACCUMULATED:
            values = accumulateAndToDouble(clientIndex.getInterestCharge(), Values.Amount.divider());
            break;
        default:
            throw new IllegalArgumentException(String.valueOf(series.getInstance()));
    }
    if (series.isLineChart()) {
        ILineSeries lineSeries = getChart().addDateSeries(clientIndex.getDates(), values, series.getLabel());
        configure(series, lineSeries);
    } else {
        IBarSeries barSeries = getChart().addDateBarSeries(clientIndex.getDates(), values, series.getLabel());
        configure(series, barSeries);
    }
}
Also used : IBarSeries(org.swtchart.IBarSeries) ClientDataSeries(name.abuchen.portfolio.ui.views.dataseries.DataSeries.ClientDataSeries) ILineSeries(org.swtchart.ILineSeries)

Aggregations

ClientDataSeries (name.abuchen.portfolio.ui.views.dataseries.DataSeries.ClientDataSeries)2 IBarSeries (org.swtchart.IBarSeries)2 ILineSeries (org.swtchart.ILineSeries)2 PerformanceIndex (name.abuchen.portfolio.snapshot.PerformanceIndex)1