use of org.eclipse.swtchart.ICircularSeries in project portfolio by buchen.
the class PieChart method renderLabels.
protected void renderLabels(PaintEvent e) {
for (ISeries<?> series : getSeriesSet().getSeries()) {
if (series instanceof ICircularSeries) {
IAxis xAxis = getAxisSet().getXAxis(series.getXAxisId());
IAxis yAxis = getAxisSet().getYAxis(series.getYAxisId());
List<Node> nodes = ((ICircularSeries<?>) series).getRootNode().getChildren();
if (!nodes.isEmpty()) {
for (Node node : nodes) {
renderNodeLabel(node, (ICircularSeries<?>) series, e.gc, xAxis, yAxis);
}
}
}
}
}
use of org.eclipse.swtchart.ICircularSeries in project portfolio by buchen.
the class PieChart method getNodeAt.
/**
* Find the node at position
*/
public Node getNodeAt(int x, int y) {
Node node = null;
for (ISeries<?> series : getSeriesSet().getSeries()) {
if (!(series instanceof ICircularSeries)) {
continue;
}
ICircularSeries<?> circularSeries = (ICircularSeries<?>) series;
double primaryValueX = getSelectedPrimaryAxisValue(x, PieChart.Orientation.X_AXIS);
double primaryValueY = getSelectedPrimaryAxisValue(y, PieChart.Orientation.Y_AXIS);
node = circularSeries.getPieSliceFromPosition(primaryValueX, primaryValueY);
circularSeries.setHighlightedNode(node);
}
return node;
}
use of org.eclipse.swtchart.ICircularSeries in project portfolio by buchen.
the class HoldingsPieChartSWT method updateChart.
private void updateChart() {
List<Double> values = new ArrayList<>();
List<String> labels = new ArrayList<>();
nodeDataMap.clear();
//
snapshot.getAssetPositions().filter(//
p -> p.getValuation().getAmount() > 0).sorted(//
(l, r) -> Long.compare(r.getValuation().getAmount(), l.getValuation().getAmount())).forEach(p -> {
String nodeId = JSONObject.escape(p.getDescription());
labels.add(nodeId);
values.add(p.getValuation().getAmount() / Values.Amount.divider());
NodeData data = new NodeData();
data.position = p;
data.percentage = p.getShare();
data.percentageString = Values.Percent2.format(p.getShare());
data.shares = Values.Share.format(p.getPosition().getShares());
data.value = Values.Money.format(p.getValuation());
data.valueSingle = Values.Money.format(p.getValuation().multiply((long) Values.Share.divider()).divide(p.getPosition().getShares()));
nodeDataMap.put(nodeId, data);
});
ICircularSeries<?> circularSeries = (ICircularSeries<?>) chart.getSeriesSet().getSeries(Messages.LabelStatementOfAssetsHoldings);
if (circularSeries == null) {
circularSeries = createSeries(values, labels);
} else {
if (hasDataSetChanged(labels)) {
// refresh values only for smoother update
ListIterator<String> iter = labels.listIterator();
while (iter.hasNext()) {
int idx = iter.nextIndex();
String label = iter.next();
Node node = circularSeries.getNodeById(label);
if (node != null) {
node.setValue(values.get(idx));
}
}
} else {
circularSeries = createSeries(values, labels);
}
}
setColors(circularSeries, values.size());
chart.redraw();
}
use of org.eclipse.swtchart.ICircularSeries in project portfolio by buchen.
the class TaxonomyDonutSWT method updateChart.
private void updateChart() {
nodeDataMap.clear();
TaxonomyNode node = chartPage.getModel().getVirtualRootNode();
ICircularSeries<?> circularSeries = (ICircularSeries<?>) chart.getSeriesSet().createSeries(ChartType.DONUT == chartType ? SeriesType.DOUGHNUT : SeriesType.PIE, node.getName());
circularSeries.setHighlightColor(Colors.GREEN);
circularSeries.setBorderColor(Colors.WHITE);
Money total = getModel().getChartRenderingRootNode().getActual();
Node rootNode = circularSeries.getRootNode();
Map<String, Color> colors = new HashMap<>();
addNodes(nodeDataMap, colors, rootNode, node, node.getChildren(), total);
for (Map.Entry<String, Color> entry : colors.entrySet()) {
circularSeries.setColor(entry.getKey(), entry.getValue());
}
chart.redraw();
}
use of org.eclipse.swtchart.ICircularSeries in project portfolio by buchen.
the class TaxonomyPieChartSWT method updateChart.
private void updateChart() {
nodeDataMap.clear();
TaxonomyNode taxRoot = getModel().getVirtualRootNode();
ICircularSeries<?> circularSeries = (ICircularSeries<?>) chart.getSeriesSet().createSeries(ChartType.DONUT == chartType ? SeriesType.DOUGHNUT : SeriesType.PIE, taxRoot.getName());
circularSeries.setHighlightColor(Colors.GREEN);
circularSeries.setBorderColor(Colors.WHITE);
Node rootNode = circularSeries.getRootNode();
Map<String, Color> colors = new HashMap<>();
addNodes(nodeDataMap, colors, rootNode, taxRoot, taxRoot.getChildren(), taxRoot.getActual(), getModel().isSecuritiesInPieChartExcluded());
for (Map.Entry<String, Color> entry : colors.entrySet()) {
circularSeries.setColor(entry.getKey(), entry.getValue());
}
chart.redraw();
}
Aggregations