Reputation: 589
I am trying to achieve something along the lines of the stacked bars example, the difference being the way my background data is organized.
The layout assumes that data is organized per-layer.
Has anyone attempted to use the layout with data organized per-data-point instead?
e.g.
//completely random example, but I hope you can get the gist.
[{
id: 1,
name: 'foo'
layers: {
a: 10,
b: 13,
c: 12
}
}, {
id: 2,
name: 'bar',
layers: {
a: 8,
b: 5,
c: 14
}
}]
Other than a complete remapping so that the data becomes arranged per layers (I might have to do this for pretty huge datasets, that's why I'm asking), has anyone ever created stacked layouts from data presented thus?
Upvotes: 3
Views: 1736
Reputation: 5480
You could always sidestep the native d3 stack layout helper functions and compute the rect positions yourself from the data - here is a basic example of a stacked bar with data similar to yours: http://jsfiddle.net/tyR2S/7/
You still need to do a little transforming of data, so it might still be worthwhile to try transforming to the layer inputs that d3.stack takes, but I present this in case it might be helpful.
Upvotes: 2