Search in sources :

Example 6 with IBarSeries

use of org.swtchart.IBarSeries in project netxms by netxms.

the class PlotArea method paintControl.

/*
	 * @see PaintListener#paintControl(PaintEvent)
	 */
public void paintControl(PaintEvent e) {
    Point p = getSize();
    final GC gc = e.gc;
    // draw the plot area background
    gc.setBackground(getBackground());
    gc.fillRectangle(0, 0, p.x, p.y);
    // draw grid
    for (IAxis axis : chart.getAxisSet().getAxes()) {
        ((Grid) axis.getGrid()).draw(gc, p.x, p.y);
    }
    // draw behind series
    for (ICustomPaintListener listener : paintListeners) {
        if (listener.drawBehindSeries()) {
            listener.paintControl(e);
        }
    }
    // draw series. The line series should be drawn on bar series.
    for (ISeries series : chart.getSeriesSet().getSeries()) {
        if (series instanceof IBarSeries) {
            ((Series) series).draw(gc, p.x, p.y);
        }
    }
    for (ISeries series : chart.getSeriesSet().getSeries()) {
        if (series instanceof ILineSeries) {
            ((Series) series).draw(gc, p.x, p.y);
        }
    }
    // draw over series
    for (ICustomPaintListener listener : paintListeners) {
        if (!listener.drawBehindSeries()) {
            listener.paintControl(e);
        }
    }
}
Also used : Series(org.swtchart.internal.series.Series) ISeries(org.swtchart.ISeries) IBarSeries(org.swtchart.IBarSeries) ILineSeries(org.swtchart.ILineSeries) ICustomPaintListener(org.swtchart.ICustomPaintListener) IBarSeries(org.swtchart.IBarSeries) ILineSeries(org.swtchart.ILineSeries) Point(org.eclipse.swt.graphics.Point) GC(org.eclipse.swt.graphics.GC) ISeries(org.swtchart.ISeries) IAxis(org.swtchart.IAxis)

Example 7 with IBarSeries

use of org.swtchart.IBarSeries 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 8 with IBarSeries

use of org.swtchart.IBarSeries 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)

Example 9 with IBarSeries

use of org.swtchart.IBarSeries in project portfolio by buchen.

the class DividendsPerYearChartTab method createSeries.

@Override
protected void createSeries() {
    updateCategorySeries();
    int startYear = model.getStartYear();
    double[] series = new double[LocalDate.now().getYear() - startYear + 1];
    for (int index = 0; index < model.getNoOfMonths(); index += 12) {
        int year = (index / 12);
        long total = 0;
        int months = Math.min(12, model.getNoOfMonths() - index);
        for (int ii = 0; ii < months; ii++) total += model.getSum().getValue(index + ii);
        series[year] = total / Values.Amount.divider();
    }
    IBarSeries barSeries = (IBarSeries) getChart().getSeriesSet().createSeries(SeriesType.BAR, getLabel());
    barSeries.setYSeries(series);
    barSeries.setBarColor(Colors.DARK_BLUE);
}
Also used : IBarSeries(org.swtchart.IBarSeries)

Aggregations

IBarSeries (org.swtchart.IBarSeries)9 ILineSeries (org.swtchart.ILineSeries)3 ClientDataSeries (name.abuchen.portfolio.ui.views.dataseries.DataSeries.ClientDataSeries)2 Color (org.eclipse.swt.graphics.Color)2 IAxis (org.swtchart.IAxis)2 ISeries (org.swtchart.ISeries)2 PerformanceIndex (name.abuchen.portfolio.snapshot.PerformanceIndex)1 PieChart (org.eclipse.linuxtools.dataviewers.piechart.PieChart)1 ChartView (org.eclipse.linuxtools.internal.dataviewers.charts.view.ChartView)1 GC (org.eclipse.swt.graphics.GC)1 Point (org.eclipse.swt.graphics.Point)1 PartInitException (org.eclipse.ui.PartInitException)1 Chart (org.swtchart.Chart)1 ICustomPaintListener (org.swtchart.ICustomPaintListener)1 ITitle (org.swtchart.ITitle)1 Series (org.swtchart.internal.series.Series)1