@visactor/vchart
Version:
charts lib based @visactor/VGrammar
1,251 lines (1,154 loc) • 4.98 MB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.VChart = {}));
})(this, (function (exports) { 'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
function __rest$e(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
}
return t;
}
function __awaiter$a(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function (resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
}
const arrayParser = (array) => {
return array;
};
exports.RenderModeEnum = void 0;
(function (RenderModeEnum) {
RenderModeEnum["desktop-browser"] = "desktop-browser";
RenderModeEnum["mobile-browser"] = "mobile-browser";
RenderModeEnum["node"] = "node";
RenderModeEnum["worker"] = "worker";
RenderModeEnum["miniApp"] = "miniApp";
RenderModeEnum["wx"] = "wx";
RenderModeEnum["tt"] = "tt";
RenderModeEnum["harmony"] = "harmony";
RenderModeEnum["desktop-miniApp"] = "desktop-miniApp";
RenderModeEnum["lynx"] = "lynx";
})(exports.RenderModeEnum || (exports.RenderModeEnum = {}));
var ComponentTypeEnum;
(function (ComponentTypeEnum) {
ComponentTypeEnum["cartesianAxis"] = "cartesianAxis";
ComponentTypeEnum["cartesianBandAxis"] = "cartesianAxis-band";
ComponentTypeEnum["cartesianLinearAxis"] = "cartesianAxis-linear";
ComponentTypeEnum["cartesianTimeAxis"] = "cartesianAxis-time";
ComponentTypeEnum["cartesianLogAxis"] = "cartesianAxis-log";
ComponentTypeEnum["cartesianSymlogAxis"] = "cartesianAxis-symlog";
ComponentTypeEnum["polarAxis"] = "polarAxis";
ComponentTypeEnum["polarBandAxis"] = "polarAxis-band";
ComponentTypeEnum["polarLinearAxis"] = "polarAxis-linear";
ComponentTypeEnum["crosshair"] = "crosshair";
ComponentTypeEnum["cartesianCrosshair"] = "cartesianCrosshair";
ComponentTypeEnum["polarCrosshair"] = "polarCrosshair";
ComponentTypeEnum["dataZoom"] = "dataZoom";
ComponentTypeEnum["geoCoordinate"] = "geoCoordinate";
ComponentTypeEnum["indicator"] = "indicator";
ComponentTypeEnum["discreteLegend"] = "discreteLegend";
ComponentTypeEnum["continuousLegend"] = "continuousLegend";
ComponentTypeEnum["colorLegend"] = "colorLegend";
ComponentTypeEnum["sizeLegend"] = "sizeLegend";
ComponentTypeEnum["markLine"] = "markLine";
ComponentTypeEnum["markArea"] = "markArea";
ComponentTypeEnum["markPoint"] = "markPoint";
ComponentTypeEnum["polarMarkLine"] = "polarMarkLine";
ComponentTypeEnum["polarMarkArea"] = "polarMarkArea";
ComponentTypeEnum["polarMarkPoint"] = "polarMarkPoint";
ComponentTypeEnum["geoMarkPoint"] = "geoMarkPoint";
ComponentTypeEnum["tooltip"] = "tooltip";
ComponentTypeEnum["title"] = "title";
ComponentTypeEnum["player"] = "player";
ComponentTypeEnum["scrollBar"] = "scrollBar";
ComponentTypeEnum["label"] = "label";
ComponentTypeEnum["totalLabel"] = "totalLabel";
ComponentTypeEnum["brush"] = "brush";
ComponentTypeEnum["poptip"] = "poptip";
ComponentTypeEnum["customMark"] = "customMark";
})(ComponentTypeEnum || (ComponentTypeEnum = {}));
function getDefaultExportFromCjs (x) {
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
}
var eventemitter3 = {exports: {}};
(function (module) {
var has = Object.prototype.hasOwnProperty,
prefix = '~';
/**
* Constructor to create a storage for our `EE` objects.
* An `Events` instance is a plain object whose properties are event names.
*
* @constructor
* @private
*/
function Events() {}
//
// We try to not inherit from `Object.prototype`. In some engines creating an
// instance in this way is faster than calling `Object.create(null)` directly.
// If `Object.create(null)` is not supported we prefix the event names with a
// character to make sure that the built-in object properties are not
// overridden or used as an attack vector.
//
if (Object.create) {
Events.prototype = Object.create(null);
//
// This hack is needed because the `__proto__` property is still inherited in
// some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
//
if (!new Events().__proto__) prefix = false;
}
/**
* Representation of a single event listener.
*
* @param {Function} fn The listener function.
* @param {*} context The context to invoke the listener with.
* @param {Boolean} [once=false] Specify if the listener is a one-time listener.
* @constructor
* @private
*/
function EE(fn, context, once) {
this.fn = fn;
this.context = context;
this.once = once || false;
}
/**
* Add a listener for a given event.
*
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
* @param {(String|Symbol)} event The event name.
* @param {Function} fn The listener function.
* @param {*} context The context to invoke the listener with.
* @param {Boolean} once Specify if the listener is a one-time listener.
* @returns {EventEmitter}
* @private
*/
function addListener(emitter, event, fn, context, once) {
if (typeof fn !== 'function') {
throw new TypeError('The listener must be a function');
}
var listener = new EE(fn, context || emitter, once),
evt = prefix ? prefix + event : event;
if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);else emitter._events[evt] = [emitter._events[evt], listener];
return emitter;
}
/**
* Clear event by name.
*
* @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
* @param {(String|Symbol)} evt The Event name.
* @private
*/
function clearEvent(emitter, evt) {
if (--emitter._eventsCount === 0) emitter._events = new Events();else delete emitter._events[evt];
}
/**
* Minimal `EventEmitter` interface that is molded against the Node.js
* `EventEmitter` interface.
*
* @constructor
* @public
*/
function EventEmitter() {
this._events = new Events();
this._eventsCount = 0;
}
/**
* Return an array listing the events for which the emitter has registered
* listeners.
*
* @returns {Array}
* @public
*/
EventEmitter.prototype.eventNames = function eventNames() {
var names = [],
events,
name;
if (this._eventsCount === 0) return names;
for (name in events = this._events) {
if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
}
if (Object.getOwnPropertySymbols) {
return names.concat(Object.getOwnPropertySymbols(events));
}
return names;
};
/**
* Return the listeners registered for a given event.
*
* @param {(String|Symbol)} event The event name.
* @returns {Array} The registered listeners.
* @public
*/
EventEmitter.prototype.listeners = function listeners(event) {
var evt = prefix ? prefix + event : event,
handlers = this._events[evt];
if (!handlers) return [];
if (handlers.fn) return [handlers.fn];
for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
ee[i] = handlers[i].fn;
}
return ee;
};
/**
* Return the number of listeners listening to a given event.
*
* @param {(String|Symbol)} event The event name.
* @returns {Number} The number of listeners.
* @public
*/
EventEmitter.prototype.listenerCount = function listenerCount(event) {
var evt = prefix ? prefix + event : event,
listeners = this._events[evt];
if (!listeners) return 0;
if (listeners.fn) return 1;
return listeners.length;
};
/**
* Calls each of the listeners registered for a given event.
*
* @param {(String|Symbol)} event The event name.
* @returns {Boolean} `true` if the event had listeners, else `false`.
* @public
*/
EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
var evt = prefix ? prefix + event : event;
if (!this._events[evt]) return false;
var listeners = this._events[evt],
len = arguments.length,
args,
i;
if (listeners.fn) {
if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
switch (len) {
case 1:
return listeners.fn.call(listeners.context), true;
case 2:
return listeners.fn.call(listeners.context, a1), true;
case 3:
return listeners.fn.call(listeners.context, a1, a2), true;
case 4:
return listeners.fn.call(listeners.context, a1, a2, a3), true;
case 5:
return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
case 6:
return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
}
for (i = 1, args = new Array(len - 1); i < len; i++) {
args[i - 1] = arguments[i];
}
listeners.fn.apply(listeners.context, args);
} else {
var length = listeners.length,
j;
for (i = 0; i < length; i++) {
if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
switch (len) {
case 1:
listeners[i].fn.call(listeners[i].context);
break;
case 2:
listeners[i].fn.call(listeners[i].context, a1);
break;
case 3:
listeners[i].fn.call(listeners[i].context, a1, a2);
break;
case 4:
listeners[i].fn.call(listeners[i].context, a1, a2, a3);
break;
default:
if (!args) for (j = 1, args = new Array(len - 1); j < len; j++) {
args[j - 1] = arguments[j];
}
listeners[i].fn.apply(listeners[i].context, args);
}
}
}
return true;
};
/**
* Add a listener for a given event.
*
* @param {(String|Symbol)} event The event name.
* @param {Function} fn The listener function.
* @param {*} [context=this] The context to invoke the listener with.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.on = function on(event, fn, context) {
return addListener(this, event, fn, context, false);
};
/**
* Add a one-time listener for a given event.
*
* @param {(String|Symbol)} event The event name.
* @param {Function} fn The listener function.
* @param {*} [context=this] The context to invoke the listener with.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.once = function once(event, fn, context) {
return addListener(this, event, fn, context, true);
};
/**
* Remove the listeners of a given event.
*
* @param {(String|Symbol)} event The event name.
* @param {Function} fn Only remove the listeners that match this function.
* @param {*} context Only remove the listeners that have this context.
* @param {Boolean} once Only remove one-time listeners.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
var evt = prefix ? prefix + event : event;
if (!this._events[evt]) return this;
if (!fn) {
clearEvent(this, evt);
return this;
}
var listeners = this._events[evt];
if (listeners.fn) {
if (listeners.fn === fn && (!once || listeners.once) && (!context || listeners.context === context)) {
clearEvent(this, evt);
}
} else {
for (var i = 0, events = [], length = listeners.length; i < length; i++) {
if (listeners[i].fn !== fn || once && !listeners[i].once || context && listeners[i].context !== context) {
events.push(listeners[i]);
}
}
//
// Reset the array, or remove it completely if we have no more listeners.
//
if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;else clearEvent(this, evt);
}
return this;
};
/**
* Remove all listeners, or those of the specified event.
*
* @param {(String|Symbol)} [event] The event name.
* @returns {EventEmitter} `this`.
* @public
*/
EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
var evt;
if (event) {
evt = prefix ? prefix + event : event;
if (this._events[evt]) clearEvent(this, evt);
} else {
this._events = new Events();
this._eventsCount = 0;
}
return this;
};
//
// Alias methods names because people roll like that.
//
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
EventEmitter.prototype.addListener = EventEmitter.prototype.on;
//
// Expose the prefix.
//
EventEmitter.prefixed = prefix;
//
// Allow `EventEmitter` to be imported as module namespace.
//
EventEmitter.EventEmitter = EventEmitter;
//
// Expose the module.
//
{
module.exports = EventEmitter;
}
})(eventemitter3);
var eventemitter3Exports = eventemitter3.exports;
var EventEmitter = /*@__PURE__*/getDefaultExportFromCjs(eventemitter3Exports);
const isType = (value, type) => Object.prototype.toString.call(value) === `[object ${type}]`;
var isType$1 = isType;
const isBoolean = (value, fuzzy = !1) => fuzzy ? "boolean" == typeof value : !0 === value || !1 === value || isType$1(value, "Boolean");
var isBoolean$1 = isBoolean;
const isFunction = value => "function" == typeof value;
var isFunction$1 = isFunction;
const isNil = value => null == value;
var isNil$1 = isNil;
const isNull = value => null === value;
var isNull$1 = isNull;
const isValid = value => null != value;
var isValid$1 = isValid;
const isObject$1 = value => {
const type = typeof value;
return null !== value && "object" === type || "function" === type;
};
var isObject$2 = isObject$1;
const isObjectLike = value => "object" == typeof value && null !== value;
var isObjectLike$1 = isObjectLike;
const isPlainObject = function (value) {
if (!isObjectLike$1(value) || !isType$1(value, "Object")) return !1;
if (null === Object.getPrototypeOf(value)) return !0;
let proto = value;
for (; null !== Object.getPrototypeOf(proto);) proto = Object.getPrototypeOf(proto);
return Object.getPrototypeOf(value) === proto;
};
var isPlainObject$1 = isPlainObject;
const isUndefined = value => void 0 === value;
var isUndefined$1 = isUndefined;
const isString = (value, fuzzy = !1) => {
const type = typeof value;
return fuzzy ? "string" === type : "string" === type || isType$1(value, "String");
};
var isString$1 = isString;
const isArray = value => Array.isArray ? Array.isArray(value) : isType$1(value, "Array");
var isArray$1 = isArray;
const isArrayLike = function (value) {
return null !== value && "function" != typeof value && Number.isFinite(value.length);
};
var isArrayLike$1 = isArrayLike;
const isDate = value => isType$1(value, "Date");
var isDate$1 = isDate;
const isNumber = (value, fuzzy = !1) => {
const type = typeof value;
return fuzzy ? "number" === type : "number" === type || isType$1(value, "Number");
};
var isNumber$1 = isNumber;
const isNumeric = value => "string" == typeof value && !isNaN(Number(value)) && !isNaN(parseFloat(value));
var isNumeric$1 = isNumeric;
const isValidNumber = value => isNumber$1(value) && Number.isFinite(value);
var isValidNumber$1 = isValidNumber;
const isValidUrl = value => new RegExp(/^(http(s)?:\/\/)\w+[^\s]+(\.[^\s]+){1,}$/).test(value);
var isValidUrl$1 = isValidUrl;
const isRegExp = value => isType$1(value, "RegExp");
var isRegExp$1 = isRegExp;
const isBase64 = value => new RegExp(/^data:image\/(?:gif|png|jpeg|bmp|webp|svg\+xml)(?:;charset=utf-8)?;base64,(?:[A-Za-z0-9]|[+/])+={0,2}/g).test(value);
var isBase64$1 = isBase64;
const getType = value => ({}).toString.call(value).replace(/^\[object /, "").replace(/]$/, "");
var getType$1 = getType;
const objectProto = Object.prototype,
isPrototype = function (value) {
const Ctor = value && value.constructor;
return value === ("function" == typeof Ctor && Ctor.prototype || objectProto);
};
var isPrototype$1 = isPrototype;
const hasOwnProperty$2 = Object.prototype.hasOwnProperty;
function isEmpty(value) {
if (isNil$1(value)) return !0;
if (isArrayLike$1(value)) return !value.length;
const type = getType$1(value);
if ("Map" === type || "Set" === type) return !value.size;
if (isPrototype$1(value)) return !Object.keys(value).length;
for (const key in value) if (hasOwnProperty$2.call(value, key)) return !1;
return !0;
}
const get = (obj, path, defaultValue) => {
const paths = isString$1(path) ? path.split(".") : path;
for (let p = 0; p < paths.length; p++) obj = obj ? obj[paths[p]] : void 0;
return void 0 === obj ? defaultValue : obj;
};
var get$1 = get;
const hasOwnProperty$1 = Object.prototype.hasOwnProperty,
has = (object, key) => null != object && hasOwnProperty$1.call(object, key);
var has$1 = has;
function getRegExpFlags(re) {
let flags = "";
return re.global && (flags += "g"), re.ignoreCase && (flags += "i"), re.multiline && (flags += "m"), flags;
}
function clone$1(parent, circular = !1, depth = 0, prototype = void 0) {
const allParents = [],
allChildren = [];
return void 0 === circular && (circular = !0), void 0 === depth && (depth = 1 / 0), function _clone(parent, depth) {
if (null === parent) return null;
if (0 === depth) return parent;
let child;
if ("object" != typeof parent) return parent;
if (isArray$1(parent) ? child = [] : isRegExp$1(parent) ? (child = new RegExp(parent.source, getRegExpFlags(parent)), parent.lastIndex && (child.lastIndex = parent.lastIndex)) : child = isDate$1(parent) ? new Date(parent.getTime()) : void 0 === prototype ? Object.create(Object.getPrototypeOf(parent)) : Object.create(prototype), circular) {
const index = allParents.indexOf(parent);
if (-1 !== index) return allChildren[index];
allParents.push(parent), allChildren.push(child);
}
for (const i in parent) child[i] = _clone(parent[i], depth - 1);
return child;
}(parent, depth);
}
function cloneDeep(value, ignoreWhen, excludeKeys) {
let result;
if (!isValid$1(value) || "object" != typeof value || ignoreWhen && ignoreWhen(value)) return value;
const isArr = isArray$1(value),
length = value.length;
result = isArr ? new Array(length) : "object" == typeof value ? {} : isBoolean$1(value) || isNumber$1(value) || isString$1(value) ? value : isDate$1(value) ? new Date(+value) : void 0;
const props = isArr ? void 0 : Object.keys(Object(value));
let index = -1;
if (result) for (; ++index < (props || value).length;) {
const key = props ? props[index] : index,
subValue = value[key];
excludeKeys && excludeKeys.includes(key.toString()) ? result[key] = subValue : result[key] = cloneDeep(subValue, ignoreWhen, excludeKeys);
}
return result;
}
function baseMerge(target, source, shallowArray = !1, skipTargetArray = !1) {
if (source) {
if (target === source) return;
if (isValid$1(source) && "object" == typeof source) {
const iterable = Object(source),
props = [];
for (const key in iterable) props.push(key);
let {
length: length
} = props,
propIndex = -1;
for (; length--;) {
const key = props[++propIndex];
!isValid$1(iterable[key]) || "object" != typeof iterable[key] || skipTargetArray && isArray$1(target[key]) ? assignMergeValue(target, key, iterable[key]) : baseMergeDeep(target, source, key, shallowArray, skipTargetArray);
}
}
}
}
function baseMergeDeep(target, source, key, shallowArray = !1, skipTargetArray = !1) {
const objValue = target[key],
srcValue = source[key];
let newValue = source[key],
isCommon = !0;
if (isArray$1(srcValue)) {
if (shallowArray) newValue = [];else if (isArray$1(objValue)) newValue = objValue;else if (isArrayLike$1(objValue)) {
newValue = new Array(objValue.length);
let index = -1;
const length = objValue.length;
for (; ++index < length;) newValue[index] = objValue[index];
}
} else isPlainObject$1(srcValue) ? (newValue = null != objValue ? objValue : {}, "function" != typeof objValue && "object" == typeof objValue || (newValue = {})) : isCommon = !1;
isCommon && baseMerge(newValue, srcValue, shallowArray, skipTargetArray), assignMergeValue(target, key, newValue);
}
function assignMergeValue(target, key, value) {
(void 0 !== value && !eq(target[key], value) || void 0 === value && !(key in target)) && (target[key] = value);
}
function eq(value, other) {
return value === other || Number.isNaN(value) && Number.isNaN(other);
}
function merge$1(target, ...sources) {
let sourceIndex = -1;
const length = sources.length;
for (; ++sourceIndex < length;) {
baseMerge(target, sources[sourceIndex], !0);
}
return target;
}
const hasOwnProperty = Object.prototype.hasOwnProperty;
function pick(obj, keys) {
if (!obj || !isPlainObject$1(obj)) return obj;
const result = {};
return keys.forEach(k => {
hasOwnProperty.call(obj, k) && (result[k] = obj[k]);
}), result;
}
function pickWithout(obj, keys) {
if (!obj || !isPlainObject$1(obj)) return obj;
const result = {};
return Object.keys(obj).forEach(k => {
const v = obj[k];
let match = !1;
keys.forEach(itKey => {
(isString$1(itKey) && itKey === k || itKey instanceof RegExp && k.match(itKey)) && (match = !0);
}), match || (result[k] = v);
}), result;
}
function objToString(obj) {
return Object.prototype.toString.call(obj);
}
function objectKeys(obj) {
return Object.keys(obj);
}
function isEqual(a, b, options) {
if (a === b) return !0;
if (typeof a != typeof b) return !1;
if (null == a || null == b) return !1;
if (Number.isNaN(a) && Number.isNaN(b)) return !0;
if (objToString(a) !== objToString(b)) return !1;
if (isFunction$1(a)) return !!(null == options ? void 0 : options.skipFunction);
if ("object" != typeof a) return !1;
if (isArray$1(a)) {
if (a.length !== b.length) return !1;
for (let i = a.length - 1; i >= 0; i--) if (!isEqual(a[i], b[i], options)) return !1;
return !0;
}
if (!isPlainObject$1(a)) return !1;
const ka = objectKeys(a),
kb = objectKeys(b);
if (ka.length !== kb.length) return !1;
ka.sort(), kb.sort();
for (let i = ka.length - 1; i >= 0; i--) if (ka[i] != kb[i]) return !1;
for (let i = ka.length - 1; i >= 0; i--) {
const key = ka[i];
if (!isEqual(a[key], b[key], options)) return !1;
}
return !0;
}
function is(x, y) {
return x === y ? 0 !== x || 0 !== y || 1 / x == 1 / y : x != x && y != y;
}
function length$1(obj) {
return isArray$1(obj) ? obj.length : isObject$2(obj) ? Object.keys(obj).length : 0;
}
function isShallowEqual(objA, objB) {
if (is(objA, objB)) return !0;
if ("object" != typeof objA || null === objA || "object" != typeof objB || null === objB) return !1;
if (isArray$1(objA) !== isArray$1(objB)) return !1;
if (length$1(objA) !== length$1(objB)) return !1;
let ret = !0;
return Object.keys(objA).forEach(k => !!is(objA[k], objB[k]) || (ret = !1, ret)), ret;
}
function keys(obj) {
if (!obj) return [];
if (Object.keys) return Object.keys(obj);
const keyList = [];
for (const key in obj) obj.hasOwnProperty(key) && keyList.push(key);
return keyList;
}
function defaults(target, source, overlay) {
const keysArr = keys(source);
for (let i = 0; i < keysArr.length; i++) {
const key = keysArr[i];
(overlay ? null != source[key] : null == target[key]) && (target[key] = source[key]);
}
return target;
}
function mixin(target, source, override = !0) {
if (target = "prototype" in target ? target.prototype : target, source = "prototype" in source ? source.prototype : source, Object.getOwnPropertyNames) {
const keyList = Object.getOwnPropertyNames(source);
for (let i = 0; i < keyList.length; i++) {
const key = keyList[i];
"constructor" !== key && (override ? null != source[key] : null == target[key]) && (target[key] = source[key]);
}
} else defaults(target, source, override);
}
function array(arr) {
return isValid$1(arr) ? isArray$1(arr) ? arr : [arr] : [];
}
function last(val) {
if (isArrayLike$1(val)) {
return val[val.length - 1];
}
}
const span = arr => arr.length <= 1 ? 0 : last(arr) - arr[0];
const maxInArray = (arr, compareFn) => {
var _a;
if (0 === arr.length) return;
let max = arr[0];
for (let i = 1; i < arr.length; i++) {
const value = arr[i];
(null !== (_a = null == compareFn ? void 0 : compareFn(value, max)) && void 0 !== _a ? _a : value - max) > 0 && (max = value);
}
return max;
};
const minInArray = (arr, compareFn) => {
var _a;
if (0 === arr.length) return;
let min = arr[0];
for (let i = 1; i < arr.length; i++) {
const value = arr[i];
(null !== (_a = null == compareFn ? void 0 : compareFn(value, min)) && void 0 !== _a ? _a : value - min) < 0 && (min = value);
}
return min;
};
function arrayEqual(a, b) {
if (!isArray$1(a) || !isArray$1(b)) return !1;
if (a.length !== b.length) return !1;
for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return !1;
return !0;
}
function uniqArray(arr) {
return arr && isArray$1(arr) ? Array.from(new Set(array(arr))) : arr;
}
function shuffleArray(arr, random = Math.random) {
let j,
x,
i = arr.length;
for (; i;) j = Math.floor(random() * i), x = arr[--i], arr[i] = arr[j], arr[j] = x;
return arr;
}
function flattenArray(arr) {
if (!isArray$1(arr)) return [arr];
const result = [];
for (const value of arr) result.push(...flattenArray(value));
return result;
}
function range(start, stop, step) {
isValid$1(stop) || (stop = start, start = 0), isValid$1(step) || (step = 1);
let i = -1;
const n = 0 | Math.max(0, Math.ceil((stop - start) / step)),
range = new Array(n);
for (; ++i < n;) range[i] = start + i * step;
return range;
}
function ascending$1(a, b) {
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
}
function toNumber(a) {
return Number(a);
}
function quantileSorted(values, percent, valueof = toNumber) {
const n = values.length;
if (!n) return;
if (percent <= 0 || n < 2) return valueof(values[0], 0, values);
if (percent >= 1) return valueof(values[n - 1], n - 1, values);
const i = (n - 1) * percent,
i0 = Math.floor(i),
value0 = valueof(values[i0], i0, values);
return value0 + (valueof(values[i0 + 1], i0 + 1, values) - value0) * (i - i0);
}
const hasConsole = "undefined" != typeof console;
function log$2(method, level, input) {
const args = [level].concat([].slice.call(input));
hasConsole && console[method].apply(console, args);
}
exports.LoggerLevel = void 0;
!function (LoggerLevel) {
LoggerLevel[LoggerLevel.None = 0] = "None", LoggerLevel[LoggerLevel.Error = 1] = "Error", LoggerLevel[LoggerLevel.Warn = 2] = "Warn", LoggerLevel[LoggerLevel.Info = 3] = "Info", LoggerLevel[LoggerLevel.Debug = 4] = "Debug";
}(exports.LoggerLevel || (exports.LoggerLevel = {}));
class Logger {
static getInstance(level, method) {
return Logger._instance && isNumber$1(level) ? Logger._instance.level(level) : Logger._instance || (Logger._instance = new Logger(level, method)), Logger._instance;
}
static setInstance(logger) {
return Logger._instance = logger;
}
static setInstanceLevel(level) {
Logger._instance ? Logger._instance.level(level) : Logger._instance = new Logger(level);
}
static clearInstance() {
Logger._instance = null;
}
constructor(level = exports.LoggerLevel.None, method) {
this._onErrorHandler = [], this._level = level, this._method = method;
}
addErrorHandler(handler) {
this._onErrorHandler.find(h => h === handler) || this._onErrorHandler.push(handler);
}
removeErrorHandler(handler) {
const index = this._onErrorHandler.findIndex(h => h === handler);
index < 0 || this._onErrorHandler.splice(index, 1);
}
callErrorHandler(...args) {
this._onErrorHandler.forEach(h => h(...args));
}
canLogInfo() {
return this._level >= exports.LoggerLevel.Info;
}
canLogDebug() {
return this._level >= exports.LoggerLevel.Debug;
}
canLogError() {
return this._level >= exports.LoggerLevel.Error;
}
canLogWarn() {
return this._level >= exports.LoggerLevel.Warn;
}
level(levelValue) {
return arguments.length ? (this._level = +levelValue, this) : this._level;
}
error(...args) {
var _a;
return this._level >= exports.LoggerLevel.Error && (this._onErrorHandler.length ? this.callErrorHandler(...args) : log$2(null !== (_a = this._method) && void 0 !== _a ? _a : "error", "ERROR", args)), this;
}
warn(...args) {
return this._level >= exports.LoggerLevel.Warn && log$2(this._method || "warn", "WARN", args), this;
}
info(...args) {
return this._level >= exports.LoggerLevel.Info && log$2(this._method || "log", "INFO", args), this;
}
debug(...args) {
return this._level >= exports.LoggerLevel.Debug && log$2(this._method || "log", "DEBUG", args), this;
}
}
Logger._instance = null;
function bisect(a, x, lo = 0, hi) {
for (isNil$1(hi) && (hi = a.length); lo < hi;) {
const mid = lo + hi >>> 1;
ascending$1(a[mid], x) > 0 ? hi = mid : lo = mid + 1;
}
return lo;
}
function findZeroOfFunction(f, a, b, parameters) {
var _a, _b;
const maxIterations = null !== (_a = null == parameters ? void 0 : parameters.maxIterations) && void 0 !== _a ? _a : 100,
tolerance = null !== (_b = null == parameters ? void 0 : parameters.tolerance) && void 0 !== _b ? _b : 1e-10,
fA = f(a),
fB = f(b);
let delta = b - a;
if (fA * fB > 0) {
return Logger.getInstance().error("Initial bisect points must have opposite signs"), NaN;
}
if (0 === fA) return a;
if (0 === fB) return b;
for (let i = 0; i < maxIterations; ++i) {
delta /= 2;
const mid = a + delta,
fMid = f(mid);
if (fMid * fA >= 0 && (a = mid), Math.abs(delta) < tolerance || 0 === fMid) return mid;
}
return a + delta;
}
const binaryFuzzySearch = (arr, compareFn) => binaryFuzzySearchInNumberRange(0, arr.length, value => compareFn(arr[value]));
const binaryFuzzySearchInNumberRange = (x1, x2, compareFn) => {
let left = x1,
right = x2;
for (; left < right;) {
const mid = Math.floor((left + right) / 2);
compareFn(mid) >= 0 ? right = mid : left = mid + 1;
}
return left;
};
function variance$1(values, valueof) {
let delta,
count = 0,
mean = 0,
sum = 0;
if (void 0 === valueof) for (let value of values) null != value && (value = +value) >= value && (delta = value - mean, mean += delta / ++count, sum += delta * (value - mean));else {
let index = -1;
for (let value of values) null != (value = valueof(value, ++index, values)) && (value = +value) >= value && (delta = value - mean, mean += delta / ++count, sum += delta * (value - mean));
}
return count > 1 ? sum / (count - 1) : 0;
}
function deviation(values, valueof) {
const v = variance$1(values, valueof);
return v ? Math.sqrt(v) : v;
}
const median$1 = (values, isSorted) => {
let sorted = values;
return !0 !== isSorted && (sorted = values.sort(ascending$1)), quantileSorted(sorted, .5);
};
const e10$2 = Math.sqrt(50),
e5$2 = Math.sqrt(10),
e2$2 = Math.sqrt(2);
function tickStep(start, stop, count) {
const step0 = Math.abs(stop - start) / Math.max(0, count);
let step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10));
const error = step0 / step1;
return error >= e10$2 ? step1 *= 10 : error >= e5$2 ? step1 *= 5 : error >= e2$2 && (step1 *= 2), stop < start ? -step1 : step1;
}
const DEFAULT_ABSOLUTE_TOLERATE = 1e-10,
DEFAULT_RELATIVE_TOLERATE = 1e-10;
function isNumberClose(a, b, relTol = DEFAULT_RELATIVE_TOLERATE, absTol = DEFAULT_ABSOLUTE_TOLERATE) {
const abs = absTol,
rel = relTol * Math.max(a, b);
return Math.abs(a - b) <= Math.max(abs, rel);
}
function isGreater(a, b, relTol, absTol) {
return a > b && !isNumberClose(a, b, relTol, absTol);
}
function isLess(a, b, relTol, absTol) {
return a < b && !isNumberClose(a, b, relTol, absTol);
}
const constant = value => isFunction$1(value) ? value : () => value;
var constant$1 = constant;
const memoize = func => {
let lastArgs = null,
lastResult = null;
return (...args) => (lastArgs && args.every((val, i) => val === lastArgs[i]) || (lastArgs = args, lastResult = func(...args)), lastResult);
};
const repeat = (str, repeatCount = 0) => {
let s = "",
i = repeatCount - 1;
for (; i >= 0;) s = `${s}${str}`, i -= 1;
return s;
},
pad$1 = (str, length, padChar = " ", align = "right") => {
const c = padChar,
s = str + "",
n = length - s.length;
return n <= 0 ? s : "left" === align ? repeat(c, n) + s : "center" === align ? repeat(c, Math.floor(n / 2)) + s + repeat(c, Math.ceil(n / 2)) : s + repeat(c, n);
};
var pad$2 = pad$1;
const truncate = (str, length, align = "right", ellipsis) => {
const e = isNil$1(ellipsis) ? "…" : ellipsis,
s = str + "",
n = s.length,
l = Math.max(0, length - e.length);
return n <= length ? s : "left" === align ? e + s.slice(n - l) : "center" === align ? s.slice(0, Math.ceil(l / 2)) + e + s.slice(n - Math.floor(l / 2)) : s.slice(0, l) + e;
};
var truncate$1 = truncate;
const uuid = (len, radix) => {
const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),
uuid = [];
let i;
if (radix = radix || chars.length, len) for (i = 0; i < len; i++) uuid[i] = chars[0 | Math.random() * radix];else {
let r;
for (uuid[8] = uuid[13] = uuid[18] = uuid[23] = "-", uuid[14] = "4", i = 0; i < 36; i++) uuid[i] || (r = 0 | 16 * Math.random(), uuid[i] = chars[19 === i ? 3 & r | 8 : r]);
}
return uuid.join("");
};
var uuid$1 = uuid;
const clamp = function (input, min, max) {
return input < min ? min : input > max ? max : input;
};
var clamp$1 = clamp;
const clampRange = (range, min, max) => {
let [lowValue, highValue] = range;
highValue < lowValue && (lowValue = range[1], highValue = range[0]);
const span = highValue - lowValue;
return span >= max - min ? [min, max] : (lowValue = Math.min(Math.max(lowValue, min), max - span), [lowValue, lowValue + span]);
};
var clampRange$1 = clampRange;
function clamper(a, b) {
let t;
return a > b && (t = a, a = b, b = t), x => Math.max(a, Math.min(b, x));
}
let hasRaf = !1;
try {
hasRaf = "function" == typeof requestAnimationFrame && "function" == typeof cancelAnimationFrame;
} catch (err) {
hasRaf = !1;
}
function debounce(func, wait, options) {
let lastArgs,
lastThis,
maxWait,
result,
timerId,
lastCallTime,
lastInvokeTime = 0,
leading = !1,
maxing = !1,
trailing = !0;
const useRAF = !wait && 0 !== wait && hasRaf;
if ("function" != typeof func) throw new TypeError("Expected a function");
function invokeFunc(time) {
const args = lastArgs,
thisArg = lastThis;
return lastArgs = lastThis = void 0, lastInvokeTime = time, result = func.apply(thisArg, args), result;
}
function startTimer(pendingFunc, wait) {
return useRAF ? (cancelAnimationFrame(timerId), requestAnimationFrame(pendingFunc)) : setTimeout(pendingFunc, wait);
}
function shouldInvoke(time) {
const timeSinceLastCall = time - lastCallTime;
return void 0 === lastCallTime || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && time - lastInvokeTime >= maxWait;
}
function timerExpired() {
const time = Date.now();
if (shouldInvoke(time)) return trailingEdge(time);
timerId = startTimer(timerExpired, function (time) {
const timeSinceLastInvoke = time - lastInvokeTime,
timeWaiting = wait - (time - lastCallTime);
return maxing ? Math.min(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
}(time));
}
function trailingEdge(time) {
return timerId = void 0, trailing && lastArgs ? invokeFunc(time) : (lastArgs = lastThis = void 0, result);
}
function debounced(...args) {
const time = Date.now(),
isInvoking = shouldInvoke(time);
if (lastArgs = args, lastThis = this, lastCallTime = time, isInvoking) {
if (void 0 === timerId) return function (time) {
return lastInvokeTime = time, timerId = startTimer(timerExpired, wait), leading ? invokeFunc(time) : result;
}(lastCallTime);
if (maxing) return timerId = startTimer(timerExpired, wait), invokeFunc(lastCallTime);
}
return void 0 === timerId && (timerId = startTimer(timerExpired, wait)), result;
}
return wait = +wait || 0, isObject$2(options) && (leading = !!options.leading, maxing = "maxWait" in options, maxing && (maxWait = Math.max(isValidNumber$1(options.maxWait) ? options.maxWait : 0, wait)), trailing = "trailing" in options ? !!options.trailing : trailing), debounced.cancel = function () {
void 0 !== timerId && function (id) {
if (useRAF) return cancelAnimationFrame(id);
clearTimeout(id);
}(timerId), lastInvokeTime = 0, lastArgs = lastCallTime = lastThis = timerId = void 0;
}, debounced.flush = function () {
return void 0 === timerId ? result : trailingEdge(Date.now());
}, debounced.pending = function () {
return void 0 !== timerId;
}, debounced;
}
hasRaf = !1;
function throttle(func, wait, options) {
let leading = !0,
trailing = !0;
if ("function" != typeof func) throw new TypeError("Expected a function");
return isObject$2(options) && (leading = "leading" in options ? !!options.leading : leading, trailing = "trailing" in options ? !!options.trailing : trailing), debounce(func, wait, {
leading: leading,
trailing: trailing,
maxWait: wait
});
}
function interpolateNumber$1(a, b) {
return t => a * (1 - t) + b * t;
}
function interpolateNumberRound(a, b) {
return function (t) {
return Math.round(a * (1 - t) + b * t);
};
}
function interpolateDate(a, b) {
const aVal = a.valueOf(),
bVal = b.valueOf(),
d = new Date();
return t => (d.setTime(aVal * (1 - t) + bVal * t), d);
}
const reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,
reB = new RegExp(reA.source, "g");
function zero$1(b) {
return function () {
return b;
};
}
function one(b) {
return function (t) {
return b(t) + "";
};
}
function interpolateString(a, b) {
let am,
bm,
bs,
bi = reA.lastIndex = reB.lastIndex = 0,
i = -1;
const s = [],
q = [];
for (a += "", b += ""; (am = reA.exec(a)) && (bm = reB.exec(b));) (bs = bm.index) > bi && (bs = b.slice(bi, bs), s[i] ? s[i] += bs : s[++i] = bs), (am = am[0]) === (bm = bm[0]) ? s[i] ? s[i] += bm : s[++i] = bm : (s[++i] = null, q.push({
i: i,
x: interpolateNumber$1(am, bm)
})), bi = reB.lastIndex;
return bi < b.length && (bs = b.slice(bi), s[i] ? s[i] += bs : s[++i] = bs), s.length < 2 ? q[0] ? one(q[0].x) : zero$1(b) : (b = q.length, function (t) {
for (let o, i = 0; i < b; ++i) s[(o = q[i]).i] = o.x(t);
return s.join("");
});
}
const TIME_REG = /^(?:(\d{4})(?:[-\/](\d{1,2})(?:[-\/](\d{1,2})(?:[T ](\d{1,2})(?::(\d{1,2})(?::(\d{1,2})(?:[.,](\d+))?)?)?(Z|[\+\-]\d\d:?\d\d)?)?)?)?)?$/;
function toDate(val) {
if (val instanceof Date) return val;
if (isString$1(val)) {
const match = TIME_REG.exec(val);
if (!match) return new Date(NaN);
if (!match[8]) return new Date(+match[1], +(match[2] || 1) - 1, +match[3] || 1, +match[4] || 0, +(match[5] || 0), +match[6] || 0, match[7] ? +match[7].substring(0, 3) : 0);
let hour = +match[4] || 0;
return "Z" !== match[8].toUpperCase() && (hour -= +match[8].slice(0, 3)), new Date(Date.UTC(+match[1], +(match[2] || 1) - 1, +match[3] || 1, hour, +(match[5] || 0), +match[6] || 0, match[7] ? +match[7].substring(0, 3) : 0));
}
return isNil$1(val) ? new Date(NaN) : new Date(Math.round(val));
}
function toValidNumber$1(v) {
if (isValidNumber$1(v)) return v;
const value = +v;
return isValidNumber$1(value) ? value : 0;
}
const lowerFirst = function (str) {
return str.charAt(0).toLowerCase() + str.substring(1);
};
var lowerFirst$1 = lowerFirst;
const upperFirst = function (str) {
return str.charAt(0).toUpperCase() + str.substring(1);
};
var upperFirst$1 = upperFirst;
function substitute(str, o) {
return str && o ? str.replace(/\\?\{([^{}]+)\}/g, (match, name) => "\\" === match.charAt(0) ? match.slice(1) : void 0 === o[name] ? "" : o[name]) : str;
}
function seedRandom(seed) {
return parseFloat("0." + Math.sin(seed).toString().substring(6));
}
const a = 1664525,
c$1 = 1013904223,
m$2 = 4294967296;
function randomLCG(initS = 1) {
let s = initS;
return () => (s = (a * s + c$1) % m$2) / m$2;
}
const fakeRandom = () => {
let i = -1;
const arr = [0, .1, .2, .3, .4, .5, .6, .7, .8, .9];
return () => (i = (i + 1) % arr.length, arr[i]);
};
const getter = path => obj => get$1(obj, path);
const fieldSingle = (fieldStr, opt = {}) => {
if (isFunction$1(fieldStr)) return fieldStr;
const path = [fieldStr];
return (opt && opt.get || getter)(path);
};
const field$2 = (fieldStr, opt = {}) => {
if (isArray$1(fieldStr)) {
const funcs = fieldStr.map(entry => fieldSingle(entry, opt));
return datum => funcs.map(func => func(datum));
}
return fieldSingle(fieldStr, opt);
};
const simpleField = option => option ? "string" == typeof option || "number" == typeof option ? () => option : isFunction$1(option) ? option : datum => datum[option.field] : null;
const toPercent = (percent, total) => isNil$1(percent) ? total : isString$1(percent) ? total * parseFloat(percent) / 100 : percent;
const zero = _ => 0;
const extent$2 = (array, func) => {
const valueGetter = isFunction$1(func) ? func : val => val;
let min, max;
if (array && array.length) {
const n = array.length;
for (let i = 0; i < n; i += 1) {
let value = valueGetter(array[i]);
isNil$1(value) || !isNumber$1(value = +value) || Number.isNaN(value) || (isNil$1(min) ? (min = value, max = value) : (min = Math.min(min, value), max = Math.max(max, value)));
}
return [min, max];
}
return [min, max];
};
function invNorm(p) {
if (p <= 0 || p >= 1) return 0;
const c1 = -.00778489400243029,
c2 = -.322396458041136,
c3 = -2.40075827716184,
c4 = -2.54973253934373,
c5 = 4.37466414146497,
c6 = 2.93816398269878,
d1 = .00778469570904146,
d2 = .32246712907004,
d3 = 2.445134137143,
d4 = 3.75440866190742;
let q, r;
return p < .02425 ? (q = Math.sqrt(-2 * Math.log(p)), (((((c1 * q + c2) * q + c3) * q + c4) * q + c5) * q + c6) / ((((d1 * q + d2) * q + d3) * q + d4) * q + 1)) : p <= .97575 ? (q = p - .5, r = q * q, (((((-39.6968302866538 * r + 220.946098424521) * r - 275.928510446969) * r + 138.357751867269) * r - 30.6647980661472) * r + 2.50662827745924) * q / (((((-54.4760987982241 * r + 161.585836858041) * r - 155.698979859887) * r + 66.8013118877197) * r - 13.2806815528857) * r + 1)) : (q = Math.sqrt(-2 * Math.log(1 - p)), -(((((c1 * q + c2) * q + c3) * q + c4) * q + c5) * q + c6) / ((((d1 * q + d2) * q + d3) * q + d4) * q + 1));
}
function computeLinearCIComponents(data, x, y, predict) {
let min = 1 / 0,
max = -1 / 0,
n = 0,
sumX = 0;
for (let i = 0; i < data.length; i++) {
const d = data[i];
let dx = x(d),
dy = y(d);
!isNil$1(dx) && (dx = +dx) >= dx && !isNil$1(dy) && (dy = +dy) >= dy && (dx < min && (min = dx), dx > max && (max = dx), n++, sumX += dx);
}
if (0 === n) return {
min: min,
max: max,
n: n,
X: 0,
SSE: 0,
Sx