简体   繁体   English

为什么NVD3 StreamGraph会随时间推移y零轴?

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

Link to sample image with tilting graph: 链接到带有倾斜图的样本图像

在此处输入图片说明

Link to NVD3 Streamgraph page : 链接到NVD3 Streamgraph页面

在此处输入图片说明

The nvd3 streamgraph will descend or ascend sharply over time. nvd3流图将随时间急剧下降或上升。 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. 我搜索了SO和NVD3文档,但没有找到控制每个时间点y轴零位置的变量。 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. 堆积面积图的NVD3代码接受图表样式的四种可能性:堆积,流,流中心和展开。 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. 如果将样式显式设置为“ stream-center”,则图表的行为将与预期的一样。 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. 其他显示算法的存在可能意味着NVD3人士正在研究它。 The github issue page might be a good place to look for updates or responses from them: github问题页面可能是寻找更新或响应的好地方:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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