Skip to content
Permalink
Browse files

fixed the issue that the direct contributions in the

Sankey diagram are strange: The direct contributions were related to
the maximum direct contribution of all processes. This makes no sense:
they should be related to the maximum value of the upstream
contributions (which is in most cases the total result of the product
system)
  • Loading branch information...
msrocka committed Mar 20, 2019
1 parent a4f2b4f commit 69e2d4676f0f73d67eaa88e948b0417e9ac16157
@@ -115,25 +115,30 @@ public void calculate(Object selection) {
} else {
directResults = upstreamResults = new double[processIndex.size()];
}
upstreamContributions = calcContributions(upstreamResults);
directContributions = calcContributions(directResults);

// calculate the contributions
double refVal = Math.max(
Math.abs(Doubles.min(upstreamResults)),
Math.abs(Doubles.max(upstreamResults)));
upstreamContributions = calcContributions(
upstreamResults, refVal);
directContributions = calcContributions(
directResults, refVal);

log.trace("Calculation done");
}

private double[] calcContributions(double[] values) {
private double[] calcContributions(double[] values, double ref) {
if (values == null || values.length == 0)
return new double[0];
double min = Doubles.min(values);
double max = Doubles.max(values);
double ref = Math.max(Math.abs(min), Math.abs(max));
double[] contributions = new double[values.length];
double[] conts = new double[values.length];
if (ref == 0)
return contributions;
for (int i = 0; i < contributions.length; i++) {
return conts;
for (int i = 0; i < conts.length; i++) {
double val = values[i];
contributions[i] = val / ref;
conts[i] = val / ref;
}
return contributions;
return conts;
}

private double[] vec(ToDoubleFunction<CategorizedDescriptor> fn) {
@@ -31,13 +31,13 @@
/** Must be disposed when the edit part is deactivated */
Font boldFont;

public ProcessFigure(ProcessNode processNode) {
setToolTip(new Label(Labels.getDisplayName(processNode.process)));
processNode.figure = this;
this.node = processNode;
public ProcessFigure(ProcessNode node) {
setToolTip(new Label(Labels.getDisplayName(node.process)));
node.figure = this;
this.node = node;
setSize(WIDTH, HEIGHT);
processNode.setXyLayoutConstraints(getBounds());
addMouseListener(new ProcessMouseClick(processNode));
node.setXyLayoutConstraints(getBounds());
addMouseListener(new ProcessMouseClick(node));
setVisible(false);
}

0 comments on commit 69e2d46

Please sign in to comment.
You can’t perform that action at this time.