D3:是否可以繪制一條直線並根據閾值將其分配給兩個軸?

[英]D3: Is it possible to draw a line and assign it to two axes depending on threshold?


I`m trying to create a line chart where the vertical axis is split up into two parts. Both parts have different scales, see the following chart ( i´m only talking about the right axis, where the scale changes at value of 100mm): https://upload.wikimedia.org/wikipedia/commons/6/60/Klimadiagramm-deutsch-Bombay-Indien.png

我試圖創建一個折線圖,其中垂直軸分為兩部分。兩個部分都有不同的比例,請參見下圖(我只談右軸,其中比例變化為100mm):https://upload.wikimedia.org/wikipedia/commons/6/60/Klimadiagramm -deutsch - 孟買 - Indien.png

So the only idea i had was to split up the input data into values below and above the threshold and then create separate lines and areas out of this data. But this seems to me like quite an unhandy solution, so before i start doing that, i wanted to ask here: Does anybody have a better idea?

所以我唯一的想法是將輸入數據分成低於和高於閾值的值,然后從這些數據中創建單獨的行和區域。但在我看來,這似乎是一個非常不方便的解決方案,所以在我開始這樣做之前,我想問一下:有沒有人有更好的主意?

1 个解决方案

#1


0  

You can try to use a power scale. It can give you a desired effect. Look here (http://bl.ocks.org/GerHobbelt/3605124). It wont be as precise as the axis on your example.

您可以嘗試使用功率刻度。它可以給你一個想要的效果。看這里(http://bl.ocks.org/GerHobbelt/3605124)。它不像你的例子中的軸那么精確。

If you need a scale that exactly match your example, then you'll have to implement it on your own just the way you described. One from 0 to 100 with the range taking the lower half of the height and another from 100 to 900 with the range taking the upper half. You'll also get two axis that you'll have to match horizontally. One of them will be missing min/max value. You can then abstract it into a function. Good luck!

如果您需要一個與您的示例完全匹配的比例,那么您必須按照您描述的方式自行實現它。一個從0到100,范圍取高度的下半部分,另一個從100到900,范圍取上半部分。你還將得到兩個你必須水平匹配的軸。其中一個將缺少最小/最大值。然后,您可以將其抽象為函數。祝好運!


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2015/11/13/724d40c9d4be29931b1a43492329ed25.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com