質問

Link to sample image with tilting graph:

enter image description here

Link to NVD3 Streamgraph page:

enter image description here

The nvd3 streamgraph will descend or ascend sharply over time. I searched SO and the NVD3 documentation but didn't find a variable that controls where the zero of the y axis is at each point in time. Nor have I found discussions of this. In other words what makes the whole graph tilt in one direction or the other and how to control or turnoff this tilt.

I read a bit of the initial paper on streamgraphs by Byron but couldn't figure it out and thought I'd ask here.

Could someone please point me towards documentation on this or otherwise provide insight?

役に立ちましたか?

解決

The NVD3 code for the stacked area chart accepts four possibilities for the chart style: stack, stream, stream-center, and expand. The default stream graph is the "stream" style, and this is the version that gets off-centre if you have any zero values in your data.

If you set the style explicitly to "stream-center", the chart behaves as expected. However, the radio buttons that switch between display styles switch back to the problematic algorithm, so they will need to be disabled.

chart.style('stream-center')
     .showControls(false);

It's possible that the existence of this other display algorithm means that the NVD3 folks are working on it. The github issue page might be a good place to look for updates or responses from them:

https://github.com/novus/nvd3/issues/416

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top