简体   繁体   English

d3.v3.js范围的多系列折线图

[英]Multi-series Line Chart with d3.v3.js Ranges

I am creating a multi-series line chart with d3.v3.js . 我正在使用d3.v3.js创建多系列折线图

I am trying to graph 4 different data-series over time. 我试图随着时间推移绘制4个不同的数据系列。 My issue is the range of the data varies a lot. 我的问题是数据范围差异很大。 I was wondering how I could go about adjusting my data so everything can be displayed? 我想知道如何调整数据以便可以显示所有内容? One of the data series has numbers that are so high, the other series are pushed way down at the bottom of the graph, and are basically illegible. 数据系列中的一个具有如此高的数字,另一个数据系列在图的底部被向下推,并且基本上难以辨认。

I want to be able to scale my data so the graph doesn't look ridiculously skewed. 我希望能够缩放数据,以使图形看起来不会出现可笑的歪斜。

Example Data Set: 数据集示例:

0: {date:2013-12-01, a:690558, b:68494, c:1886, d:0}    
1: {date:2013-12-02, a:607800, b:53720, c:1698, d:0}    
2: {date:2013-12-03, a:740914, b:86944, c:2896, d:0}    
3: {date:2013-12-04, a:885053, b:99616, c:3301, d:0}

As you can see, data-set A > B > C > D (d is not really being used yet) 如您所见,数据集A> B> C> D(尚未真正使用d)

您可以为每条线设置多个Y刻度,然后为轴和刻度线着色,例如与该线相同的颜色以显示哪条线。

This is really a design question, not a programming question, so not totally appropriate here. 这实际上是一个设计问题,而不是编程问题,因此此处并不完全合适。 It depends on the nature of the data and on your visualization's goals. 它取决于数据的性质和可视化目标。 Still.. 仍然..

You can try what tomtomtom suggested, using multiple axes. 您可以使用多个轴尝试建议的tomtomtom。

You can use a non-linear scale, like d3.scale.sqrt or d3.scale.log . 您可以使用非线性标尺,例如d3.scale.sqrtd3.scale.log

Or, you can transform all the values into percent change relative to a chosen point in time (often, that time is the beginning of the series). 或者,您可以将所有值转换为相对于所选时间点的百分比变化(通常,时间是序列的开始)。 This is exactly how stock price graphs show comparisons between two or more stocks. 这正是股票价格图显示两个或更多股票之间比较的方式。 See example . 参见示例

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

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