【发布时间】:2017-11-14 20:25:55
【问题描述】:
我试图绘制一个折线图,我想按月聚合数据。我正在使用来自crossfilter documentation 的数据集,日期稍作修改。
这就是我的数据集的样子:
var data = [
{date: "2011-11-14T16:17:54Z", quantity: 2, total: 190, tip: 100, type: "tab"},
{date: "2011-07-10T16:28:54Z", quantity: 1, total: 300, tip: 200, type: "visa"},
{date: "2011-07-15T16:28:54Z", quantity: 1, total: 300, tip: 200, type: "visa"},
{date: "2011-06-14T16:30:43Z", quantity: 2, total: 90, tip: 0, type: "tab"},
{date: "2011-06-14T16:48:46Z", quantity: 2, total: 90, tip: 0, type: "tab"},
{date: "2011-05-14T16:53:41Z", quantity: 2, total: 90, tip: 0, type: "tab"},
{date: "2011-07-17T16:14:06Z", quantity: 1, total: 100, tip: 0, type: "cash"},
{date: "2011-05-14T16:58:03Z", quantity: 2, total: 90, tip: 0, type: "tab"},
{date: "2011-12-14T17:07:21Z", quantity: 2, total: 90, tip: 0, type: "tab"},
{date: "2011-11-14T17:22:59Z", quantity: 2, total: 90, tip: 0, type: "tab"},
{date: "2011-11-14T17:25:45Z", quantity: 2, total: 200, tip: 0, type: "cash"},
{date: "2011-11-14T17:29:52Z", quantity: 1, total: 200, tip: 100, type: "visa"}
];
我想按月-年对总计进行分组。我的数据组根据日期而不是月份返回总计。
在我的图表中,7 月 10 日、15 日和 17 日被绘制为不同的点。我想将它们全部合并为 2017 年 7 月的积分。我如何做到这一点?任何指针? 谢谢大家!
【问题讨论】:
标签: javascript d3.js dc.js crossfilter