| 1 | "use strict";
|
|---|
| 2 |
|
|---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
|---|
| 4 | value: true
|
|---|
| 5 | });
|
|---|
| 6 | exports.calendar = calendar;
|
|---|
| 7 | exports.default = time;
|
|---|
| 8 | var _index = require("../../../lib-vendor/d3-time/src/index.js");
|
|---|
| 9 | var _index2 = require("../../../lib-vendor/d3-time-format/src/index.js");
|
|---|
| 10 | var _continuous = _interopRequireWildcard(require("./continuous.js"));
|
|---|
| 11 | var _init = require("./init.js");
|
|---|
| 12 | var _nice = _interopRequireDefault(require("./nice.js"));
|
|---|
| 13 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|---|
| 14 | function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|---|
| 15 | function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|---|
| 16 | function date(t) {
|
|---|
| 17 | return new Date(t);
|
|---|
| 18 | }
|
|---|
| 19 | function number(t) {
|
|---|
| 20 | return t instanceof Date ? +t : +new Date(+t);
|
|---|
| 21 | }
|
|---|
| 22 | function calendar(ticks, tickInterval, year, month, week, day, hour, minute, second, format) {
|
|---|
| 23 | var scale = (0, _continuous.default)(),
|
|---|
| 24 | invert = scale.invert,
|
|---|
| 25 | domain = scale.domain;
|
|---|
| 26 | var formatMillisecond = format(".%L"),
|
|---|
| 27 | formatSecond = format(":%S"),
|
|---|
| 28 | formatMinute = format("%I:%M"),
|
|---|
| 29 | formatHour = format("%I %p"),
|
|---|
| 30 | formatDay = format("%a %d"),
|
|---|
| 31 | formatWeek = format("%b %d"),
|
|---|
| 32 | formatMonth = format("%B"),
|
|---|
| 33 | formatYear = format("%Y");
|
|---|
| 34 | function tickFormat(date) {
|
|---|
| 35 | return (second(date) < date ? formatMillisecond : minute(date) < date ? formatSecond : hour(date) < date ? formatMinute : day(date) < date ? formatHour : month(date) < date ? week(date) < date ? formatDay : formatWeek : year(date) < date ? formatMonth : formatYear)(date);
|
|---|
| 36 | }
|
|---|
| 37 | scale.invert = function (y) {
|
|---|
| 38 | return new Date(invert(y));
|
|---|
| 39 | };
|
|---|
| 40 | scale.domain = function (_) {
|
|---|
| 41 | return arguments.length ? domain(Array.from(_, number)) : domain().map(date);
|
|---|
| 42 | };
|
|---|
| 43 | scale.ticks = function (interval) {
|
|---|
| 44 | var d = domain();
|
|---|
| 45 | return ticks(d[0], d[d.length - 1], interval == null ? 10 : interval);
|
|---|
| 46 | };
|
|---|
| 47 | scale.tickFormat = function (count, specifier) {
|
|---|
| 48 | return specifier == null ? tickFormat : format(specifier);
|
|---|
| 49 | };
|
|---|
| 50 | scale.nice = function (interval) {
|
|---|
| 51 | var d = domain();
|
|---|
| 52 | if (!interval || typeof interval.range !== "function") interval = tickInterval(d[0], d[d.length - 1], interval == null ? 10 : interval);
|
|---|
| 53 | return interval ? domain((0, _nice.default)(d, interval)) : scale;
|
|---|
| 54 | };
|
|---|
| 55 | scale.copy = function () {
|
|---|
| 56 | return (0, _continuous.copy)(scale, calendar(ticks, tickInterval, year, month, week, day, hour, minute, second, format));
|
|---|
| 57 | };
|
|---|
| 58 | return scale;
|
|---|
| 59 | }
|
|---|
| 60 | function time() {
|
|---|
| 61 | return _init.initRange.apply(calendar(_index.timeTicks, _index.timeTickInterval, _index.timeYear, _index.timeMonth, _index.timeWeek, _index.timeDay, _index.timeHour, _index.timeMinute, _index.timeSecond, _index2.timeFormat).domain([new Date(2000, 0, 1), new Date(2000, 0, 2)]), arguments);
|
|---|
| 62 | } |
|---|