1 | require("./../../lib/env-js/envjs/node"); |
---|
2 | require("./../../d3"); |
---|
3 | require("./../../d3.time"); |
---|
4 | |
---|
5 | var f = d3.time.scale().tickFormat(), |
---|
6 | u = d3.time.format.iso; |
---|
7 | |
---|
8 | console.log("1-second ticks (explicit):"); |
---|
9 | d3.time.scale().domain([u.parse("2011-01-01T12:00:00Z"), u.parse("2011-01-01T12:00:10Z")]).ticks(d3.time.seconds).forEach(log); |
---|
10 | console.log(""); |
---|
11 | |
---|
12 | console.log("1-second ticks (implicit):"); |
---|
13 | d3.time.scale().domain([u.parse("2011-01-01T12:00:00Z"), u.parse("2011-01-01T12:00:10Z")]).ticks(10).forEach(log); |
---|
14 | console.log(""); |
---|
15 | |
---|
16 | console.log("5-second ticks:"); |
---|
17 | d3.time.scale().domain([u.parse("2011-01-01T12:00:00Z"), u.parse("2011-01-01T12:00:50Z")]).ticks(10).forEach(log); |
---|
18 | console.log(""); |
---|
19 | |
---|
20 | console.log("15-second ticks:"); |
---|
21 | d3.time.scale().domain([u.parse("2011-01-01T12:00:00Z"), u.parse("2011-01-01T12:02:30Z")]).ticks(10).forEach(log); |
---|
22 | console.log(""); |
---|
23 | |
---|
24 | console.log("30-second ticks:"); |
---|
25 | d3.time.scale().domain([u.parse("2011-01-01T12:00:00Z"), u.parse("2011-01-01T12:05:00Z")]).ticks(10).forEach(log); |
---|
26 | console.log(""); |
---|
27 | |
---|
28 | console.log("1-minute ticks:"); |
---|
29 | d3.time.scale().domain([u.parse("2011-01-01T12:00:00Z"), u.parse("2011-01-01T12:10:00Z")]).ticks(10).forEach(log); |
---|
30 | console.log(""); |
---|
31 | |
---|
32 | console.log("5-minute ticks:"); |
---|
33 | d3.time.scale().domain([u.parse("2011-01-01T12:00:00Z"), u.parse("2011-01-01T13:00:00Z")]).ticks(10).forEach(log); |
---|
34 | console.log(""); |
---|
35 | |
---|
36 | console.log("15-minute ticks:"); |
---|
37 | d3.time.scale().domain([u.parse("2011-01-01T12:00:00Z"), u.parse("2011-01-01T15:00:00Z")]).ticks(10).forEach(log); |
---|
38 | console.log(""); |
---|
39 | |
---|
40 | console.log("30-minute ticks:"); |
---|
41 | d3.time.scale().domain([u.parse("2011-01-01T12:00:00Z"), u.parse("2011-01-01T18:00:00Z")]).ticks(10).forEach(log); |
---|
42 | console.log(""); |
---|
43 | |
---|
44 | console.log("1-hour ticks:"); |
---|
45 | d3.time.scale().domain([u.parse("2011-01-01T06:00:00Z"), u.parse("2011-01-01T18:00:00Z")]).ticks(10).forEach(log); |
---|
46 | console.log(""); |
---|
47 | |
---|
48 | console.log("3-hour ticks:"); |
---|
49 | d3.time.scale().domain([u.parse("2011-01-01T06:00:00Z"), u.parse("2011-01-02T18:00:00Z")]).ticks(10).forEach(log); |
---|
50 | console.log(""); |
---|
51 | |
---|
52 | console.log("6-hour ticks:"); |
---|
53 | d3.time.scale().domain([u.parse("2011-01-01T06:00:00Z"), u.parse("2011-01-04T18:00:00Z")]).ticks(10).forEach(log); |
---|
54 | console.log(""); |
---|
55 | |
---|
56 | console.log("12-hour ticks (implicit):"); |
---|
57 | d3.time.scale().domain([u.parse("2011-01-01T06:00:00Z"), u.parse("2011-01-07T18:00:00Z")]).ticks(10).forEach(log); |
---|
58 | console.log(""); |
---|
59 | |
---|
60 | console.log("12-hour ticks (explicit):"); |
---|
61 | d3.time.scale().domain([u.parse("2011-01-01T06:00:00Z"), u.parse("2011-01-07T18:00:00Z")]).ticks(d3.time.hours, 12).forEach(log); |
---|
62 | console.log(""); |
---|
63 | |
---|
64 | console.log("1-day ticks:"); |
---|
65 | d3.time.scale().domain([u.parse("2011-01-01T06:00:00Z"), u.parse("2011-01-14T06:00:00Z")]).ticks(10).forEach(log); |
---|
66 | console.log(""); |
---|
67 | |
---|
68 | console.log("2-day ticks:"); |
---|
69 | d3.time.scale().domain([u.parse("2011-01-01T06:00:00Z"), u.parse("2011-01-28T06:00:00Z")]).ticks(10).forEach(log); |
---|
70 | console.log(""); |
---|
71 | |
---|
72 | console.log("1-week ticks:"); |
---|
73 | d3.time.scale().domain([u.parse("2011-01-01T06:00:00Z"), u.parse("2011-02-28T06:00:00Z")]).ticks(10).forEach(log); |
---|
74 | console.log(""); |
---|
75 | |
---|
76 | console.log("1-month ticks:"); |
---|
77 | d3.time.scale().domain([u.parse("2011-01-01T06:00:00Z"), u.parse("2011-10-28T06:00:00Z")]).ticks(10).forEach(log); |
---|
78 | console.log(""); |
---|
79 | |
---|
80 | console.log("3-month ticks:"); |
---|
81 | d3.time.scale().domain([u.parse("2011-01-01T06:00:00Z"), u.parse("2013-02-28T06:00:00Z")]).ticks(10).forEach(log); |
---|
82 | console.log(""); |
---|
83 | |
---|
84 | console.log("1-year ticks:"); |
---|
85 | d3.time.scale().domain([u.parse("2011-01-01T06:00:00Z"), u.parse("2020-02-28T06:00:00Z")]).ticks(10).forEach(log); |
---|
86 | console.log(""); |
---|
87 | |
---|
88 | console.log("seconds around minute:") |
---|
89 | d3.time.seconds(new Date(2011, 01, 02, 01, 02, 56), new Date(2011, 01, 02, 01, 03, 05)).forEach(log); |
---|
90 | console.log(""); |
---|
91 | |
---|
92 | console.log("seconds around hour:") |
---|
93 | d3.time.seconds(new Date(2011, 01, 02, 02, 59, 56), new Date(2011, 01, 02, 03, 00, 05)).forEach(log); |
---|
94 | console.log(""); |
---|
95 | |
---|
96 | console.log("seconds around day:") |
---|
97 | d3.time.seconds(new Date(2011, 01, 01, 23, 59, 56), new Date(2011, 01, 02, 00, 00, 05)).forEach(log); |
---|
98 | console.log(""); |
---|
99 | |
---|
100 | console.log("seconds around week:") |
---|
101 | d3.time.seconds(new Date(2011, 01, 12, 23, 59, 56), new Date(2011, 01, 13, 00, 00, 05)).forEach(log); |
---|
102 | console.log(""); |
---|
103 | |
---|
104 | console.log("seconds around month:") |
---|
105 | d3.time.seconds(new Date(2011, 01, 28, 23, 59, 56), new Date(2011, 02, 01, 00, 00, 05)).forEach(log); |
---|
106 | console.log(""); |
---|
107 | |
---|
108 | console.log("seconds around year:") |
---|
109 | d3.time.seconds(new Date(2010, 11, 31, 23, 59, 56), new Date(2011, 00, 01, 00, 00, 05)).forEach(log); |
---|
110 | console.log(""); |
---|
111 | |
---|
112 | console.log("minutes around hour:") |
---|
113 | d3.time.minutes(new Date(2011, 01, 02, 02, 56), new Date(2011, 01, 02, 03, 05)).forEach(log); |
---|
114 | console.log(""); |
---|
115 | |
---|
116 | console.log("minutes around day:") |
---|
117 | d3.time.minutes(new Date(2011, 01, 01, 23, 56), new Date(2011, 01, 02, 00, 05)).forEach(log); |
---|
118 | console.log(""); |
---|
119 | |
---|
120 | console.log("minutes around week:") |
---|
121 | d3.time.minutes(new Date(2011, 01, 12, 23, 56), new Date(2011, 01, 13, 00, 05)).forEach(log); |
---|
122 | console.log(""); |
---|
123 | |
---|
124 | console.log("minutes around month:") |
---|
125 | d3.time.minutes(new Date(2011, 01, 28, 23, 56), new Date(2011, 02, 01, 00, 05)).forEach(log); |
---|
126 | console.log(""); |
---|
127 | |
---|
128 | console.log("minutes around year:") |
---|
129 | d3.time.minutes(new Date(2010, 11, 31, 23, 56), new Date(2011, 00, 01, 00, 05)).forEach(log); |
---|
130 | console.log(""); |
---|
131 | |
---|
132 | console.log("hours around day:") |
---|
133 | d3.time.hours(new Date(2011, 01, 01, 20), new Date(2011, 01, 02, 05)).forEach(log); |
---|
134 | console.log(""); |
---|
135 | |
---|
136 | console.log("hours around week:") |
---|
137 | d3.time.hours(new Date(2011, 01, 12, 20), new Date(2011, 01, 13, 05)).forEach(log); |
---|
138 | console.log(""); |
---|
139 | |
---|
140 | console.log("hours around month:") |
---|
141 | d3.time.hours(new Date(2011, 01, 28, 20), new Date(2011, 02, 01, 05)).forEach(log); |
---|
142 | console.log(""); |
---|
143 | |
---|
144 | console.log("hours around year:") |
---|
145 | d3.time.hours(new Date(2010, 11, 31, 20), new Date(2011, 00, 01, 05)).forEach(log); |
---|
146 | console.log(""); |
---|
147 | |
---|
148 | console.log("days around week:") |
---|
149 | d3.time.days(new Date(2011, 01, 09), new Date(2011, 01, 18)).forEach(log); |
---|
150 | console.log(""); |
---|
151 | |
---|
152 | console.log("days around month:") |
---|
153 | d3.time.days(new Date(2011, 01, 25), new Date(2011, 02, 06)).forEach(log); |
---|
154 | console.log(""); |
---|
155 | |
---|
156 | console.log("days around year:") |
---|
157 | d3.time.days(new Date(2010, 11, 28), new Date(2011, 00, 06)).forEach(log); |
---|
158 | console.log(""); |
---|
159 | |
---|
160 | console.log("weeks around month:") |
---|
161 | d3.time.weeks(new Date(2011, 03, 01), new Date(2011, 05, 01)).forEach(log); |
---|
162 | console.log(""); |
---|
163 | |
---|
164 | console.log("weeks around year:") |
---|
165 | d3.time.weeks(new Date(2005, 11, 01), new Date(2006, 01, 01)).forEach(log); |
---|
166 | console.log(""); |
---|
167 | |
---|
168 | console.log("months around year:") |
---|
169 | d3.time.months(new Date(2005, 08, 01), new Date(2006, 05, 01)).forEach(log); |
---|
170 | console.log(""); |
---|
171 | |
---|
172 | function log(date) { |
---|
173 | console.log(" " + f(date)); |
---|
174 | } |
---|