mirror of
https://github.com/morrisjs/morris.js.git
synced 2024-11-10 21:36:34 +01:00
Add week in label_specs
This commit is contained in:
parent
b98ae8ab1d
commit
b192a00d68
@ -359,6 +359,11 @@ Morris.LABEL_SPECS =
|
||||
start: (d) -> new Date(d.getFullYear(), d.getMonth(), 1)
|
||||
fmt: (d) -> "#{d.getFullYear()}-#{Morris.pad2(d.getMonth() + 1)}"
|
||||
incr: (d) -> d.setMonth(d.getMonth() + 1)
|
||||
"week":
|
||||
span: 604800000 # 7 * 24 * 60 * 60 * 1000
|
||||
start: (d) -> new Date(d.getFullYear(), d.getMonth(), d.getDate())
|
||||
fmt: (d) -> "#{d.getFullYear()}-#{Morris.pad2(d.getMonth() + 1)}-#{Morris.pad2(d.getDate())}"
|
||||
incr: (d) -> d.setDate(d.getDate() + 7)
|
||||
"day":
|
||||
span: 86400000 # 24 * 60 * 60 * 1000
|
||||
start: (d) -> new Date(d.getFullYear(), d.getMonth(), d.getDate())
|
||||
@ -377,7 +382,7 @@ Morris.LABEL_SPECS =
|
||||
"second": secondsSpecHelper(1)
|
||||
|
||||
Morris.AUTO_LABEL_ORDER = [
|
||||
"decade", "year", "month", "day", "hour",
|
||||
"decade", "year", "month", "week", "day", "hour",
|
||||
"30min", "15min", "10min", "5min", "minute",
|
||||
"30sec", "15sec", "10sec", "5sec", "second"
|
||||
]
|
||||
|
14
morris.js
14
morris.js
@ -1151,6 +1151,18 @@
|
||||
return d.setMonth(d.getMonth() + 1);
|
||||
}
|
||||
},
|
||||
"week": {
|
||||
span: 604800000,
|
||||
start: function(d) {
|
||||
return new Date(d.getFullYear(), d.getMonth(), d.getDate());
|
||||
},
|
||||
fmt: function(d) {
|
||||
return "" + (d.getFullYear()) + "-" + (Morris.pad2(d.getMonth() + 1)) + "-" + (Morris.pad2(d.getDate()));
|
||||
},
|
||||
incr: function(d) {
|
||||
return d.setDate(d.getDate() + 7);
|
||||
}
|
||||
},
|
||||
"day": {
|
||||
span: 86400000,
|
||||
start: function(d) {
|
||||
@ -1176,7 +1188,7 @@
|
||||
"second": secondsSpecHelper(1)
|
||||
};
|
||||
|
||||
Morris.AUTO_LABEL_ORDER = ["decade", "year", "month", "day", "hour", "30min", "15min", "10min", "5min", "minute", "30sec", "15sec", "10sec", "5sec", "second"];
|
||||
Morris.AUTO_LABEL_ORDER = ["decade", "year", "month", "week", "day", "hour", "30min", "15min", "10min", "5min", "minute", "30sec", "15sec", "10sec", "5sec", "second"];
|
||||
|
||||
Morris.Area = (function(_super) {
|
||||
var areaDefaults;
|
||||
|
2
morris.min.js
vendored
2
morris.min.js
vendored
File diff suppressed because one or more lines are too long
@ -65,6 +65,20 @@ describe '#labelSeries', ->
|
||||
["2012-06", new Date(2012, 5, 1).getTime()]
|
||||
])
|
||||
|
||||
it 'should generate week intervals', ->
|
||||
Morris.labelSeries(
|
||||
new Date(2012, 0, 1).getTime(),
|
||||
new Date(2012, 1, 10).getTime(),
|
||||
1000
|
||||
).should.deep.equal([
|
||||
["2012-01-01", new Date(2012, 0, 1).getTime()],
|
||||
["2012-01-08", new Date(2012, 0, 8).getTime()],
|
||||
["2012-01-15", new Date(2012, 0, 15).getTime()],
|
||||
["2012-01-22", new Date(2012, 0, 22).getTime()],
|
||||
["2012-01-29", new Date(2012, 0, 29).getTime()],
|
||||
["2012-02-05", new Date(2012, 1, 5).getTime()]
|
||||
])
|
||||
|
||||
it 'should generate day intervals', ->
|
||||
Morris.labelSeries(
|
||||
new Date(2012, 0, 1).getTime(),
|
||||
|
Loading…
Reference in New Issue
Block a user