final String transform = SVGUtil.makeMarginTransform(task.getWidth(), task.getHeight(), sizex, sizey, margin);
SVGUtil.setAtt(layer, SVGConstants.SVG_TRANSFORM_ATTRIBUTE, transform);
// find maximum, determine step size
Integer dim = null;
DoubleMinMax xminmax = new DoubleMinMax();
DoubleMinMax yminmax = new DoubleMinMax();
for(NumberVector<?, ?> vec : curve) {
xminmax.put(vec.doubleValue(1));
if(dim == null) {
dim = vec.getDimensionality();
}
else {
// TODO: test and throw always
assert (dim == vec.getDimensionality());
}
for(int i = 1; i < dim; i++) {
yminmax.put(vec.doubleValue(i + 1));
}
}
// Minimum should always start at 0 for histograms
yminmax.put(0.0);
// remove one dimension which are the x values.
dim = dim - 1;
int size = curve.size();
double range = xminmax.getMax() - xminmax.getMin();
double binwidth = range / (size - 1);
LinearScale xscale = new LinearScale(xminmax.getMin() - binwidth / 2, xminmax.getMax() + binwidth / 2);
LinearScale yscale = new LinearScale(yminmax.getMin(), yminmax.getMax());
SVGPath[] path = new SVGPath[dim];
for(int i = 0; i < dim; i++) {
path[i] = new SVGPath(sizex * xscale.getScaled(xminmax.getMin() - binwidth / 2), sizey);
}