@@ -102,6 +102,303 @@ describe('ResultSet', () => {
102102 ] ;
103103 expect ( resultSet . timeSeries ( timeDimension ) ) . toEqual ( output ) ;
104104 } ) ;
105+
106+ test ( 'it generates array of dates - custom interval - 1 year, origin - 2020-01-01' , ( ) => {
107+ const resultSet = new ResultSet ( { } ) ;
108+ const timeDimension = {
109+ dateRange : [ '2021-01-01' , '2023-12-31' ] ,
110+ granularity : 'one_year' ,
111+ dimension : 'Events.time'
112+ } ;
113+ const output = [
114+ '2021-01-01T00:00:00.000' ,
115+ '2022-01-01T00:00:00.000' ,
116+ '2023-01-01T00:00:00.000'
117+ ] ;
118+ expect ( resultSet . timeSeries ( timeDimension , 1 , {
119+ 'Events.time.one_year' : {
120+ title : 'Time Dimension' ,
121+ shortTitle : 'TD' ,
122+ type : 'time' ,
123+ granularity : {
124+ name : '1 year' ,
125+ title : '1 year' ,
126+ interval : '1 year' ,
127+ origin : '2020-01-01' ,
128+ } ,
129+ } ,
130+ } ) ) . toEqual ( output ) ;
131+ } ) ;
132+
133+ test ( 'it generates array of dates - custom interval - 1 year, origin - 2025-03-01' , ( ) => {
134+ const resultSet = new ResultSet ( { } ) ;
135+ const timeDimension = {
136+ dateRange : [ '2021-01-01' , '2022-12-31' ] ,
137+ granularity : 'one_year' ,
138+ dimension : 'Events.time'
139+ } ;
140+ const output = [
141+ '2020-03-01T00:00:00.000' ,
142+ '2021-03-01T00:00:00.000' ,
143+ '2022-03-01T00:00:00.000' ,
144+ ] ;
145+ expect ( resultSet . timeSeries ( timeDimension , 1 , {
146+ 'Events.time.one_year' : {
147+ title : 'Time Dimension' ,
148+ shortTitle : 'TD' ,
149+ type : 'time' ,
150+ granularity : {
151+ name : '1 year' ,
152+ title : '1 year' ,
153+ interval : '1 year' ,
154+ origin : '2025-03-01' ,
155+ } ,
156+ } ,
157+ } ) ) . toEqual ( output ) ;
158+ } ) ;
159+
160+ test ( 'it generates array of dates - custom interval - 1 year, offset - 2 months' , ( ) => {
161+ const resultSet = new ResultSet ( { } ) ;
162+ const timeDimension = {
163+ dateRange : [ '2021-01-01' , '2022-12-31' ] ,
164+ granularity : 'one_year' ,
165+ dimension : 'Events.time'
166+ } ;
167+ const output = [
168+ '2020-03-01T00:00:00.000' ,
169+ '2021-03-01T00:00:00.000' ,
170+ '2022-03-01T00:00:00.000' ,
171+ ] ;
172+ expect ( resultSet . timeSeries ( timeDimension , 1 , {
173+ 'Events.time.one_year' : {
174+ title : 'Time Dimension' ,
175+ shortTitle : 'TD' ,
176+ type : 'time' ,
177+ granularity : {
178+ name : '1 year' ,
179+ title : '1 year' ,
180+ interval : '1 year' ,
181+ offset : '2 months' ,
182+ } ,
183+ } ,
184+ } ) ) . toEqual ( output ) ;
185+ } ) ;
186+
187+ test ( 'it generates array of dates - custom interval - 2 months, origin - 2019-01-01' , ( ) => {
188+ const resultSet = new ResultSet ( { } ) ;
189+ const timeDimension = {
190+ dateRange : [ '2021-01-01' , '2021-12-31' ] ,
191+ granularity : 'two_months' ,
192+ dimension : 'Events.time'
193+ } ;
194+ const output = [
195+ '2021-01-01T00:00:00.000' ,
196+ '2021-03-01T00:00:00.000' ,
197+ '2021-05-01T00:00:00.000' ,
198+ '2021-07-01T00:00:00.000' ,
199+ '2021-09-01T00:00:00.000' ,
200+ '2021-11-01T00:00:00.000' ,
201+ ] ;
202+ expect ( resultSet . timeSeries ( timeDimension , 1 , {
203+ 'Events.time.two_months' : {
204+ title : 'Time Dimension' ,
205+ shortTitle : 'TD' ,
206+ type : 'time' ,
207+ granularity : {
208+ name : '2 months' ,
209+ title : '2 months' ,
210+ interval : '2 months' ,
211+ origin : '2019-01-01' ,
212+ } ,
213+ } ,
214+ } ) ) . toEqual ( output ) ;
215+ } ) ;
216+
217+ test ( 'it generates array of dates - custom interval - 2 months, no offset' , ( ) => {
218+ const resultSet = new ResultSet ( { } ) ;
219+ const timeDimension = {
220+ dateRange : [ '2021-01-01' , '2021-12-31' ] ,
221+ granularity : 'two_months' ,
222+ dimension : 'Events.time'
223+ } ;
224+ const output = [
225+ '2021-01-01T00:00:00.000' ,
226+ '2021-03-01T00:00:00.000' ,
227+ '2021-05-01T00:00:00.000' ,
228+ '2021-07-01T00:00:00.000' ,
229+ '2021-09-01T00:00:00.000' ,
230+ '2021-11-01T00:00:00.000' ,
231+ ] ;
232+ expect ( resultSet . timeSeries ( timeDimension , 1 , {
233+ 'Events.time.two_months' : {
234+ title : 'Time Dimension' ,
235+ shortTitle : 'TD' ,
236+ type : 'time' ,
237+ granularity : {
238+ name : '2 months' ,
239+ title : '2 months' ,
240+ interval : '2 months' ,
241+ } ,
242+ } ,
243+ } ) ) . toEqual ( output ) ;
244+ } ) ;
245+
246+ test ( 'it generates array of dates - custom interval - 2 months, origin - 2019-03-15' , ( ) => {
247+ const resultSet = new ResultSet ( { } ) ;
248+ const timeDimension = {
249+ dateRange : [ '2021-01-01' , '2021-12-31' ] ,
250+ granularity : 'two_months' ,
251+ dimension : 'Events.time'
252+ } ;
253+ const output = [
254+ '2020-11-15T00:00:00.000' ,
255+ '2021-01-15T00:00:00.000' ,
256+ '2021-03-15T00:00:00.000' ,
257+ '2021-05-15T00:00:00.000' ,
258+ '2021-07-15T00:00:00.000' ,
259+ '2021-09-15T00:00:00.000' ,
260+ '2021-11-15T00:00:00.000' ,
261+ ] ;
262+ expect ( resultSet . timeSeries ( timeDimension , 1 , {
263+ 'Events.time.two_months' : {
264+ title : 'Time Dimension' ,
265+ shortTitle : 'TD' ,
266+ type : 'time' ,
267+ granularity : {
268+ name : '2 months' ,
269+ title : '2 months' ,
270+ interval : '2 months' ,
271+ origin : '2019-03-15' ,
272+ } ,
273+ } ,
274+ } ) ) . toEqual ( output ) ;
275+ } ) ;
276+
277+ test ( 'it generates array of dates - custom interval - 1 months 2 weeks 3 days, origin - 2021-01-25' , ( ) => {
278+ const resultSet = new ResultSet ( { } ) ;
279+ const timeDimension = {
280+ dateRange : [ '2021-01-01' , '2021-12-31' ] ,
281+ granularity : 'one_mo_two_we_three_d' ,
282+ dimension : 'Events.time'
283+ } ;
284+ const output = [
285+ '2020-12-08T00:00:00.000' ,
286+ '2021-01-25T00:00:00.000' ,
287+ '2021-03-14T00:00:00.000' ,
288+ '2021-05-01T00:00:00.000' ,
289+ '2021-06-18T00:00:00.000' ,
290+ '2021-08-04T00:00:00.000' ,
291+ '2021-09-21T00:00:00.000' ,
292+ '2021-11-07T00:00:00.000' ,
293+ '2021-12-24T00:00:00.000' ,
294+ ] ;
295+ expect ( resultSet . timeSeries ( timeDimension , 1 , {
296+ 'Events.time.one_mo_two_we_three_d' : {
297+ title : 'Time Dimension' ,
298+ shortTitle : 'TD' ,
299+ type : 'time' ,
300+ granularity : {
301+ name : '1 months 2 weeks 3 days' ,
302+ title : '1 months 2 weeks 3 days' ,
303+ interval : '1 months 2 weeks 3 days' ,
304+ origin : '2021-01-25' ,
305+ } ,
306+ } ,
307+ } ) ) . toEqual ( output ) ;
308+ } ) ;
309+
310+ test ( 'it generates array of dates - custom interval - 3 weeks, origin - 2020-12-15' , ( ) => {
311+ const resultSet = new ResultSet ( { } ) ;
312+ const timeDimension = {
313+ dateRange : [ '2021-01-01' , '2021-03-01' ] ,
314+ granularity : 'three_weeks' ,
315+ dimension : 'Events.time'
316+ } ;
317+ const output = [
318+ '2020-12-15T00:00:00.000' ,
319+ '2021-01-05T00:00:00.000' ,
320+ '2021-01-26T00:00:00.000' ,
321+ '2021-02-16T00:00:00.000' ,
322+ ] ;
323+ expect ( resultSet . timeSeries ( timeDimension , 1 , {
324+ 'Events.time.three_weeks' : {
325+ title : 'Time Dimension' ,
326+ shortTitle : 'TD' ,
327+ type : 'time' ,
328+ granularity : {
329+ name : '3 weeks' ,
330+ title : '3 weeks' ,
331+ interval : '3 weeks' ,
332+ origin : '2020-12-15' ,
333+ } ,
334+ } ,
335+ } ) ) . toEqual ( output ) ;
336+ } ) ;
337+
338+ test ( 'it generates array of dates - custom interval - 2 months 3 weeks 4 days 5 hours 6 minutes 7 seconds, origin - 2021-01-01' , ( ) => {
339+ const resultSet = new ResultSet ( { } ) ;
340+ const timeDimension = {
341+ dateRange : [ '2021-01-01' , '2021-12-31' ] ,
342+ granularity : 'two_mo_3w_4d_5h_6m_7s' ,
343+ dimension : 'Events.time'
344+ } ;
345+ const output = [
346+ '2021-01-01T00:00:00.000' ,
347+ '2021-03-26T05:06:07.000' ,
348+ '2021-06-20T10:12:14.000' ,
349+ '2021-09-14T15:18:21.000' ,
350+ '2021-12-09T20:24:28.000' ,
351+ ] ;
352+ expect ( resultSet . timeSeries ( timeDimension , 1 , {
353+ 'Events.time.two_mo_3w_4d_5h_6m_7s' : {
354+ title : 'Time Dimension' ,
355+ shortTitle : 'TD' ,
356+ type : 'time' ,
357+ granularity : {
358+ name : 'two_mo_3w_4d_5h_6m_7s' ,
359+ title : 'two_mo_3w_4d_5h_6m_7s' ,
360+ interval : '2 months 3 weeks 4 days 5 hours 6 minutes 7 seconds' ,
361+ origin : '2021-01-01' ,
362+ } ,
363+ } ,
364+ } ) ) . toEqual ( output ) ;
365+ } ) ;
366+
367+ test ( 'it generates array of dates - custom interval - 10 minutes 15 seconds, origin - 2021-02-01 09:59:45' , ( ) => {
368+ const resultSet = new ResultSet ( { } ) ;
369+ const timeDimension = {
370+ dateRange : [ '2021-02-01 10:00:00' , '2021-02-01 12:00:00' ] ,
371+ granularity : 'ten_min_fifteen_sec' ,
372+ dimension : 'Events.time'
373+ } ;
374+ const output = [
375+ '2021-02-01T09:59:45.000' ,
376+ '2021-02-01T10:10:00.000' ,
377+ '2021-02-01T10:20:15.000' ,
378+ '2021-02-01T10:30:30.000' ,
379+ '2021-02-01T10:40:45.000' ,
380+ '2021-02-01T10:51:00.000' ,
381+ '2021-02-01T11:01:15.000' ,
382+ '2021-02-01T11:11:30.000' ,
383+ '2021-02-01T11:21:45.000' ,
384+ '2021-02-01T11:32:00.000' ,
385+ '2021-02-01T11:42:15.000' ,
386+ '2021-02-01T11:52:30.000' ,
387+ ] ;
388+ expect ( resultSet . timeSeries ( timeDimension , 1 , {
389+ 'Events.time.ten_min_fifteen_sec' : {
390+ title : 'Time Dimension' ,
391+ shortTitle : 'TD' ,
392+ type : 'time' ,
393+ granularity : {
394+ name : '10 minutes 15 seconds' ,
395+ title : '10 minutes 15 seconds' ,
396+ interval : '10 minutes 15 seconds' ,
397+ origin : '2021-02-01 09:59:45' ,
398+ } ,
399+ } ,
400+ } ) ) . toEqual ( output ) ;
401+ } ) ;
105402 } ) ;
106403
107404 describe ( 'chartPivot' , ( ) => {
@@ -145,7 +442,7 @@ describe('ResultSet', () => {
145442 expect ( resultSet . chartPivot ( ) ) . toEqual ( [
146443 {
147444 x : 'Name 1' ,
148-
445+
149446 'Foo.count' : 'Some string' ,
150447 xValues : [
151448 'Name 1'
@@ -194,7 +491,7 @@ describe('ResultSet', () => {
194491 expect ( resultSet . chartPivot ( ) ) . toEqual ( [
195492 {
196493 x : 'Name 1' ,
197-
494+
198495 'Foo.count' : 0 ,
199496 xValues : [
200497 'Name 1'
@@ -291,7 +588,7 @@ describe('ResultSet', () => {
291588 expect ( resultSet . chartPivot ( ) ) . toEqual ( [
292589 {
293590 x : 'Name 1' ,
294-
591+
295592 'Foo.count' : 10 ,
296593 xValues : [
297594 'Name 1'
@@ -343,7 +640,7 @@ describe('ResultSet', () => {
343640 expect ( resultSet . chartPivot ( ) ) . toEqual ( [
344641 {
345642 x : 'Name 1' ,
346-
643+
347644 'Foo.latestRun' : new Date ( '2020-03-11T18:06:09.403Z' ) ,
348645 xValues : [
349646 'Name 1'
0 commit comments