Search in sources :

Example 51 with ISeries

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

the class StackedChartViewer method rebuildChartSeries.

private void rebuildChartSeries(long[] totals, List<SeriesBuilder> series) {
    if (chart.isDisposed())
        return;
    try {
        chart.suspendUpdate(true);
        for (ISeries s : chart.getSeriesSet().getSeries()) chart.getSeriesSet().deleteSeries(s.getId());
        for (SeriesBuilder serie : series) {
            // 
            chart.addSeries(// 
            serie.node.getClassification().getPathName(false), // 
            serie.getValues(totals), getRenderer().getColorFor(serie.node));
        }
        chart.getAxisSet().adjustRange();
        chart.getAxisSet().getYAxis(0).setRange(new Range(-0.01, 1.01));
    } finally {
        chart.suspendUpdate(false);
        chart.redraw();
    }
    isDirty = false;
}
Also used : Range(org.swtchart.Range) ISeries(org.swtchart.ISeries)

Example 52 with ISeries

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

the class AbstractChartTab method updateChart.

private void updateChart() {
    try {
        chart.suspendUpdate(true);
        for (ISeries s : chart.getSeriesSet().getSeries()) chart.getSeriesSet().deleteSeries(s.getId());
        createSeries();
        chart.getAxisSet().adjustRange();
    } finally {
        chart.suspendUpdate(false);
    }
    chart.redraw();
}
Also used : ISeries(org.swtchart.ISeries)

Example 53 with ISeries

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

the class ScatterChartCSVExporter method writeToFile.

@Override
protected void writeToFile(File file) throws IOException {
    try (CSVPrinter printer = new CSVPrinter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8), STRATEGY)) {
        // write header
        printer.print(Messages.ColumnDataSeries);
        printer.print(chart.getAxisSet().getXAxis(0).getTitle().getText());
        printer.print(chart.getAxisSet().getYAxis(0).getTitle().getText());
        printer.println();
        // write body
        ISeries[] series = chart.getSeriesSet().getSeries();
        for (ISeries serie : series) {
            printer.print(serie.getId());
            printer.print(valueFormat.format(serie.getXSeries()[0]));
            printer.print(valueFormat.format(serie.getYSeries()[0]));
            printer.println();
        }
    }
}
Also used : CSVPrinter(org.apache.commons.csv.CSVPrinter) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) ISeries(org.swtchart.ISeries)

Example 54 with ISeries

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

the class TimelineChartCSVExporter method writeToFile.

@Override
protected void writeToFile(File file) throws IOException {
    try (CSVPrinter printer = new CSVPrinter(new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8), STRATEGY)) {
        ISeries[] series = chart.getSeriesSet().getSeries();
        // write header
        printer.print(Messages.ColumnDate);
        for (ISeries s : series) printer.print(s.getId());
        printer.println();
        // write body
        Date[] dateSeries = series[0].getXDateSeries();
        SeriesAdapter[] adapters = new SeriesAdapter[series.length];
        for (int ii = 0; ii < series.length; ii++) {
            if (discontinousSeries.contains(series[ii].getId()))
                adapters[ii] = new DiscontinousAdapter(series[ii]);
            else
                adapters[ii] = new DefaultAdapter(series[ii]);
        }
        for (int line = 0; line < dateSeries.length; line++) {
            printer.print(dateFormat.format(dateSeries[line]));
            for (int col = 0; col < adapters.length; col++) printer.print(adapters[col].format(dateSeries[line], line));
            printer.println();
        }
    }
}
Also used : CSVPrinter(org.apache.commons.csv.CSVPrinter) FileOutputStream(java.io.FileOutputStream) OutputStreamWriter(java.io.OutputStreamWriter) ISeries(org.swtchart.ISeries) Date(java.util.Date)

Example 55 with ISeries

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

the class ScatterChartToolTip method getFocusObjectAt.

@Override
protected Object getFocusObjectAt(Event event) {
    // find closest scatter series
    ISeries[] series = getChart().getSeriesSet().getSeries();
    ISeries closest = null;
    double minDist = Double.MAX_VALUE;
    for (ISeries serie : series) {
        Point point = serie.getPixelCoordinates(0);
        // compute distance to mouse position
        double newDist = Math.sqrt(Math.pow((event.x - point.x), 2) + Math.pow((event.y - point.y), 2));
        if (newDist < minDist) {
            minDist = newDist;
            closest = serie;
        }
    }
    return closest;
}
Also used : Point(org.eclipse.swt.graphics.Point) ISeries(org.swtchart.ISeries)

Aggregations

ISeries (org.swtchart.ISeries)68 Point (org.eclipse.swt.graphics.Point)27 IAxis (org.swtchart.IAxis)17 Date (java.util.Date)15 ArrayList (java.util.ArrayList)11 Range (org.swtchart.Range)10 LocalDate (java.time.LocalDate)7 HashMap (java.util.HashMap)5 GC (org.eclipse.swt.graphics.GC)5 IBarSeries (org.swtchart.IBarSeries)5 ILineSeries (org.swtchart.ILineSeries)5 DecimalFormat (java.text.DecimalFormat)4 List (java.util.List)4 Rectangle (org.eclipse.swt.graphics.Rectangle)4 DataPoint (org.netxms.ui.eclipse.charts.api.DataPoint)4 Series (org.swtchart.internal.series.Series)4 CurrencyConverter (name.abuchen.portfolio.money.CurrencyConverter)3 Interval (name.abuchen.portfolio.util.Interval)3 Pair (name.abuchen.portfolio.util.Pair)3 Color (org.eclipse.swt.graphics.Color)3