Skip to content
This repository was archived by the owner on Sep 12, 2024. It is now read-only.

Commit 7e6ae03

Browse files
author
Alex Gabriel
committed
Add docs and spec
1 parent 57360aa commit 7e6ae03

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

docs/index.md

+21-5
Original file line numberDiff line numberDiff line change
@@ -195,18 +195,18 @@ ranges: Object
195195
Default:
196196
```javascript
197197
{
198-
'Last 30 days': [moment().subtract(29, 'days'), moment()]
199-
'Last 90 days': [moment().subtract(89, 'days'), moment()]
200-
'Last Year': [moment().subtract(1, 'year').add(1,'day'), moment()]
201-
'All Time': 'all-time' // [minDate, maxDate]
198+
'Last 30 days': [moment().subtract(29, 'days'), moment()],
199+
'Last 90 days': [moment().subtract(89, 'days'), moment()],
200+
'Last Year': [moment().subtract(1, 'year').add(1,'day'), moment()],
201+
'All Time': 'all-time' // [minDate, maxDate],
202202
'Custom Range': 'custom'
203203
}
204204
```
205205

206206
Examples:
207207
```javascript
208208
ranges: {
209-
'Last 245 Days': [moment().subtract(244, 'days'), moment()]
209+
'Last 245 Days': [moment().subtract(244, 'days'), moment()],
210210
'Last 3 Years': [moment().subtract(3, 'years').add(1, 'day'), moment()]
211211
}
212212
```
@@ -235,6 +235,22 @@ Array of available _periods_. Period selector disappears if only one period spec
235235
periods: String[]
236236
```
237237

238+
### customPeriodRanges
239+
240+
Similar to ranges except they are appended to the period row across the top of the picker.
241+
242+
```javascript
243+
ranges: Object
244+
```
245+
246+
Examples:
247+
```javascript
248+
customPeriodRanges: {
249+
'Last Year': [moment().subtract(1, 'year').add(1,'day'), moment()],
250+
'All Time': 'all-time' // [minDate, maxDate]
251+
}
252+
```
253+
238254
### single
239255
```javascript
240256
single: Boolean

test/config.coffee

+17
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,23 @@ describe 'Config', ->
104104
})
105105
, /Missing end date/)
106106

107+
describe 'customPeriodRanges', ->
108+
it 'works with a valid object', () ->
109+
new Config({
110+
customPeriodRanges: {
111+
"Test Range": ['2015-05-14', moment()]
112+
}
113+
})
114+
115+
it 'fails with a object value that is not an array', () ->
116+
assert.throw( ->
117+
new Config({
118+
ranges: {
119+
'Test Range': '2015-05-14'
120+
}
121+
})
122+
, /Value should be an array/)
123+
107124
describe '_dateObservable', ->
108125
describe '#fit()', ->
109126
describe 'minDate = 2015-05-14, period = month', ->

0 commit comments

Comments
 (0)