【发布时间】:2017-01-12 14:28:54
【问题描述】:
我想创建一个堆积条形图,但不是通常的系列堆积方式。
确切的数据示例:
[
{"issue":19,"created_at":"2017-01-06T14:24:04.247Z","time":"00:30:00"},
{"issue":18,"created_at":"2017-01-06T14:24:04.247Z","time":"02:00:00"},
{"issue":18,"created_at":"2017-01-07T14:24:04.247Z","time":"00:10:00"},
{"issue":19,"created_at":"2017-01-07T14:24:04.247Z","time":"00:10:00"},
{"issue":17,"created_at":"2017-01-07T14:24:04.247Z","time":"02:00:00"},
{"issue":17,"created_at":"2017-01-07T14:24:04.247Z","time":"06:00:00"},
{"issue":17,"created_at":"2017-01-08T14:24:04.247Z","time":"06:00:00"},
{"issue":17,"created_at":"2017-01-09T14:24:04.247Z","time":"06:00:00"},
{"issue":17,"created_at":"2017-01-09T14:24:04.247Z","time":"00:30:00"},
{"issue":18,"created_at":"2017-01-10T14:24:04.247Z","time":"00:10:00"},
{"issue":19,"created_at":"2017-01-10T14:24:04.247Z","time":"02:00:00"},
{"issue":17,"created_at":"2017-01-10T14:24:04.247Z","time":"06:00:00"},
{"issue":19,"created_at":"2017-01-10T14:24:04.247Z","time":"02:00:00"},
{"issue":19,"created_at":"2017-01-11T14:24:04.247Z","time":"00:10:00"}
]
我现在想创建一个过去 7 天的堆积条形图,其中值(时间字段)每天堆积并按 id(问题)着色。
问题是我发现的所有示例都在进行系列堆叠
我每天有不同数量的值:0
谁能给我看一个简短的例子 (http://jsfiddle.net/qbmy76on/3/) 用 d3 从这个数据中得到一个堆积条(值也可以是一个简单的整数值,如下例所示)
使用 Charts.js 我实现了一个原型(有分钟),但我想切换到 d3 以获取未来的功能。
【问题讨论】:
-
提示:使用
:,而不是=,使其成为有效对象,并将对象包装到数组中。 -
是的,只是一些示例数据,这不是问题.. 我只是不知道如何在 d3 中优雅地实现这种情况。
-
这是我现在在我的 js 文件中的数据结构:i.imgur.com/tljd89p.png
-
在这种情况下,请粘贴您的确切数组,否则人们会浪费时间尝试一个不起作用的解决方案。
-
好的,完成了,希望有人能给我展示一个小提琴之类的例子
标签: javascript d3.js