Bar graph added.

This commit is contained in:
prabhatdev
2020-07-28 00:48:25 +05:30
parent d0a6e2667d
commit 194b41124d
3468 changed files with 640611 additions and 169 deletions

27
node_modules/vega-time/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,27 @@
Copyright (c) 2015-2018, University of Washington Interactive Data Lab
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

148
node_modules/vega-time/README.md generated vendored Normal file
View File

@@ -0,0 +1,148 @@
# vega-time
JavaScript date-time utilities for Vega. Provides a set of helper methods for working with date objects (or, equivalently, with [UNIX timestamps](https://en.wikipedia.org/wiki/Unix_time)).
## API Reference
- [Time Units](#time-units)
- [Local Time Utilities](#local-time-utilities)
- [UTC Time Utilities](#utc-time-utilities)
### Time Units
The date-time utilities support a set of pre-defined time units. A single _unit_ value is one of the following strings:
- `'year'` - [Gregorian calendar](https://en.wikipedia.org/wiki/Gregorian_calendar) years.
- `'quarter'` - Three-month intervals, starting in one of January, April, July, and October.
- `'month'` - Calendar months (January, February, _etc._).
- `'date'` - Calendar day of the month (January 1, January 2, _etc._).
- `'week'` - Sunday-based weeks. Days before the first Sunday of the year are considered to be in week 0, the first Sunday of the year is the start of week 1, the second Sunday week 2, _etc._.
- `'day'` - Day of the week (Sunday, Monday, _etc._).
- `'dayofyear'` - Day of the year (1, 2, ..., 365, _etc._).
- `'hours'` - Hours of the day (12:00am, 1:00am, _etc_.).
- `'minutes'` - Minutes in an hour (12:00, 12:01, _etc_.).
- `'seconds'` - Seconds in a minute (12:00:00, 12:00:01, _etc_.).
- `'milliseconds'` - Milliseconds in a second.
Multiple _units_ can be listed in an array to indicate desired intervals of time. For example, `['year', 'month', 'date']` indicates chronological time sensitive to year, month, and date (but not to hours, minutes, or seconds). The specifier `['month', 'date']` is sensitive to month and date, but not year, which can be useful for binning time values to look at seasonal patterns only.
<a name="timeUnits" href="#timeUnits">#</a>
vega.<b>timeUnits</b>(<i>units</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-time/src/units.js "Source")
Returns a standardized and sorted specifier for the given _units_, which must be an array of one or more valid time unit strings. The returned array contains the same units, sorted in decreasing over of unit size, such that the most granular unit is last (for example, `['year', 'month', 'date']`). This method throws an error if the _units_ array is empty, contains an invalid unit, or contains incompatible units. Specifically, the `'quarter'`, `'month'`, and `'date'` units can not be used in conjunction with the `'week'` or `'day'` units.
<a name="timeUnitSpecifier" href="#timeUnitSpecifier">#</a>
vega.<b>timeUnitSpecifier</b>(<i>units</i>[, <i>specifiers</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-time/src/format.js "Source")
Returns a time format specifier string for the given time _units_. The optional _specifiers_ object provides a set of desired specifier sub-strings for customizing the resulting time formats. The _specifiers_ object may contain keys for both single time units (`"year"`) and time unit sequences (`"year-month-date"`). This method will first standardize the input time units using the [timeUnits](#timeUnits) method. It will then search, starting from the beginning of the units array, for the largest matching sequence defined in the specifiers object. Matching entries are then concatenated together, and the resulting string is whitespace-trimmed and returned.
If no _specifiers_ object is provided, the following defaults are used:
```json
{
"year": "%Y ",
"year-month": "%Y-%m ",
"year-month-date": "%Y-%m-%d ",
"quarter": "Q%q ",
"month": "%b ",
"date": "%d ",
"week": "W%U ",
"day": "%a ",
"hours": "%H:00",
"hours-minutes": "%H:%M",
"minutes": "00:%M",
"seconds": ":%S",
"milliseconds": ".%L"
}
```
If a _specifiers_ object is provided, its values are merged with the defaults above. As a result, for complete control callees may wish to override the multi-unit `"year-month"`, `"year-month-date"`, and `"hours-minutes"` entries in addition to any individual unit entries. The input _specifiers_ object can use a `null` value to invalidate an entry in the defaults.
<a name="timeBin" href="#timeBin">#</a>
vega.<b>timeBin</b>(<i>options</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-time/src/bin.js "Source")
Determine a temporal binning scheme, for example to create a histogram. Based on the options provided given, this method will search over a space of possible time unit bins, applying constraints such as the maximum number of allowable bins. Given a set of options (see below), returns an object describing the binning scheme, in terms of `units` and `step` properties. These values can then be used as input to the [timeFloor](#timeFloor) or [utcFloor](#utcFloor) methods.
The supported options properties are:
- _extent_: (required) A two-element (`[min, max]`) array indicating the date range over which the bin values are defined.
- _maxbins_: The maximum number of allowable bins (default `40`).
### Local Time Utilities
<a name="timeFloor" href="#timeFloor">#</a>
vega.<b>timeFloor</b>(<i>units</i>[, <i>step</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-time/src/floor.js "Source")
Returns a function that performs flooring (truncation) of input dates to given time _units_ in the local timezone. The _units_ argument must be an array of valid time unit strings, for example `['year', 'month']` or `['week', 'date']`. The optional _step_ argument (default 1) indicates the number of time unit steps (of the smallest provided unit) to include as part of the truncation scheme. For example, `utcFloor(['quarter'])` is equivalent to `utcFloor(['month'], 3)`.
<a name="timeInterval" href="#timeInterval">#</a>
vega.<b>timeInterval</b>(<i>unit</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-time/src/interval.js "Source")
Returns a [d3-time interval](https://github.com/d3/d3-time#_interval) for the given time _unit_ in the local timezone.
<a name="timeOffset" href="#timeOffset">#</a>
vega.<b>timeOffset</b>(<i>unit</i>, <i>date</i>[, <i>step</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-time/src/interval.js "Source")
Returns a new Date instance that offsets the given _date_ by the specified time _unit_ in the local timezone. The optional _step_ argument indicates the number of time unit steps to offset by (default 1).
<a name="timeSequence" href="#timeSequence">#</a>
vega.<b>timeSequence</b>(<i>unit</i>, <i>start</i>, <i>stop</i>[, <i>step</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-time/src/interval.js "Source")
Returns an array of Date instances from _start_ (inclusive) to _stop_ (exclusive), with each entry separated by the given time _unit_ in the local timezone. The optional _step_ argument indicates the number of time unit steps to take between each sequence entry (default 1).
<a name="dayofyear" href="#dayofyear">#</a>
vega.<b>dayofyear</b>(<i>date</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-time/src/util.js "Source")
Returns the one-based day of the year for the given _date_, which should be either a `Date` object or timestamp value.
<a name="week" href="#week">#</a>
vega.<b>week</b>(<i>date</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-time/src/util.js "Source")
Returns the week number of the year for the given _date_, which should be either a `Date` object or timestamp value. This function assumes Sunday-based weeks. Days before the first Sunday of the year are considered to be in week 0, the first Sunday of the year is the start of week 1, the second Sunday week 2, _etc._.
### UTC Time Utilities
<a name="utcFloor" href="#utcFloor">#</a>
vega.<b>utcFloor</b>(<i>units</i>[, <i>step</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-time/src/floor.js "Source")
Returns a function that performs flooring (truncation) of input dates to given time _units_ in [Coordinated Universal Time](https://en.wikipedia.org/wiki/Coordinated_Universal_Time) (UTC). The _units_ argument must be an array of valid time unit strings, for example `['year', 'month']` or `['week', 'date']`. The optional _step_ argument (default 1) indicates the number of time unit steps (of the smallest provided unit) to include as part of the truncation scheme. For example, `utcFloor(['quarter'])` is equivalent to `utcFloor(['month'], 3)`.
<a name="utcInterval" href="#utcInterval">#</a>
vega.<b>utcInterval</b>(<i>unit</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-time/src/interval.js "Source")
Returns a [d3-time interval](https://github.com/d3/d3-time#_interval) for the given time _unit_ in [Coordinated Universal Time](https://en.wikipedia.org/wiki/Coordinated_Universal_Time) (UTC).
<a name="utcOffset" href="#utcOffset">#</a>
vega.<b>utcOffset</b>(<i>unit</i>, <i>date</i>[, <i>step</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-time/src/interval.js "Source")
Returns a new Date instance that offsets the given _date_ by the specified time _unit_ in [Coordinated Universal Time](https://en.wikipedia.org/wiki/Coordinated_Universal_Time) (UTC). The optional _step_ argument indicates the number of time unit steps to offset by (default 1).
<a name="utcSequence" href="#utcSequence">#</a>
vega.<b>utcSequence</b>(<i>unit</i>, <i>start</i>, <i>stop</i>[, <i>step</i>])
[<>](https://github.com/vega/vega/blob/master/packages/vega-time/src/interval.js "Source")
Returns an array of Date instances from _start_ (inclusive) to _stop_ (exclusive), with each entry separated by the given time _unit_ in [Coordinated Universal Time](https://en.wikipedia.org/wiki/Coordinated_Universal_Time) (UTC). The optional _step_ argument indicates the number of time unit steps to take between each sequence entry (default 1).
<a name="utcdayofyear" href="#utcdayofyear">#</a>
vega.<b>utcdayofyear</b>(<i>date</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-time/src/util.js "Source")
Returns the one-based day of the year for the given _date_ in [Coordinated Universal Time](https://en.wikipedia.org/wiki/Coordinated_Universal_Time) (UTC), which should be either a `Date` object or timestamp value.
<a name="utcweek" href="#utcweek">#</a>
vega.<b>utcweek</b>(<i>date</i>)
[<>](https://github.com/vega/vega/blob/master/packages/vega-time/src/util.js "Source")
Returns the week number of the year for the given _date_ in [Coordinated Universal Time](https://en.wikipedia.org/wiki/Coordinated_Universal_Time) (UTC), which should be either a `Date` object or timestamp value. This function assumes Sunday-based weeks. Days before the first Sunday of the year are considered to be in week 0, the first Sunday of the year is the start of week 1, the second Sunday week 2, _etc._.

422
node_modules/vega-time/build/vega-time.js generated vendored Normal file
View File

@@ -0,0 +1,422 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vega-util'), require('d3-time'), require('d3-array')) :
typeof define === 'function' && define.amd ? define(['exports', 'vega-util', 'd3-time', 'd3-array'], factory) :
(global = global || self, factory(global.vega = {}, global.vega, global.d3, global.d3));
}(this, (function (exports, vegaUtil, d3Time, d3Array) { 'use strict';
const YEAR = 'year';
const QUARTER = 'quarter';
const MONTH = 'month';
const WEEK = 'week';
const DATE = 'date';
const DAY = 'day';
const DAYOFYEAR = 'dayofyear';
const HOURS = 'hours';
const MINUTES = 'minutes';
const SECONDS = 'seconds';
const MILLISECONDS = 'milliseconds';
const TIME_UNITS = [
YEAR,
QUARTER,
MONTH,
WEEK,
DATE,
DAY,
DAYOFYEAR,
HOURS,
MINUTES,
SECONDS,
MILLISECONDS
];
const UNITS = TIME_UNITS.reduce((o, u, i) => (o[u] = 1 + i, o), {});
function timeUnits(units) {
const u = vegaUtil.array(units).slice(),
m = {};
// check validity
if (!u.length) vegaUtil.error('Missing time unit.');
u.forEach(unit => {
if (vegaUtil.hasOwnProperty(UNITS, unit)) {
m[unit] = 1;
} else {
vegaUtil.error(`Invalid time unit: ${unit}.`);
}
});
const numTypes = (
(m[WEEK] || m[DAY] ? 1 : 0) +
(m[QUARTER] || m[MONTH] || m[DATE] ? 1 : 0) +
(m[DAYOFYEAR] ? 1 : 0)
);
if (numTypes > 1) {
vegaUtil.error(`Incompatible time units: ${units}`);
}
// ensure proper sort order
u.sort((a, b) => UNITS[a] - UNITS[b]);
return u;
}
const defaultSpecifiers = {
[YEAR]: '%Y ',
[QUARTER]: 'Q%q ',
[MONTH]: '%b ',
[DATE]: '%d ',
[WEEK]: 'W%U ',
[DAY]: '%a ',
[DAYOFYEAR]: '%j ',
[HOURS]: '%H:00',
[MINUTES]: '00:%M',
[SECONDS]: ':%S',
[MILLISECONDS]: '.%L',
[`${YEAR}-${MONTH}`]: '%Y-%m ',
[`${YEAR}-${MONTH}-${DATE}`]: '%Y-%m-%d ',
[`${HOURS}-${MINUTES}`]: '%H:%M'
};
function timeUnitSpecifier(units, specifiers) {
const s = vegaUtil.extend({}, defaultSpecifiers, specifiers),
u = timeUnits(units),
n = u.length;
let fmt = '', start = 0, end, key;
for (start=0; start<n; ) {
for (end=u.length; end > start; --end) {
key = u.slice(start, end).join('-');
if (s[key] != null) {
fmt += s[key];
start = end;
break;
}
}
}
return fmt.trim();
}
const t0 = new Date;
function localYear(y) {
t0.setFullYear(y);
t0.setMonth(0);
t0.setDate(1);
t0.setHours(0, 0, 0, 0);
return t0;
}
function dayofyear(d) {
return localDayOfYear(new Date(d));
}
function week(d) {
return localWeekNum(new Date(d));
}
function localDayOfYear(d) {
return d3Time.timeDay.count(localYear(d.getFullYear()) - 1, d);
}
function localWeekNum(d) {
return d3Time.timeWeek.count(localYear(d.getFullYear()) - 1, d);
}
function localFirst(y) {
return localYear(y).getDay();
}
function localDate(y, m, d, H, M, S, L) {
if (0 <= y && y < 100) {
var date = new Date(-1, m, d, H, M, S, L);
date.setFullYear(y);
return date;
}
return new Date(y, m, d, H, M, S, L);
}
function utcdayofyear(d) {
return utcDayOfYear(new Date(d));
}
function utcweek(d) {
return utcWeekNum(new Date(d));
}
function utcDayOfYear(d) {
const y = Date.UTC(d.getUTCFullYear(), 0, 1);
return d3Time.utcDay.count(y - 1, d);
}
function utcWeekNum(d) {
const y = Date.UTC(d.getUTCFullYear(), 0, 1);
return d3Time.utcWeek.count(y - 1, d);
}
function utcFirst(y) {
t0.setTime(Date.UTC(y, 0, 1));
return t0.getUTCDay();
}
function utcDate(y, m, d, H, M, S, L) {
if (0 <= y && y < 100) {
var date = new Date(Date.UTC(-1, m, d, H, M, S, L));
date.setUTCFullYear(d.y);
return date;
}
return new Date(Date.UTC(y, m, d, H, M, S, L));
}
function floor(units, step, get, inv, newDate) {
const s = step || 1,
b = vegaUtil.peek(units),
_ = (unit, p, key) => {
key = key || unit;
return getUnit(get[key], inv[key], unit === b && s, p);
};
const t = new Date,
u = vegaUtil.toSet(units),
y = u[YEAR] ? _(YEAR) : vegaUtil.constant(2012),
m = u[MONTH] ? _(MONTH)
: u[QUARTER] ? _(QUARTER)
: vegaUtil.zero,
d = u[WEEK] && u[DAY] ? _(DAY, 1, WEEK + DAY)
: u[WEEK] ? _(WEEK, 1)
: u[DAY] ? _(DAY, 1)
: u[DATE] ? _(DATE, 1)
: u[DAYOFYEAR] ? _(DAYOFYEAR, 1)
: vegaUtil.one,
H = u[HOURS] ? _(HOURS) : vegaUtil.zero,
M = u[MINUTES] ? _(MINUTES) : vegaUtil.zero,
S = u[SECONDS] ? _(SECONDS) : vegaUtil.zero,
L = u[MILLISECONDS] ? _(MILLISECONDS) : vegaUtil.zero;
return function(v) {
t.setTime(+v);
const year = y(t);
return newDate(year, m(t), d(t, year), H(t), M(t), S(t), L(t));
};
}
function getUnit(f, inv, step, phase) {
const u = step <= 1 ? f
: phase ? (d, y) => phase + step * Math.floor((f(d, y) - phase) / step)
: (d, y) => step * Math.floor(f(d, y) / step);
return inv ? (d, y) => inv(u(d, y), y) : u;
}
// returns the day of the year based on week number, day of week,
// and the day of the week for the first day of the year
function weekday(week, day, firstDay) {
return day + week * 7 - (firstDay + 6) % 7;
}
// -- LOCAL TIME --
const localGet = {
[YEAR]: d => d.getFullYear(),
[QUARTER]: d => Math.floor(d.getMonth() / 3),
[MONTH]: d => d.getMonth(),
[DATE]: d => d.getDate(),
[HOURS]: d => d.getHours(),
[MINUTES]: d => d.getMinutes(),
[SECONDS]: d => d.getSeconds(),
[MILLISECONDS]: d => d.getMilliseconds(),
[DAYOFYEAR]: d => localDayOfYear(d),
[WEEK]: d => localWeekNum(d),
[WEEK + DAY]: (d, y) => weekday(localWeekNum(d), d.getDay(), localFirst(y)),
[DAY]: (d, y) => weekday(1, d.getDay(), localFirst(y))
};
const localInv = {
[QUARTER]: q => 3 * q,
[WEEK]: (w, y) => weekday(w, 0, localFirst(y))
};
function timeFloor(units, step) {
return floor(units, step || 1, localGet, localInv, localDate);
}
// -- UTC TIME --
const utcGet = {
[YEAR]: d => d.getUTCFullYear(),
[QUARTER]: d => Math.floor(d.getUTCMonth() / 3),
[MONTH]: d => d.getUTCMonth(),
[DATE]: d => d.getUTCDate(),
[HOURS]: d => d.getUTCHours(),
[MINUTES]: d => d.getUTCMinutes(),
[SECONDS]: d => d.getUTCSeconds(),
[MILLISECONDS]: d => d.getUTCMilliseconds(),
[DAYOFYEAR]: d => utcDayOfYear(d),
[WEEK]: d => utcWeekNum(d),
[DAY]: (d, y) => weekday(1, d.getUTCDay(), utcFirst(y)),
[WEEK + DAY]: (d, y) => weekday(utcWeekNum(d), d.getUTCDay(), utcFirst(y))
};
const utcInv = {
[QUARTER]: q => 3 * q,
[WEEK]: (w, y) => weekday(w, 0, utcFirst(y))
};
function utcFloor(units, step) {
return floor(units, step || 1, utcGet, utcInv, utcDate);
}
const timeIntervals = {
[YEAR]: d3Time.timeYear,
[QUARTER]: d3Time.timeMonth.every(3),
[MONTH]: d3Time.timeMonth,
[WEEK]: d3Time.timeWeek,
[DATE]: d3Time.timeDay,
[DAY]: d3Time.timeDay,
[DAYOFYEAR]: d3Time.timeDay,
[HOURS]: d3Time.timeHour,
[MINUTES]: d3Time.timeMinute,
[SECONDS]: d3Time.timeSecond,
[MILLISECONDS]: d3Time.timeMillisecond
};
const utcIntervals = {
[YEAR]: d3Time.utcYear,
[QUARTER]: d3Time.utcMonth.every(3),
[MONTH]: d3Time.utcMonth,
[WEEK]: d3Time.utcWeek,
[DATE]: d3Time.utcDay,
[DAY]: d3Time.utcDay,
[DAYOFYEAR]: d3Time.utcDay,
[HOURS]: d3Time.utcHour,
[MINUTES]: d3Time.utcMinute,
[SECONDS]: d3Time.utcSecond,
[MILLISECONDS]: d3Time.utcMillisecond
};
function timeInterval(unit) {
return timeIntervals[unit];
}
function utcInterval(unit) {
return utcIntervals[unit];
}
function offset(ival, date, step) {
return ival ? ival.offset(date, step) : undefined;
}
function timeOffset(unit, date, step) {
return offset(timeInterval(unit), date, step);
}
function utcOffset(unit, date, step) {
return offset(utcInterval(unit), date, step);
}
function sequence(ival, start, stop, step) {
return ival ? ival.range(start, stop, step) : undefined;
}
function timeSequence(unit, start, stop, step) {
return sequence(timeInterval(unit), start, stop, step);
}
function utcSequence(unit, start, stop, step) {
return sequence(utcInterval(unit), start, stop, step);
}
const durationSecond = 1000,
durationMinute = durationSecond * 60,
durationHour = durationMinute * 60,
durationDay = durationHour * 24,
durationWeek = durationDay * 7,
durationMonth = durationDay * 30,
durationYear = durationDay * 365;
const Milli = [YEAR, MONTH, DATE, HOURS, MINUTES, SECONDS, MILLISECONDS],
Seconds = Milli.slice(0, -1),
Minutes = Seconds.slice(0, -1),
Hours = Minutes.slice(0, -1),
Day = Hours.slice(0, -1),
Week = [YEAR, WEEK],
Month = [YEAR, MONTH],
Year = [YEAR];
const intervals = [
[Seconds, 1, durationSecond],
[Seconds, 5, 5 * durationSecond],
[Seconds, 15, 15 * durationSecond],
[Seconds, 30, 30 * durationSecond],
[Minutes, 1, durationMinute],
[Minutes, 5, 5 * durationMinute],
[Minutes, 15, 15 * durationMinute],
[Minutes, 30, 30 * durationMinute],
[ Hours, 1, durationHour ],
[ Hours, 3, 3 * durationHour ],
[ Hours, 6, 6 * durationHour ],
[ Hours, 12, 12 * durationHour ],
[ Day, 1, durationDay ],
[ Week, 1, durationWeek ],
[ Month, 1, durationMonth ],
[ Month, 3, 3 * durationMonth ],
[ Year, 1, durationYear ]
];
function bin(opt) {
const ext = opt.extent,
max = opt.maxbins || 40,
target = Math.abs(vegaUtil.span(ext)) / max;
let i = d3Array.bisector(i => i[2]).right(intervals, target),
units, step;
if (i === intervals.length) {
units = Year,
step = d3Array.tickStep(ext[0] / durationYear, ext[1] / durationYear, max);
} else if (i) {
i = intervals[target / intervals[i - 1][2] < intervals[i][2] / target ? i - 1 : i];
units = i[0];
step = i[1];
} else {
units = Milli;
step = Math.max(d3Array.tickStep(ext[0], ext[1], max), 1);
}
return {units, step};
}
exports.DATE = DATE;
exports.DAY = DAY;
exports.DAYOFYEAR = DAYOFYEAR;
exports.HOURS = HOURS;
exports.MILLISECONDS = MILLISECONDS;
exports.MINUTES = MINUTES;
exports.MONTH = MONTH;
exports.QUARTER = QUARTER;
exports.SECONDS = SECONDS;
exports.TIME_UNITS = TIME_UNITS;
exports.WEEK = WEEK;
exports.YEAR = YEAR;
exports.dayofyear = dayofyear;
exports.timeBin = bin;
exports.timeFloor = timeFloor;
exports.timeInterval = timeInterval;
exports.timeOffset = timeOffset;
exports.timeSequence = timeSequence;
exports.timeUnitSpecifier = timeUnitSpecifier;
exports.timeUnits = timeUnits;
exports.utcFloor = utcFloor;
exports.utcInterval = utcInterval;
exports.utcOffset = utcOffset;
exports.utcSequence = utcSequence;
exports.utcdayofyear = utcdayofyear;
exports.utcweek = utcweek;
exports.week = week;
Object.defineProperty(exports, '__esModule', { value: true });
})));

1
node_modules/vega-time/build/vega-time.min.js generated vendored Normal file

File diff suppressed because one or more lines are too long

41
node_modules/vega-time/index.js generated vendored Normal file
View File

@@ -0,0 +1,41 @@
export {
TIME_UNITS,
YEAR,
QUARTER,
MONTH,
WEEK,
DATE,
DAY,
DAYOFYEAR,
HOURS,
MINUTES,
SECONDS,
MILLISECONDS,
timeUnitSpecifier,
timeUnits
} from './src/units';
export {
dayofyear,
week,
utcdayofyear,
utcweek
} from './src/util';
export {
timeFloor,
utcFloor
} from './src/floor';
export {
timeInterval,
timeOffset,
timeSequence,
utcInterval,
utcOffset,
utcSequence
} from './src/interval';
export {
default as timeBin
} from './src/bin';

72
node_modules/vega-time/package.json generated vendored Normal file
View File

@@ -0,0 +1,72 @@
{
"_from": "vega-time@~2.0.1",
"_id": "vega-time@2.0.1",
"_inBundle": false,
"_integrity": "sha512-Ij0gmABKDRKAMUTh/1AGSSkU6ocWiteLkIK/cmcnt98u8LiuVcFT5w7gusd0+ibO9EooeMKazn5xPmjvQs0qEg==",
"_location": "/vega-time",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "vega-time@~2.0.1",
"name": "vega-time",
"escapedName": "vega-time",
"rawSpec": "~2.0.1",
"saveSpec": null,
"fetchSpec": "~2.0.1"
},
"_requiredBy": [
"/vega",
"/vega-format",
"/vega-functions",
"/vega-scale",
"/vega-transforms"
],
"_resolved": "https://registry.npmjs.org/vega-time/-/vega-time-2.0.1.tgz",
"_shasum": "2a91c3acafd091e6724063dea26e4b3fe6061d2f",
"_spec": "vega-time@~2.0.1",
"_where": "/home/prabhatdev/Documents/opensource/gitHubStats/waka-readme-stats/node_modules/vega",
"author": {
"name": "Jeffrey Heer",
"url": "http://idl.cs.washington.edu"
},
"bugs": {
"url": "https://github.com/vega/vega/issues"
},
"bundleDependencies": false,
"dependencies": {
"d3-array": "^2.4.0",
"d3-time": "^1.1.0",
"vega-util": "^1.14.0"
},
"deprecated": false,
"description": "JavaScript date/time utilities for Vega.",
"gitHead": "8fe8d36961c128df8300e6bc4fe6aac1e537bbe0",
"homepage": "https://github.com/vega/vega#readme",
"keywords": [
"vega",
"date",
"time",
"utilities"
],
"license": "BSD-3-Clause",
"main": "build/vega-time.js",
"module": "index",
"name": "vega-time",
"repository": {
"type": "git",
"url": "git+https://github.com/vega/vega.git"
},
"scripts": {
"build": "yarn rollup",
"postbuild": "terser build/vega-time.js -c -m -o build/vega-time.min.js",
"postpublish": "git push && git push --tags",
"prebuild": "rimraf build && mkdir build",
"prepublishOnly": "yarn test && yarn build",
"pretest": "yarn prebuild && yarn rollup",
"rollup": "rollup -g d3-array:d3,d3-time:d3,vega-util:vega -f umd -n vega -o build/vega-time.js -- index.js",
"test": "tape 'test/**/*-test.js'"
},
"types": "index.d.ts",
"version": "2.0.1"
}

63
node_modules/vega-time/src/bin.js generated vendored Normal file
View File

@@ -0,0 +1,63 @@
import {DATE, HOURS, MILLISECONDS, MINUTES, MONTH, SECONDS, WEEK, YEAR} from './units';
import {span} from 'vega-util';
import {bisector, tickStep} from 'd3-array';
const durationSecond = 1000,
durationMinute = durationSecond * 60,
durationHour = durationMinute * 60,
durationDay = durationHour * 24,
durationWeek = durationDay * 7,
durationMonth = durationDay * 30,
durationYear = durationDay * 365;
const Milli = [YEAR, MONTH, DATE, HOURS, MINUTES, SECONDS, MILLISECONDS],
Seconds = Milli.slice(0, -1),
Minutes = Seconds.slice(0, -1),
Hours = Minutes.slice(0, -1),
Day = Hours.slice(0, -1),
Week = [YEAR, WEEK],
Month = [YEAR, MONTH],
Year = [YEAR];
const intervals = [
[Seconds, 1, durationSecond],
[Seconds, 5, 5 * durationSecond],
[Seconds, 15, 15 * durationSecond],
[Seconds, 30, 30 * durationSecond],
[Minutes, 1, durationMinute],
[Minutes, 5, 5 * durationMinute],
[Minutes, 15, 15 * durationMinute],
[Minutes, 30, 30 * durationMinute],
[ Hours, 1, durationHour ],
[ Hours, 3, 3 * durationHour ],
[ Hours, 6, 6 * durationHour ],
[ Hours, 12, 12 * durationHour ],
[ Day, 1, durationDay ],
[ Week, 1, durationWeek ],
[ Month, 1, durationMonth ],
[ Month, 3, 3 * durationMonth ],
[ Year, 1, durationYear ]
];
export default function(opt) {
const ext = opt.extent,
max = opt.maxbins || 40,
target = Math.abs(span(ext)) / max;
let i = bisector(i => i[2]).right(intervals, target),
units, step;
if (i === intervals.length) {
units = Year,
step = tickStep(ext[0] / durationYear, ext[1] / durationYear, max);
} else if (i) {
i = intervals[target / intervals[i - 1][2] < intervals[i][2] / target ? i - 1 : i];
units = i[0];
step = i[1];
} else {
units = Milli;
step = Math.max(tickStep(ext[0], ext[1], max), 1);
}
return {units, step};
}

115
node_modules/vega-time/src/floor.js generated vendored Normal file
View File

@@ -0,0 +1,115 @@
import {
DATE,
DAY,
DAYOFYEAR,
HOURS,
MILLISECONDS,
MINUTES,
MONTH,
QUARTER,
SECONDS,
WEEK,
YEAR
} from './units';
import {
localDate, localDayOfYear, localFirst, localWeekNum,
utcDate, utcDayOfYear, utcFirst, utcWeekNum
} from './util';
import {constant, one, peek, toSet, zero} from 'vega-util';
function floor(units, step, get, inv, newDate) {
const s = step || 1,
b = peek(units),
_ = (unit, p, key) => {
key = key || unit;
return getUnit(get[key], inv[key], unit === b && s, p);
};
const t = new Date,
u = toSet(units),
y = u[YEAR] ? _(YEAR) : constant(2012),
m = u[MONTH] ? _(MONTH)
: u[QUARTER] ? _(QUARTER)
: zero,
d = u[WEEK] && u[DAY] ? _(DAY, 1, WEEK + DAY)
: u[WEEK] ? _(WEEK, 1)
: u[DAY] ? _(DAY, 1)
: u[DATE] ? _(DATE, 1)
: u[DAYOFYEAR] ? _(DAYOFYEAR, 1)
: one,
H = u[HOURS] ? _(HOURS) : zero,
M = u[MINUTES] ? _(MINUTES) : zero,
S = u[SECONDS] ? _(SECONDS) : zero,
L = u[MILLISECONDS] ? _(MILLISECONDS) : zero;
return function(v) {
t.setTime(+v);
const year = y(t);
return newDate(year, m(t), d(t, year), H(t), M(t), S(t), L(t));
};
}
function getUnit(f, inv, step, phase) {
const u = step <= 1 ? f
: phase ? (d, y) => phase + step * Math.floor((f(d, y) - phase) / step)
: (d, y) => step * Math.floor(f(d, y) / step);
return inv ? (d, y) => inv(u(d, y), y) : u;
}
// returns the day of the year based on week number, day of week,
// and the day of the week for the first day of the year
function weekday(week, day, firstDay) {
return day + week * 7 - (firstDay + 6) % 7;
}
// -- LOCAL TIME --
const localGet = {
[YEAR]: d => d.getFullYear(),
[QUARTER]: d => Math.floor(d.getMonth() / 3),
[MONTH]: d => d.getMonth(),
[DATE]: d => d.getDate(),
[HOURS]: d => d.getHours(),
[MINUTES]: d => d.getMinutes(),
[SECONDS]: d => d.getSeconds(),
[MILLISECONDS]: d => d.getMilliseconds(),
[DAYOFYEAR]: d => localDayOfYear(d),
[WEEK]: d => localWeekNum(d),
[WEEK + DAY]: (d, y) => weekday(localWeekNum(d), d.getDay(), localFirst(y)),
[DAY]: (d, y) => weekday(1, d.getDay(), localFirst(y))
};
const localInv = {
[QUARTER]: q => 3 * q,
[WEEK]: (w, y) => weekday(w, 0, localFirst(y))
};
export function timeFloor(units, step) {
return floor(units, step || 1, localGet, localInv, localDate);
}
// -- UTC TIME --
const utcGet = {
[YEAR]: d => d.getUTCFullYear(),
[QUARTER]: d => Math.floor(d.getUTCMonth() / 3),
[MONTH]: d => d.getUTCMonth(),
[DATE]: d => d.getUTCDate(),
[HOURS]: d => d.getUTCHours(),
[MINUTES]: d => d.getUTCMinutes(),
[SECONDS]: d => d.getUTCSeconds(),
[MILLISECONDS]: d => d.getUTCMilliseconds(),
[DAYOFYEAR]: d => utcDayOfYear(d),
[WEEK]: d => utcWeekNum(d),
[DAY]: (d, y) => weekday(1, d.getUTCDay(), utcFirst(y)),
[WEEK + DAY]: (d, y) => weekday(utcWeekNum(d), d.getUTCDay(), utcFirst(y))
};
const utcInv = {
[QUARTER]: q => 3 * q,
[WEEK]: (w, y) => weekday(w, 0, utcFirst(y))
};
export function utcFloor(units, step) {
return floor(units, step || 1, utcGet, utcInv, utcDate);
}

92
node_modules/vega-time/src/interval.js generated vendored Normal file
View File

@@ -0,0 +1,92 @@
import {
DATE,
DAY,
DAYOFYEAR,
HOURS,
MILLISECONDS,
MINUTES,
MONTH,
QUARTER,
SECONDS,
WEEK,
YEAR
} from './units';
import {
timeDay,
timeHour,
timeMillisecond,
timeMinute,
timeMonth,
timeSecond,
timeWeek,
timeYear,
utcDay,
utcHour,
utcMillisecond,
utcMinute,
utcMonth,
utcSecond,
utcWeek,
utcYear
} from 'd3-time';
const timeIntervals = {
[YEAR]: timeYear,
[QUARTER]: timeMonth.every(3),
[MONTH]: timeMonth,
[WEEK]: timeWeek,
[DATE]: timeDay,
[DAY]: timeDay,
[DAYOFYEAR]: timeDay,
[HOURS]: timeHour,
[MINUTES]: timeMinute,
[SECONDS]: timeSecond,
[MILLISECONDS]: timeMillisecond
};
const utcIntervals = {
[YEAR]: utcYear,
[QUARTER]: utcMonth.every(3),
[MONTH]: utcMonth,
[WEEK]: utcWeek,
[DATE]: utcDay,
[DAY]: utcDay,
[DAYOFYEAR]: utcDay,
[HOURS]: utcHour,
[MINUTES]: utcMinute,
[SECONDS]: utcSecond,
[MILLISECONDS]: utcMillisecond
};
export function timeInterval(unit) {
return timeIntervals[unit];
}
export function utcInterval(unit) {
return utcIntervals[unit];
}
function offset(ival, date, step) {
return ival ? ival.offset(date, step) : undefined;
}
export function timeOffset(unit, date, step) {
return offset(timeInterval(unit), date, step);
}
export function utcOffset(unit, date, step) {
return offset(utcInterval(unit), date, step);
}
function sequence(ival, start, stop, step) {
return ival ? ival.range(start, stop, step) : undefined;
}
export function timeSequence(unit, start, stop, step) {
return sequence(timeInterval(unit), start, stop, step);
}
export function utcSequence(unit, start, stop, step) {
return sequence(utcInterval(unit), start, stop, step);
}

98
node_modules/vega-time/src/units.js generated vendored Normal file
View File

@@ -0,0 +1,98 @@
import {array, error, extend, hasOwnProperty} from 'vega-util';
export const YEAR = 'year';
export const QUARTER = 'quarter';
export const MONTH = 'month';
export const WEEK = 'week';
export const DATE = 'date';
export const DAY = 'day';
export const DAYOFYEAR = 'dayofyear';
export const HOURS = 'hours';
export const MINUTES = 'minutes';
export const SECONDS = 'seconds';
export const MILLISECONDS = 'milliseconds';
export const TIME_UNITS = [
YEAR,
QUARTER,
MONTH,
WEEK,
DATE,
DAY,
DAYOFYEAR,
HOURS,
MINUTES,
SECONDS,
MILLISECONDS
];
const UNITS = TIME_UNITS.reduce((o, u, i) => (o[u] = 1 + i, o), {});
export function timeUnits(units) {
const u = array(units).slice(),
m = {};
// check validity
if (!u.length) error('Missing time unit.');
u.forEach(unit => {
if (hasOwnProperty(UNITS, unit)) {
m[unit] = 1;
} else {
error(`Invalid time unit: ${unit}.`);
}
});
const numTypes = (
(m[WEEK] || m[DAY] ? 1 : 0) +
(m[QUARTER] || m[MONTH] || m[DATE] ? 1 : 0) +
(m[DAYOFYEAR] ? 1 : 0)
);
if (numTypes > 1) {
error(`Incompatible time units: ${units}`);
}
// ensure proper sort order
u.sort((a, b) => UNITS[a] - UNITS[b]);
return u;
}
const defaultSpecifiers = {
[YEAR]: '%Y ',
[QUARTER]: 'Q%q ',
[MONTH]: '%b ',
[DATE]: '%d ',
[WEEK]: 'W%U ',
[DAY]: '%a ',
[DAYOFYEAR]: '%j ',
[HOURS]: '%H:00',
[MINUTES]: '00:%M',
[SECONDS]: ':%S',
[MILLISECONDS]: '.%L',
[`${YEAR}-${MONTH}`]: '%Y-%m ',
[`${YEAR}-${MONTH}-${DATE}`]: '%Y-%m-%d ',
[`${HOURS}-${MINUTES}`]: '%H:%M'
};
export function timeUnitSpecifier(units, specifiers) {
const s = extend({}, defaultSpecifiers, specifiers),
u = timeUnits(units),
n = u.length;
let fmt = '', start = 0, end, key;
for (start=0; start<n; ) {
for (end=u.length; end > start; --end) {
key = u.slice(start, end).join('-');
if (s[key] != null) {
fmt += s[key];
start = end;
break;
}
}
}
return fmt.trim();
}

72
node_modules/vega-time/src/util.js generated vendored Normal file
View File

@@ -0,0 +1,72 @@
import {timeDay, timeWeek, utcDay, utcWeek} from 'd3-time';
const t0 = new Date;
function localYear(y) {
t0.setFullYear(y);
t0.setMonth(0);
t0.setDate(1);
t0.setHours(0, 0, 0, 0);
return t0;
}
export function dayofyear(d) {
return localDayOfYear(new Date(d));
}
export function week(d) {
return localWeekNum(new Date(d));
}
export function localDayOfYear(d) {
return timeDay.count(localYear(d.getFullYear()) - 1, d);
}
export function localWeekNum(d) {
return timeWeek.count(localYear(d.getFullYear()) - 1, d);
}
export function localFirst(y) {
return localYear(y).getDay();
}
export function localDate(y, m, d, H, M, S, L) {
if (0 <= y && y < 100) {
var date = new Date(-1, m, d, H, M, S, L);
date.setFullYear(y);
return date;
}
return new Date(y, m, d, H, M, S, L);
}
export function utcdayofyear(d) {
return utcDayOfYear(new Date(d));
}
export function utcweek(d) {
return utcWeekNum(new Date(d));
}
export function utcDayOfYear(d) {
const y = Date.UTC(d.getUTCFullYear(), 0, 1);
return utcDay.count(y - 1, d);
}
export function utcWeekNum(d) {
const y = Date.UTC(d.getUTCFullYear(), 0, 1);
return utcWeek.count(y - 1, d);
}
export function utcFirst(y) {
t0.setTime(Date.UTC(y, 0, 1));
return t0.getUTCDay();
}
export function utcDate(y, m, d, H, M, S, L) {
if (0 <= y && y < 100) {
var date = new Date(Date.UTC(-1, m, d, H, M, S, L));
date.setUTCFullYear(d.y);
return date;
}
return new Date(Date.UTC(y, m, d, H, M, S, L));
}