简体   繁体   中英

Why does the NVD3 StreamGraph shift the y zero axis over time?

Link to sample image with tilting graph:

在此处输入图片说明

Link to NVD3 Streamgraph page :

在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM