Say I'd like to sum up the number of sales I've made per month, and I have the datetime which sale was made. I also have sales from different years. Is there a convinient way to "truncate" dates so datetimes in the same month and year are equal in dimension? My only solution so far is setting all dates to have day of the month 1.
Asked
Active
Viewed 48 times
0
-
2You can use this code in your chart to show volume by dates by days, weeks, months (this example), years: .xUnits(d3.time.months) This [example](http://dc-js.github.io/dc.js/examples/switching-time-intervals.html) may be worth looking at – Kevin Jun 14 '17 at 13:55
-
1You can also use `d3.time.month` (notice, not plural) in your dimension or group key function. This will truncate exactly as you want. See [d3.time.interval](https://github.com/d3/d3-3.x-api-reference/blob/master/Time-Intervals.md#interval) – Gordon Jun 14 '17 at 19:59