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;
}
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();
}
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();
}
}
}
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();
}
}
}
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;
}
Aggregations