Search in sources :

Example 1 with DataSeriesConfigurator

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

the class PerformanceChartView method createBody.

@Override
protected Composite createBody(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    chart = new TimelineChart(composite);
    chart.getTitle().setText(getTitle());
    chart.getTitle().setVisible(false);
    // $NON-NLS-1$
    chart.getAxisSet().getYAxis(0).getTick().setFormat(new DecimalFormat("0.#%"));
    // $NON-NLS-1$
    chart.getToolTip().setValueFormat(new DecimalFormat("0.##%"));
    DataSeriesCache cache = make(DataSeriesCache.class);
    seriesBuilder = new PerformanceChartSeriesBuilder(chart, cache);
    picker = new DataSeriesConfigurator(this, DataSeries.UseCase.PERFORMANCE);
    picker.addListener(this::updateChart);
    DataSeriesChartLegend legend = new DataSeriesChartLegend(composite, picker);
    // $NON-NLS-1$ //$NON-NLS-2$
    updateTitle(Messages.LabelPerformanceChart + " (" + picker.getConfigurationName() + ")");
    chart.getTitle().setText(getTitle());
    GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 0).applyTo(composite);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(chart);
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.FILL).applyTo(legend);
    setChartSeries();
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) DataSeriesCache(name.abuchen.portfolio.ui.views.dataseries.DataSeriesCache) DataSeriesConfigurator(name.abuchen.portfolio.ui.views.dataseries.DataSeriesConfigurator) DecimalFormat(java.text.DecimalFormat) TimelineChart(name.abuchen.portfolio.ui.util.chart.TimelineChart) DataSeriesChartLegend(name.abuchen.portfolio.ui.views.dataseries.DataSeriesChartLegend) PerformanceChartSeriesBuilder(name.abuchen.portfolio.ui.views.dataseries.PerformanceChartSeriesBuilder)

Example 2 with DataSeriesConfigurator

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

the class ReturnsVolatilityChartView method createBody.

@Override
protected Composite createBody(Composite parent) {
    cache = make(DataSeriesCache.class);
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    resources = new LocalResourceManager(JFaceResources.getResources(), composite);
    chart = new ScatterChart(composite);
    chart.getTitle().setVisible(false);
    IAxis xAxis = chart.getAxisSet().getXAxis(0);
    xAxis.getTitle().setText(Messages.LabelVolatility);
    // $NON-NLS-1$
    xAxis.getTick().setFormat(new DecimalFormat("0.##%"));
    IAxis yAxis = chart.getAxisSet().getYAxis(0);
    yAxis.getTitle().setText(Messages.LabelPeformanceTTWROR);
    // $NON-NLS-1$
    yAxis.getTick().setFormat(new DecimalFormat("0.##%"));
    ((IPlotArea) chart.getPlotArea()).addCustomPaintListener(new ICustomPaintListener() {

        @Override
        public void paintControl(PaintEvent e) {
            int y = xAxis.getPixelCoordinate(0);
            e.gc.drawLine(y, 0, y, e.height);
            int x = yAxis.getPixelCoordinate(0);
            e.gc.drawLine(0, x, e.width, x);
        }

        @Override
        public boolean drawBehindSeries() {
            return true;
        }
    });
    configurator = new DataSeriesConfigurator(this, DataSeries.UseCase.RETURN_VOLATILITY);
    configurator.addListener(() -> updateChart());
    DataSeriesChartLegend legend = new DataSeriesChartLegend(composite, configurator);
    // $NON-NLS-1$ //$NON-NLS-2$
    updateTitle(Messages.LabelHistoricalReturnsAndVolatiltity + " (" + configurator.getConfigurationName() + ")");
    chart.getTitle().setText(getTitle());
    GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 0).applyTo(composite);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(chart);
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.FILL).applyTo(legend);
    setChartSeries();
    return composite;
}
Also used : ICustomPaintListener(org.swtchart.ICustomPaintListener) PaintEvent(org.eclipse.swt.events.PaintEvent) DataSeriesCache(name.abuchen.portfolio.ui.views.dataseries.DataSeriesCache) Composite(org.eclipse.swt.widgets.Composite) DataSeriesConfigurator(name.abuchen.portfolio.ui.views.dataseries.DataSeriesConfigurator) LocalResourceManager(org.eclipse.jface.resource.LocalResourceManager) ScatterChart(name.abuchen.portfolio.ui.util.chart.ScatterChart) DecimalFormat(java.text.DecimalFormat) IPlotArea(org.swtchart.IPlotArea) DataSeriesChartLegend(name.abuchen.portfolio.ui.views.dataseries.DataSeriesChartLegend) IAxis(org.swtchart.IAxis)

Example 3 with DataSeriesConfigurator

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

the class StatementOfAssetsHistoryView method createBody.

@Override
protected Composite createBody(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    chart = new TimelineChart(composite);
    chart.getTitle().setVisible(false);
    DataSeriesCache cache = make(DataSeriesCache.class);
    seriesBuilder = new StatementOfAssetsSeriesBuilder(chart, cache);
    configurator = new DataSeriesConfigurator(this, DataSeries.UseCase.STATEMENT_OF_ASSETS);
    configurator.addListener(() -> updateChart());
    DataSeriesChartLegend legend = new DataSeriesChartLegend(composite, configurator);
    // $NON-NLS-1$ //$NON-NLS-2$
    updateTitle(Messages.LabelStatementOfAssetsHistory + " (" + configurator.getConfigurationName() + ")");
    chart.getTitle().setText(getTitle());
    GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 0).applyTo(composite);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(chart);
    GridDataFactory.fillDefaults().grab(true, false).align(SWT.CENTER, SWT.FILL).applyTo(legend);
    configurator.getSelectedDataSeries().forEach(series -> seriesBuilder.build(series, getReportingPeriod()));
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) DataSeriesCache(name.abuchen.portfolio.ui.views.dataseries.DataSeriesCache) DataSeriesConfigurator(name.abuchen.portfolio.ui.views.dataseries.DataSeriesConfigurator) StatementOfAssetsSeriesBuilder(name.abuchen.portfolio.ui.views.dataseries.StatementOfAssetsSeriesBuilder) TimelineChart(name.abuchen.portfolio.ui.util.chart.TimelineChart) DataSeriesChartLegend(name.abuchen.portfolio.ui.views.dataseries.DataSeriesChartLegend)

Aggregations

DataSeriesCache (name.abuchen.portfolio.ui.views.dataseries.DataSeriesCache)3 DataSeriesChartLegend (name.abuchen.portfolio.ui.views.dataseries.DataSeriesChartLegend)3 DataSeriesConfigurator (name.abuchen.portfolio.ui.views.dataseries.DataSeriesConfigurator)3 Composite (org.eclipse.swt.widgets.Composite)3 DecimalFormat (java.text.DecimalFormat)2 TimelineChart (name.abuchen.portfolio.ui.util.chart.TimelineChart)2 ScatterChart (name.abuchen.portfolio.ui.util.chart.ScatterChart)1 PerformanceChartSeriesBuilder (name.abuchen.portfolio.ui.views.dataseries.PerformanceChartSeriesBuilder)1 StatementOfAssetsSeriesBuilder (name.abuchen.portfolio.ui.views.dataseries.StatementOfAssetsSeriesBuilder)1 LocalResourceManager (org.eclipse.jface.resource.LocalResourceManager)1 PaintEvent (org.eclipse.swt.events.PaintEvent)1 IAxis (org.swtchart.IAxis)1 ICustomPaintListener (org.swtchart.ICustomPaintListener)1 IPlotArea (org.swtchart.IPlotArea)1