From ddde62b71fbab0142422d5f818a152b0045b48b7 Mon Sep 17 00:00:00 2001 From: SmallRuralDog <296404875@qq.com> Date: Mon, 20 Apr 2020 13:28:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=84=E4=BB=B6=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E7=BB=93=E6=9E=84=EF=BC=8C=E6=AD=A4=E6=AC=A1=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E5=BD=B1=E5=93=8D=E8=BE=83=E5=A4=A7=EF=BC=8C=E8=AF=B7?= =?UTF-8?q?=E5=B0=BD=E5=BF=AB=E6=9B=B4=E6=94=B9=E6=9C=89=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E7=BB=84=E4=BB=B6=E5=BC=95=E5=85=A5=EF=BC=8C=E8=80=81?= =?UTF-8?q?=E7=9A=84=E7=BB=84=E4=BB=B6=E5=B0=86=E4=BC=9A=E5=9C=A8=E5=90=8E?= =?UTF-8?q?=E9=9D=A2=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/0.js | 59692 +-------------------------- public/10.js | 495 +- public/11.js | 4688 +-- public/12.js | 141 +- public/13.js | 141 +- public/4.js | 141 +- public/5.js | 141 +- public/6.js | 141 +- public/7.js | 147 +- public/8.js | 163 +- public/9.js | 160 +- public/app.js | 37718 +---------------- public/manifest.js | 224 +- public/mix-manifest.json | 6 +- public/vendor.js | 80131 +------------------------------------ 15 files changed, 17 insertions(+), 184112 deletions(-) diff --git a/public/0.js b/public/0.js index 253c672..737e0c9 100644 --- a/public/0.js +++ b/public/0.js @@ -1,59691 +1 @@ -(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],{ - -/***/ "./node_modules/@antv/color-util/esm/index.js": -/*!****************************************************!*\ - !*** ./node_modules/@antv/color-util/esm/index.js ***! - \****************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); - -var RGB_REG = /rgba?\(([\s.,0-9]+)\)/; -var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i; -var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i; -var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/gi; -var isGradientColor = function (val) { return /^[r,R,L,l]{1}[\s]*\(/.test(val); }; -// 创建辅助 tag 取颜色 -var createTmp = function () { - var i = document.createElement('i'); - i.title = 'Web Colour Picker'; - i.style.display = 'none'; - document.body.appendChild(i); - return i; -}; -// 获取颜色之间的插值 -var getValue = function (start, end, percent, index) { - return start[index] + (end[index] - start[index]) * percent; -}; -// 数组转换成颜色 -function arr2rgb(arr) { - return "#" + toHex(arr[0]) + toHex(arr[1]) + toHex(arr[2]); -} -// rgb 颜色转换成数组 -var rgb2arr = function (str) { - return [ - parseInt(str.substr(1, 2), 16), - parseInt(str.substr(3, 2), 16), - parseInt(str.substr(5, 2), 16), - ]; -}; -// 将数值从 0-255 转换成16进制字符串 -var toHex = function (value) { - var x16Value = Math.round(value).toString(16); - return x16Value.length === 1 ? "0" + x16Value : x16Value; -}; -// 计算颜色 -var calColor = function (points, percent) { - var fixedPercent = isNaN(Number(percent)) || percent < 0 ? 0 : - percent > 1 ? 1 : - Number(percent); - var steps = points.length - 1; - var step = Math.floor(steps * fixedPercent); - var left = steps * fixedPercent - step; - var start = points[step]; - var end = step === steps ? start : points[step + 1]; - return arr2rgb([ - getValue(start, end, left, 0), - getValue(start, end, left, 1), - getValue(start, end, left, 2), - ]); -}; -// 用于给 toRGB 的缓存(使用 memoize 方法替换) -// const colorCache = {}; -var iEl; -/** - * 将颜色转换到 rgb 的格式 - * @param {color} color 颜色 - * @return 将颜色转换到 '#ffffff' 的格式 - */ -var toRGB = function (color) { - // 如果已经是 rgb的格式 - if (color[0] === '#' && color.length === 7) { - return color; - } - if (!iEl) { - // 防止防止在页头报错 - iEl = createTmp(); - } - iEl.style.color = color; - var rst = document.defaultView.getComputedStyle(iEl, '').getPropertyValue('color'); - var matches = RGB_REG.exec(rst); - var cArray = matches[1].split(/\s*,\s*/).map(function (s) { return Number(s); }); - rst = arr2rgb(cArray); - return rst; -}; -/** - * 获取渐变函数 - * @param colors 多个颜色 - * @return 颜色值 - */ -var gradient = function (colors) { - var colorArray = Object(_antv_util__WEBPACK_IMPORTED_MODULE_0__["isString"])(colors) ? colors.split('-') : colors; - var points = Object(_antv_util__WEBPACK_IMPORTED_MODULE_0__["map"])(colorArray, function (color) { - return rgb2arr(color.indexOf('#') === -1 ? toRGB(color) : color); - }); - // 返回一个函数 - return function (percent) { - return calColor(points, percent); - }; -}; -var toCSSGradient = function (gradientColor) { - if (isGradientColor(gradientColor)) { - var cssColor_1; - var steps = void 0; - if (gradientColor[0] === 'l') { - // 线性渐变 - var arr = regexLG.exec(gradientColor); - var angle = +arr[1] + 90; // css 和 g 的渐变起始角度不同 - steps = arr[2]; - cssColor_1 = "linear-gradient(" + angle + "deg, "; - } - else if (gradientColor[0] === 'r') { - // 径向渐变 - cssColor_1 = 'radial-gradient('; - var arr = regexRG.exec(gradientColor); - steps = arr[4]; - } - var colorStops_1 = steps.match(regexColorStop); - Object(_antv_util__WEBPACK_IMPORTED_MODULE_0__["each"])(colorStops_1, function (item, index) { - var itemArr = item.split(':'); - cssColor_1 += itemArr[1] + " " + itemArr[0] * 100 + "%"; - if (index !== (colorStops_1.length - 1)) { - cssColor_1 += ', '; - } - }); - cssColor_1 += ')'; - return cssColor_1; - } - return gradientColor; -}; -/* harmony default export */ __webpack_exports__["default"] = ({ - rgb2arr: rgb2arr, - gradient: gradient, - toRGB: Object(_antv_util__WEBPACK_IMPORTED_MODULE_0__["memoize"])(toRGB), - toCSSGradient: toCSSGradient, -}); -//# sourceMappingURL=index.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/abstract/component.js": -/*!****************************************************************!*\ - !*** ./node_modules/@antv/component/esm/abstract/component.js ***! - \****************************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _antv_g_base__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @antv/g-base */ "./node_modules/@antv/g-base/esm/index.js"); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); - - - -var LOCATION_FIELD_MAP = { - none: [], - point: ['x', 'y'], - region: ['start', 'end'], - points: ['points'], - circle: ['center', 'radius', 'startAngle', 'endAngle'], -}; -var Component = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Component, _super); - function Component(cfg) { - var _this = _super.call(this, cfg) || this; - _this.initCfg(); - return _this; - } - /** - * @protected - * 默认的配置项 - * @returns {object} 默认的配置项 - */ - Component.prototype.getDefaultCfg = function () { - return { - id: '', - name: '', - type: '', - locationType: 'none', - offsetX: 0, - offsetY: 0, - animate: false, - capture: true, - updateAutoRender: false, - animateOption: { - appear: null, - update: { - duration: 400, - easing: 'easeQuadInOut', - }, - enter: { - duration: 400, - easing: 'easeQuadInOut', - }, - leave: { - duration: 350, - easing: 'easeQuadIn', - }, - }, - events: null, - defaultCfg: {}, - visible: true, - }; - }; - /** - * 清理组件的内容,一般配合 render 使用 - * @example - * axis.clear(); - * axis.render(); - */ - Component.prototype.clear = function () { }; - /** - * 更新组件 - * @param {object} cfg 更新属性 - */ - Component.prototype.update = function (cfg) { - var _this = this; - var defaultCfg = this.get('defaultCfg'); - Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["each"])(cfg, function (value, name) { - var originCfg = _this.get(name); - var newCfg = value; - if (originCfg !== value) { - // 判断两者是否相等,主要是进行 null 的判定 - if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["isObject"])(value) && defaultCfg[name]) { - // 新设置的属性与默认值进行合并 - newCfg = Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["deepMix"])({}, defaultCfg[name], value); - } - _this.set(name, newCfg); - } - }); - // 更新时考虑显示、隐藏 - if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["hasKey"])(cfg, 'visible')) { - if (cfg.visible) { - this.show(); - } - else { - this.hide(); - } - } - // 更新时考虑capture - if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["hasKey"])(cfg, 'capture')) { - this.setCapture(cfg.capture); - } - }; - Component.prototype.getLayoutBBox = function () { - return this.getBBox(); // 默认返回 getBBox,不同的组件内部单独实现 - }; - Component.prototype.getLocationType = function () { - return this.get('locationType'); - }; - Component.prototype.getOffset = function () { - return { - offsetX: this.get('offsetX'), - offsetY: this.get('offsetY'), - }; - }; - // 默认使用 update - Component.prototype.setOffset = function (offsetX, offsetY) { - this.update({ - offsetX: offsetX, - offsetY: offsetY, - }); - }; - Component.prototype.setLocation = function (cfg) { - var location = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg); - this.update(location); - }; - // 实现 ILocation 接口的 getLocation - Component.prototype.getLocation = function () { - var _this = this; - var location = {}; - var locationType = this.get('locationType'); - var fields = LOCATION_FIELD_MAP[locationType]; - Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["each"])(fields, function (field) { - location[field] = _this.get(field); - }); - return location; - }; - Component.prototype.isList = function () { - return false; - }; - Component.prototype.isSlider = function () { - return false; - }; - /** - * @protected - * 初始化,用于具体的组件继承 - */ - Component.prototype.init = function () { }; - // 将组件默认的配置项设置合并到传入的配置项 - Component.prototype.initCfg = function () { - var _this = this; - var defaultCfg = this.get('defaultCfg'); - Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["each"])(defaultCfg, function (value, name) { - var cfg = _this.get(name); - if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["isObject"])(cfg)) { - var newCfg = Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["deepMix"])({}, value, cfg); - _this.set(name, newCfg); - } - }); - }; - return Component; -}(_antv_g_base__WEBPACK_IMPORTED_MODULE_1__["Base"])); -/* harmony default export */ __webpack_exports__["default"] = (Component); -//# sourceMappingURL=component.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/abstract/group-component.js": -/*!**********************************************************************!*\ - !*** ./node_modules/@antv/component/esm/abstract/group-component.js ***! - \**********************************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); -/* harmony import */ var _util_event__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/event */ "./node_modules/@antv/component/esm/util/event.js"); -/* harmony import */ var _util_matrix__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/matrix */ "./node_modules/@antv/component/esm/util/matrix.js"); -/* harmony import */ var _util_util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../util/util */ "./node_modules/@antv/component/esm/util/util.js"); -/* harmony import */ var _component__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./component */ "./node_modules/@antv/component/esm/abstract/component.js"); - - - - - - -var STATUS_UPDATE = 'update_status'; -var COPY_PROPERTIES = ['visible', 'tip', 'delegateObject']; // 更新对象时需要复制的属性 -var COPY_PROPERTIES_EXCLUDES = ['container', 'group', 'shapesMap', 'isRegister', 'isUpdating', 'destroyed']; // 更新子组件时排除的属性 -var GroupComponent = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(GroupComponent, _super); - function GroupComponent() { - return _super !== null && _super.apply(this, arguments) || this; - } - GroupComponent.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { container: null, - /** - * @private - * 缓存图形的 Map - */ - shapesMap: {}, group: null, capture: true, - /** - * @private 组件或者图形是否允许注册 - * @type {false} - */ - isRegister: false, - /** - * @private 是否正在更新 - * @type {false} - */ - isUpdating: false, - /** - * @private - * 是否初始状态,一旦 render,update 后,这个状态就变成 false, clear 后恢复 - */ - isInit: true }); - }; - GroupComponent.prototype.remove = function () { - this.clear(); - var group = this.get('group'); - group.remove(); - }; - GroupComponent.prototype.clear = function () { - var group = this.get('group'); - group.clear(); - this.set('shapesMap', {}); - this.clearOffScreenCache(); - this.set('isInit', true); - }; - GroupComponent.prototype.getChildComponentById = function (id) { - var group = this.getElementById(id); - var inst = group && group.get('component'); - return inst; - }; - GroupComponent.prototype.getElementById = function (id) { - return this.get('shapesMap')[id]; - }; - GroupComponent.prototype.getElementByLocalId = function (localId) { - var id = this.getElementId(localId); - return this.getElementById(id); - }; - GroupComponent.prototype.getElementsByName = function (name) { - var rst = []; - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(this.get('shapesMap'), function (elem) { - if (elem.get('name') === name) { - rst.push(elem); - } - }); - return rst; - }; - GroupComponent.prototype.getContainer = function () { - return this.get('container'); - }; - GroupComponent.prototype.update = function (cfg) { - // 设置正在更新的标记位 - // this.set('isUpdating', true); - _super.prototype.update.call(this, cfg); - // this.updateInner(); - // this.set('isUpdating', false); - this.offScreenRender(); - if (this.get('updateAutoRender')) { - this.render(); - } - }; - GroupComponent.prototype.render = function () { - var offScreenGroup = this.get('offScreenGroup'); - if (!offScreenGroup) { - offScreenGroup = this.offScreenRender(); - } - var group = this.get('group'); - this.updateElements(offScreenGroup, group); - this.deleteElements(); - this.applyOffset(); - if (!this.get('eventInitted')) { - this.initEvent(); - this.set('eventInitted', true); - } - this.set('isInit', false); - }; - GroupComponent.prototype.show = function () { - var group = this.get('group'); - group.show(); - this.set('visible', true); - }; - GroupComponent.prototype.hide = function () { - var group = this.get('group'); - group.hide(); - this.set('visible', false); - }; - GroupComponent.prototype.setCapture = function (capture) { - var group = this.get('group'); - group.set('capture', capture); - this.set('capture', capture); - }; - GroupComponent.prototype.destroy = function () { - this.removeEvent(); - this.remove(); - _super.prototype.destroy.call(this); - }; - GroupComponent.prototype.getBBox = function () { - return this.get('group').getCanvasBBox(); - }; - GroupComponent.prototype.getLayoutBBox = function () { - var group = this.get('group'); - // 防止被 clear 了,offScreenBBox 不存在 - var bbox = this.getInnerLayoutBBox(); - var matrix = group.getTotalMatrix(); - if (matrix) { - bbox = Object(_util_matrix__WEBPACK_IMPORTED_MODULE_3__["applyMatrix2BBox"])(matrix, bbox); - } - return bbox; // 默认返回 getBBox,不同的组件内部单独实现 - }; - // 复写 on, off, emit 透传到 group - GroupComponent.prototype.on = function (evt, callback, once) { - var group = this.get('group'); - group.on(evt, callback, once); - return this; - }; - GroupComponent.prototype.off = function (evt, callback) { - var group = this.get('group'); - group && group.off(evt, callback); - return this; - }; - GroupComponent.prototype.emit = function (eventName, eventObject) { - var group = this.get('group'); - group.emit(eventName, eventObject); - }; - GroupComponent.prototype.init = function () { - _super.prototype.init.call(this); - if (!this.get('group')) { - this.initGroup(); - } - this.offScreenRender(); // 绘制离屏 group - }; - // 获取组件内部布局占的包围盒 - GroupComponent.prototype.getInnerLayoutBBox = function () { - return this.get('offScreenBBox') || this.get('group').getBBox(); - }; - // 抛出委托对象 - GroupComponent.prototype.delegateEmit = function (eventName, eventObject) { - var group = this.get('group'); - eventObject.target = group; - group.emit(eventName, eventObject); - Object(_util_event__WEBPACK_IMPORTED_MODULE_2__["propagationDelegate"])(group, eventName, eventObject); - }; - // 创建离屏的 group ,不添加在 canvas 中 - GroupComponent.prototype.createOffScreenGroup = function () { - var group = this.get('group'); - var GroupClass = group.getGroupBase(); // 获取分组的构造函数 - var newGroup = new GroupClass({ - delegateObject: this.getDelegateObject(), - }); - return newGroup; - }; - // 应用 offset - GroupComponent.prototype.applyOffset = function () { - var offsetX = this.get('offsetX'); - var offsetY = this.get('offsetY'); - this.moveElementTo(this.get('group'), { - x: offsetX, - y: offsetY, - }); - }; - GroupComponent.prototype.initGroup = function () { - var container = this.get('container'); - this.set('group', container.addGroup({ - id: this.get('id'), - name: this.get('name'), - capture: this.get('capture'), - visible: this.get('visible'), - isComponent: true, - component: this, - delegateObject: this.getDelegateObject(), - })); - }; - // 离屏渲染 - GroupComponent.prototype.offScreenRender = function () { - this.clearOffScreenCache(); - var offScreenGroup = this.createOffScreenGroup(); - this.renderInner(offScreenGroup); - this.set('offScreenGroup', offScreenGroup); - // 包含包围盒的 bbox - this.set('offScreenBBox', Object(_util_util__WEBPACK_IMPORTED_MODULE_4__["getBBoxWithClip"])(offScreenGroup)); - return offScreenGroup; - }; - /** - * @protected - * 在组件上添加分组,主要解决 isReigeter 的问题 - * @param {IGroup} parent 父元素 - * @param {object} cfg 分组的配置项 - */ - GroupComponent.prototype.addGroup = function (parent, cfg) { - this.appendDelegateObject(parent, cfg); - var group = parent.addGroup(cfg); - if (this.get('isRegister')) { - this.registerElement(group); - } - return group; - }; - /** - * @protected - * 在组件上添加图形,主要解决 isReigeter 的问题 - * @param {IGroup} parent 父元素 - * @param {object} cfg 分组的配置项 - */ - GroupComponent.prototype.addShape = function (parent, cfg) { - this.appendDelegateObject(parent, cfg); - var shape = parent.addShape(cfg); - if (this.get('isRegister')) { - this.registerElement(shape); - } - return shape; - }; - /** - * 在组件上添加子组件 - * - * @param parent 父元素 - * @param cfg 子组件配置项 - */ - GroupComponent.prototype.addComponent = function (parent, cfg) { - var id = cfg.id, Ctor = cfg.component, restCfg = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__rest"])(cfg, ["id", "component"]); - // @ts-ignore - var inst = new Ctor(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, restCfg), { id: id, container: parent, updateAutoRender: this.get('updateAutoRender') })); - inst.init(); - inst.render(); - if (this.get('isRegister')) { - this.registerElement(inst.get('group')); - } - return inst; - }; - GroupComponent.prototype.initEvent = function () { }; - GroupComponent.prototype.removeEvent = function () { - var group = this.get('group'); - group.off(); - }; - GroupComponent.prototype.getElementId = function (localId) { - var id = this.get('id'); // 组件的 Id - var name = this.get('name'); // 组件的名称 - return id + "-" + name + "-" + localId; - }; - GroupComponent.prototype.registerElement = function (element) { - var id = element.get('id'); - this.get('shapesMap')[id] = element; - }; - GroupComponent.prototype.unregisterElement = function (element) { - var id = element.get('id'); - delete this.get('shapesMap')[id]; - }; - // 移动元素 - GroupComponent.prototype.moveElementTo = function (element, point) { - var matrix = Object(_util_matrix__WEBPACK_IMPORTED_MODULE_3__["getMatrixByTranslate"])(point); - element.attr('matrix', matrix); - }; - /** - * 图形元素新出现时的动画,默认图形从透明度 0 到当前透明度 - * @protected - * @param {string} elmentName 图形元素名称 - * @param {IElement} newElement 新的图形元素 - * @param {object} animateCfg 动画的配置项 - */ - GroupComponent.prototype.addAnimation = function (elmentName, newElement, animateCfg) { - // 缓存透明度 - var originOpacity = newElement.attr('opacity'); - if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["isNil"])(originOpacity)) { - originOpacity = 1; - } - newElement.attr('opacity', 0); - newElement.animate({ opacity: originOpacity }, animateCfg); - }; - /** - * 图形元素新出现时的动画,默认图形从透明度 0 到当前透明度 - * @protected - * @param {string} elmentName 图形元素名称 - * @param {IElement} originElement 要删除的图形元素 - * @param {object} animateCfg 动画的配置项 - */ - GroupComponent.prototype.removeAnimation = function (elementName, originElement, animateCfg) { - originElement.animate({ opacity: 0 }, animateCfg); - }; - /** - * 图形元素的更新动画 - * @param {string} elmentName 图形元素名称 - * @param {IElement} originElement 现有的图形元素 - * @param {object} newAttrs 新的图形元素 - * @param {object} animateCfg 动画的配置项 - */ - GroupComponent.prototype.updateAnimation = function (elementName, originElement, newAttrs, animateCfg) { - originElement.animate(newAttrs, animateCfg); - }; - // 更新组件的图形 - GroupComponent.prototype.updateElements = function (newGroup, originGroup) { - var _this = this; - var animate = this.get('animate'); - var animateOption = this.get('animateOption'); - var children = newGroup.getChildren().slice(0); // 创建一个新数组,防止添加到 originGroup 时, children 变动 - var preElement; // 前面已经匹配到的图形元素,用于 - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(children, function (element) { - var elementId = element.get('id'); - var originElement = _this.getElementById(elementId); - var elementName = element.get('name'); - if (originElement) { - if (element.get('isComponent')) { - // 嵌套子组件更新 - var childComponent = element.get('component'); - var origChildComponent = originElement.get('component'); - var newCfg = Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["pick"])(childComponent.cfg, Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["difference"])(Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["keys"])(childComponent.cfg), COPY_PROPERTIES_EXCLUDES)); - origChildComponent.update(newCfg); - originElement.set(STATUS_UPDATE, 'update'); - } - else { - var replaceAttrs = _this.getReplaceAttrs(originElement, element); - // 更新 - if (animate && animateOption.update) { - // 没有动画 - _this.updateAnimation(elementName, originElement, replaceAttrs, animateOption.update); - } - else { - // originElement.attrs = replaceAttrs; // 直接替换 - originElement.attr(replaceAttrs); - } - // 如果是分组,则继续执行 - if (element.isGroup()) { - _this.updateElements(element, originElement); - } - // 复制属性 - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(COPY_PROPERTIES, function (name) { - originElement.set(name, element.get(name)); - }); - Object(_util_util__WEBPACK_IMPORTED_MODULE_4__["updateClip"])(originElement, element); - preElement = originElement; - // 执行完更新后设置状态位为更新 - originElement.set(STATUS_UPDATE, 'update'); - } - } - else { - // 没有对应的图形,则插入当前图形 - originGroup.add(element); // 应该在 group 加个 insertAt 的方法 - var siblings = originGroup.getChildren(); // 兄弟节点 - siblings.splice(siblings.length - 1, 1); // 先从数组中移除,然后放到合适的位置 - if (preElement) { - // 前面已经有更新的图形或者插入的图形,则在这个图形后面插入 - var index = siblings.indexOf(preElement); - siblings.splice(index + 1, 0, element); // 在已经更新的图形元素后面插入 - } - else { - siblings.unshift(element); - } - _this.registerElement(element); // 注册节点 - element.set(STATUS_UPDATE, 'add'); // 执行完更新后设置状态位为添加 - if (element.get('isComponent')) { - // 直接新增子组件container属性,实例不变 - var childComponent = element.get('component'); - childComponent.set('container', originGroup); - } - else if (element.isGroup()) { - // 如果元素是新增加的元素,则遍历注册所有的子节点 - _this.registerNewGroup(element); - } - preElement = element; - if (animate) { - var animateCfg = _this.get('isInit') ? animateOption.appear : animateOption.enter; - if (animateCfg) { - _this.addAnimation(elementName, element, animateCfg); - } - } - } - }); - }; - GroupComponent.prototype.clearUpdateStatus = function (group) { - var children = group.getChildren(); - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(children, function (el) { - el.set(STATUS_UPDATE, null); // 清理掉更新状态 - }); - }; - // 清理离屏缓存 - GroupComponent.prototype.clearOffScreenCache = function () { - var offScreenGroup = this.get('offScreenGroup'); - if (offScreenGroup) { - // 销毁原先的离线 Group - offScreenGroup.destroy(); - } - this.set('offScreenGroup', null); - this.set('offScreenBBox', null); - }; - // private updateInner() { - // const group = this.get('group'); - // const newGroup = this.createOffScreenGroup(); - // this.renderInner(newGroup); - // this.applyOffset(); - // this.updateElements(newGroup, group); - // this.deleteElements(); - // newGroup.destroy(); // 销毁虚拟分组 - // } - // 获取发生委托时的对象,在事件中抛出 - GroupComponent.prototype.getDelegateObject = function () { - var _a; - var name = this.get('name'); - var delegateObject = (_a = {}, - _a[name] = this, - _a.component = this, - _a); - return delegateObject; - }; - // 附加委托信息,用于事件 - GroupComponent.prototype.appendDelegateObject = function (parent, cfg) { - var parentObject = parent.get('delegateObject'); - if (!cfg.delegateObject) { - cfg.delegateObject = {}; - } - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["mix"])(cfg.delegateObject, parentObject); // 将父元素上的委托信息复制到自身 - }; - // 获取需要替换的属性,如果原先图形元素存在,而新图形不存在,则设置 undefined - GroupComponent.prototype.getReplaceAttrs = function (originElement, newElement) { - var originAttrs = originElement.attr(); - var newAttrs = newElement.attr(); - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(originAttrs, function (v, k) { - if (newAttrs[k] === undefined) { - newAttrs[k] = undefined; - } - }); - return newAttrs; - }; - GroupComponent.prototype.registerNewGroup = function (group) { - var _this = this; - var children = group.getChildren(); - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(children, function (element) { - _this.registerElement(element); // 注册节点 - element.set(STATUS_UPDATE, 'add'); // 执行完更新后设置状态位为添加 - if (element.isGroup()) { - _this.registerNewGroup(element); - } - }); - }; - // 移除多余的元素 - GroupComponent.prototype.deleteElements = function () { - var _this = this; - var shapesMap = this.get('shapesMap'); - var deleteArray = []; - // 遍历获取需要删除的图形元素 - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(shapesMap, function (element, id) { - if (!element.get(STATUS_UPDATE) || element.destroyed) { - deleteArray.push([id, element]); - } - else { - element.set(STATUS_UPDATE, null); // 清理掉更新状态 - } - }); - var animate = this.get('animate'); - var animateOption = this.get('animateOption'); - // 删除图形元素 - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(deleteArray, function (item) { - var id = item[0], element = item[1]; - if (!element.destroyed) { - var elementName = element.get('name'); - if (animate && animateOption.leave) { - // 需要动画结束时移除图形 - var callbackAnimCfg = Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["mix"])({ - callback: function () { - _this.removeElement(element); - }, - }, animateOption.leave); - _this.removeAnimation(elementName, element, callbackAnimCfg); - } - else { - _this.removeElement(element); - } - } - delete shapesMap[id]; // 从缓存中移除 - }); - }; - GroupComponent.prototype.removeElement = function (element) { - if (element.get('isGroup')) { - var component = element.get('component'); - if (component) { - component.destroy(); - } - } - element.remove(); - }; - return GroupComponent; -}(_component__WEBPACK_IMPORTED_MODULE_5__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (GroupComponent); -//# sourceMappingURL=group-component.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/abstract/html-component.js": -/*!*********************************************************************!*\ - !*** ./node_modules/@antv/component/esm/abstract/html-component.js ***! - \*********************************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _antv_dom_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @antv/dom-util */ "./node_modules/@antv/dom-util/esm/index.js"); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); -/* harmony import */ var _util_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/util */ "./node_modules/@antv/component/esm/util/util.js"); -/* harmony import */ var _component__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./component */ "./node_modules/@antv/component/esm/abstract/component.js"); - - - - - -var HtmlComponent = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(HtmlComponent, _super); - function HtmlComponent() { - return _super !== null && _super.apply(this, arguments) || this; - } - HtmlComponent.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { container: null, containerTpl: '
', updateAutoRender: true, parent: null }); - return cfg; - }; - HtmlComponent.prototype.getContainer = function () { - return this.get('container'); - }; - /** - * 显示组件 - */ - HtmlComponent.prototype.show = function () { - var container = this.get('container'); - container.style.display = ''; - this.set('visible', true); - }; - /** - * 隐藏组件 - */ - HtmlComponent.prototype.hide = function () { - var container = this.get('container'); - container.style.display = 'none'; - this.set('visible', false); - }; - /** - * 是否允许捕捉事件 - * @param capture 事件捕捉 - */ - HtmlComponent.prototype.setCapture = function (capture) { - var container = this.getContainer(); - var value = capture ? 'auto' : 'none'; - container.style.pointerEvents = value; - this.set('capture', capture); - }; - HtmlComponent.prototype.getBBox = function () { - var container = this.getContainer(); - var x = parseFloat(container.style.left) || 0; - var y = parseFloat(container.style.top) || 0; - return Object(_util_util__WEBPACK_IMPORTED_MODULE_3__["createBBox"])(x, y, container.clientWidth, container.clientHeight); - }; - HtmlComponent.prototype.clear = function () { - var container = this.get('container'); - Object(_util_util__WEBPACK_IMPORTED_MODULE_3__["clearDom"])(container); - }; - HtmlComponent.prototype.destroy = function () { - this.removeEvent(); - this.removeDom(); - _super.prototype.destroy.call(this); - }; - /** - * 复写 init,主要是初始化 DOM 和事件 - */ - HtmlComponent.prototype.init = function () { - _super.prototype.init.call(this); - this.initContainer(); - this.initEvent(); - this.initCapture(); - this.initVisible(); - }; - HtmlComponent.prototype.initCapture = function () { - this.setCapture(this.get('capture')); - }; - HtmlComponent.prototype.initVisible = function () { - if (!this.get('visible')) { - // 设置初始显示状态 - this.hide(); - } - else { - this.show(); - } - }; - HtmlComponent.prototype.initContainer = function () { - var container = this.get('container'); - if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["isNil"])(container)) { - // 未指定 container 则创建 - container = this.createDom(); - var parent_1 = this.get('parent'); - if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["isString"])(parent_1)) { - parent_1 = document.getElementById(parent_1); - this.set('parent', parent_1); - } - parent_1.appendChild(container); - this.set('container', container); - } - else if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["isString"])(container)) { - // 用户传入的 id, 作为 container - container = document.getElementById(container); - this.set('container', container); - } // else container 是 DOM - if (!this.get('parent')) { - this.set('parent', container.parentNode); - } - }; - /** - * @protected - */ - HtmlComponent.prototype.createDom = function () { - var containerTpl = this.get('containerTpl'); - return Object(_antv_dom_util__WEBPACK_IMPORTED_MODULE_1__["createDom"])(containerTpl); - }; - /** - * @protected - * 初始化事件 - */ - HtmlComponent.prototype.initEvent = function () { }; - /** - * @protected - * 清理 DOM - */ - HtmlComponent.prototype.removeDom = function () { - var container = this.get('container'); - container && container.parentNode.removeChild(container); - }; - /** - * @protected - * 清理事件 - */ - HtmlComponent.prototype.removeEvent = function () { }; - return HtmlComponent; -}(_component__WEBPACK_IMPORTED_MODULE_4__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (HtmlComponent); -//# sourceMappingURL=html-component.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/annotation/arc.js": -/*!************************************************************!*\ - !*** ./node_modules/@antv/component/esm/annotation/arc.js ***! - \************************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _abstract_group_component__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../abstract/group-component */ "./node_modules/@antv/component/esm/abstract/group-component.js"); -/* harmony import */ var _util_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/util */ "./node_modules/@antv/component/esm/util/util.js"); - - - -var ArcAnnotation = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ArcAnnotation, _super); - function ArcAnnotation() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * @protected - * 默认的配置项 - * @returns {object} 默认的配置项 - */ - ArcAnnotation.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { name: 'annotation', type: 'arc', locationType: 'circle', center: null, radius: 100, startAngle: -Math.PI / 2, endAngle: (Math.PI * 3) / 2, style: { - stroke: '#999', - lineWidth: 1, - } }); - }; - ArcAnnotation.prototype.renderInner = function (group) { - this.renderArc(group); - }; - ArcAnnotation.prototype.getArcPath = function () { - var _a = this.getLocation(), center = _a.center, radius = _a.radius, startAngle = _a.startAngle, endAngle = _a.endAngle; - var startPoint = Object(_util_util__WEBPACK_IMPORTED_MODULE_2__["getCirclePoint"])(center, radius, startAngle); - var endPoint = Object(_util_util__WEBPACK_IMPORTED_MODULE_2__["getCirclePoint"])(center, radius, endAngle); - var largeFlag = endAngle - startAngle > Math.PI ? 1 : 0; - var path = [['M', startPoint.x, startPoint.y]]; - if (endAngle - startAngle === Math.PI * 2) { - // 整个圆是分割成两个圆 - var middlePoint = Object(_util_util__WEBPACK_IMPORTED_MODULE_2__["getCirclePoint"])(center, radius, startAngle + Math.PI); - path.push(['A', radius, radius, 0, largeFlag, 1, middlePoint.x, middlePoint.y]); - path.push(['A', radius, radius, 0, largeFlag, 1, endPoint.x, endPoint.y]); - } - else { - path.push(['A', radius, radius, 0, largeFlag, 1, endPoint.x, endPoint.y]); - } - return path; - }; - // 绘制 arc - ArcAnnotation.prototype.renderArc = function (group) { - // 也可以 通过 get('center') 类似的方式逐个获取 - var path = this.getArcPath(); - var style = this.get('style'); - this.addShape(group, { - type: 'path', - id: this.getElementId('arc'), - name: 'annotation-arc', - attrs: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ path: path }, style), - }); - }; - return ArcAnnotation; -}(_abstract_group_component__WEBPACK_IMPORTED_MODULE_1__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (ArcAnnotation); -//# sourceMappingURL=arc.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/annotation/data-marker.js": -/*!********************************************************************!*\ - !*** ./node_modules/@antv/component/esm/annotation/data-marker.js ***! - \********************************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); -/* harmony import */ var _abstract_group_component__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstract/group-component */ "./node_modules/@antv/component/esm/abstract/group-component.js"); -/* harmony import */ var _util_theme__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/theme */ "./node_modules/@antv/component/esm/util/theme.js"); - - - - -var DataMarkerAnnotation = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DataMarkerAnnotation, _super); - function DataMarkerAnnotation() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * 默认的配置项 - * @returns {object} 默认的配置项 - */ - DataMarkerAnnotation.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { name: 'annotation', type: 'dataMarker', locationType: 'point', x: 0, y: 0, point: {}, line: {}, text: {}, direction: 'upward', autoAdjust: true, coordinateBBox: null, defaultCfg: { - point: { - display: true, - style: { - r: 3, - fill: '#FFFFFF', - stroke: '#1890FF', - lineWidth: 2, - }, - }, - line: { - display: true, - length: 20, - style: { - stroke: _util_theme__WEBPACK_IMPORTED_MODULE_3__["default"].lineColor, - lineWidth: 1, - }, - }, - text: { - content: '', - display: true, - style: { - fill: _util_theme__WEBPACK_IMPORTED_MODULE_3__["default"].textColor, - opacity: 0.65, - fontSize: 12, - textAlign: 'start', - fontFamily: _util_theme__WEBPACK_IMPORTED_MODULE_3__["default"].fontFamily, - }, - }, - } }); - }; - DataMarkerAnnotation.prototype.renderInner = function (group) { - if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(this.get('line'), 'display')) { - this.renderLine(group); - } - if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(this.get('text'), 'display')) { - this.renderText(group); - } - if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(this.get('point'), 'display')) { - this.renderPoint(group); - } - if (this.get('autoAdjust')) { - this.autoAdjust(group); - } - }; - DataMarkerAnnotation.prototype.applyOffset = function () { - this.moveElementTo(this.get('group'), { - x: this.get('x') + this.get('offsetX'), - y: this.get('y') + this.get('offsetY'), - }); - }; - DataMarkerAnnotation.prototype.renderPoint = function (group) { - var point = this.getShapeAttrs().point; - this.addShape(group, { - type: 'circle', - id: this.getElementId('point'), - name: 'annotation-point', - attrs: point, - }); - }; - DataMarkerAnnotation.prototype.renderLine = function (group) { - var line = this.getShapeAttrs().line; - this.addShape(group, { - type: 'path', - id: this.getElementId('line'), - name: 'annotation-line', - attrs: line, - }); - }; - DataMarkerAnnotation.prototype.renderText = function (group) { - var text = this.getShapeAttrs().text; - this.addShape(group, { - type: 'text', - id: this.getElementId('text'), - name: 'annotation-text', - attrs: text, - }); - }; - DataMarkerAnnotation.prototype.autoAdjust = function (group) { - var direction = this.get('direction'); - var x = this.get('x'); - var y = this.get('y'); - var lineLength = Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(this.get('line'), 'length', 0); - var coordinateBBox = this.get('coordinateBBox'); - var _a = group.getBBox(), minX = _a.minX, maxX = _a.maxX, minY = _a.minY, maxY = _a.maxY; - var textShape = group.findById(this.getElementId('text')); - var lineShape = group.findById(this.getElementId('line')); - if (!coordinateBBox) { - return; - } - if (textShape) { - if (x + minX <= coordinateBBox.minX) { - // 左侧超出 - textShape.attr('textAlign', 'start'); - } - if (x + maxX >= coordinateBBox.maxX) { - // 右侧超出 - textShape.attr('textAlign', 'end'); - } - } - if ((direction === 'upward' && y + minY <= coordinateBBox.minY) || - (direction !== 'upward' && y + maxY >= coordinateBBox.maxY)) { - // 上方或者下方超出 - var textBaseline = void 0; - var factor = void 0; - if (direction === 'upward' && y + minY <= coordinateBBox.minY) { - textBaseline = 'top'; - factor = 1; - } - else { - textBaseline = 'bottom'; - factor = -1; - } - textShape.attr('textBaseline', textBaseline); - if (lineShape) { - lineShape.attr('path', [ - ['M', 0, 0], - ['L', 0, lineLength * factor], - ]); - } - textShape.attr('y', (lineLength + 2) * factor); - } - }; - DataMarkerAnnotation.prototype.getShapeAttrs = function () { - var lineDisplay = Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(this.get('line'), 'display'); - var pointStyle = Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(this.get('point'), 'style', {}); - var lineStyle = Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(this.get('line'), 'style', {}); - var textStyle = Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(this.get('text'), 'style', {}); - var direction = this.get('direction'); - var lineLength = lineDisplay ? Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(this.get('line'), 'length', 0) : 0; - var factor = direction === 'upward' ? -1 : 1; - return { - point: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ x: 0, y: 0 }, pointStyle), - line: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ path: [ - ['M', 0, 0], - ['L', 0, lineLength * factor], - ] }, lineStyle), - text: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ x: 0, y: (lineLength + 2) * factor, text: Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(this.get('text'), 'content', ''), textBaseline: direction === 'upward' ? 'bottom' : 'top' }, textStyle), - }; - }; - return DataMarkerAnnotation; -}(_abstract_group_component__WEBPACK_IMPORTED_MODULE_2__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (DataMarkerAnnotation); -//# sourceMappingURL=data-marker.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/annotation/data-region.js": -/*!********************************************************************!*\ - !*** ./node_modules/@antv/component/esm/annotation/data-region.js ***! - \********************************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); -/* harmony import */ var _abstract_group_component__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstract/group-component */ "./node_modules/@antv/component/esm/abstract/group-component.js"); -/* harmony import */ var _util_theme__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/theme */ "./node_modules/@antv/component/esm/util/theme.js"); -/* harmony import */ var _util_util__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../util/util */ "./node_modules/@antv/component/esm/util/util.js"); - - - - - -var DataRegionAnnotation = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(DataRegionAnnotation, _super); - function DataRegionAnnotation() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * 默认的配置项 - * @returns {object} 默认的配置项 - */ - DataRegionAnnotation.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { name: 'annotation', type: 'dataRegion', locationType: 'points', points: [], lineLength: 0, region: {}, text: {}, defaultCfg: { - region: { - style: { - lineWidth: 0, - fill: _util_theme__WEBPACK_IMPORTED_MODULE_3__["default"].regionColor, - opacity: 0.4, - }, - }, - text: { - content: '', - style: { - textAlign: 'center', - textBaseline: 'bottom', - fontSize: 12, - fill: _util_theme__WEBPACK_IMPORTED_MODULE_3__["default"].textColor, - fontFamily: _util_theme__WEBPACK_IMPORTED_MODULE_3__["default"].fontFamily, - }, - }, - } }); - }; - DataRegionAnnotation.prototype.renderInner = function (group) { - var regionStyle = Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(this.get('region'), 'style', {}); - var textStyle = Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(this.get('text'), 'style', {}); - var lineLength = this.get('lineLength') || 0; - var points = this.get('points'); - if (!points.length) { - return; - } - var bbox = Object(_util_util__WEBPACK_IMPORTED_MODULE_4__["pointsToBBox"])(points); - // render region - var path = []; - path.push(['M', points[0].x, bbox.minY - lineLength]); - points.forEach(function (point) { - path.push(['L', point.x, point.y]); - }); - path.push(['L', points[points.length - 1].x, points[points.length - 1].y - lineLength]); - this.addShape(group, { - type: 'path', - id: this.getElementId('region'), - name: 'annotation-region', - attrs: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ path: path }, regionStyle), - }); - // render text - this.addShape(group, { - type: 'text', - id: this.getElementId('text'), - name: 'annotation-text', - attrs: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ x: (bbox.minX + bbox.maxX) / 2, y: bbox.minY - lineLength, text: Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(this.get('text'), 'content', '') }, textStyle), - }); - }; - return DataRegionAnnotation; -}(_abstract_group_component__WEBPACK_IMPORTED_MODULE_2__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (DataRegionAnnotation); -//# sourceMappingURL=data-region.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/annotation/image.js": -/*!**************************************************************!*\ - !*** ./node_modules/@antv/component/esm/annotation/image.js ***! - \**************************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _abstract_group_component__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../abstract/group-component */ "./node_modules/@antv/component/esm/abstract/group-component.js"); -/* harmony import */ var _util_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/util */ "./node_modules/@antv/component/esm/util/util.js"); - - - -var ImageAnnotation = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ImageAnnotation, _super); - function ImageAnnotation() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * @protected - * 默认的配置项 - * @returns {object} 默认的配置项 - */ - ImageAnnotation.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { name: 'annotation', type: 'image', locationType: 'region', start: null, end: null, src: null, style: {} }); - }; - ImageAnnotation.prototype.renderInner = function (group) { - this.renderImage(group); - }; - ImageAnnotation.prototype.getImageAttrs = function () { - var start = this.get('start'); - var end = this.get('end'); - var style = this.get('style'); - var bbox = Object(_util_util__WEBPACK_IMPORTED_MODULE_2__["regionToBBox"])({ start: start, end: end }); - var src = this.get('src'); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ x: bbox.x, y: bbox.y, img: src, width: bbox.width, height: bbox.height }, style); - }; - // 绘制图片 - ImageAnnotation.prototype.renderImage = function (group) { - this.addShape(group, { - type: 'image', - id: this.getElementId('image'), - name: 'annotation-image', - attrs: this.getImageAttrs(), - }); - }; - return ImageAnnotation; -}(_abstract_group_component__WEBPACK_IMPORTED_MODULE_1__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (ImageAnnotation); -//# sourceMappingURL=image.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/annotation/index.js": -/*!**************************************************************!*\ - !*** ./node_modules/@antv/component/esm/annotation/index.js ***! - \**************************************************************/ -/*! exports provided: Line, Text, Arc, Region, Image, DataMarker, DataRegion, RegionFilter */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./line */ "./node_modules/@antv/component/esm/annotation/line.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_0__["default"]; }); - -/* harmony import */ var _text__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./text */ "./node_modules/@antv/component/esm/annotation/text.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Text", function() { return _text__WEBPACK_IMPORTED_MODULE_1__["default"]; }); - -/* harmony import */ var _arc__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arc */ "./node_modules/@antv/component/esm/annotation/arc.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc", function() { return _arc__WEBPACK_IMPORTED_MODULE_2__["default"]; }); - -/* harmony import */ var _region__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./region */ "./node_modules/@antv/component/esm/annotation/region.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Region", function() { return _region__WEBPACK_IMPORTED_MODULE_3__["default"]; }); - -/* harmony import */ var _image__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./image */ "./node_modules/@antv/component/esm/annotation/image.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Image", function() { return _image__WEBPACK_IMPORTED_MODULE_4__["default"]; }); - -/* harmony import */ var _data_marker__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./data-marker */ "./node_modules/@antv/component/esm/annotation/data-marker.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DataMarker", function() { return _data_marker__WEBPACK_IMPORTED_MODULE_5__["default"]; }); - -/* harmony import */ var _data_region__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./data-region */ "./node_modules/@antv/component/esm/annotation/data-region.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DataRegion", function() { return _data_region__WEBPACK_IMPORTED_MODULE_6__["default"]; }); - -/* harmony import */ var _region_filter__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./region-filter */ "./node_modules/@antv/component/esm/annotation/region-filter.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RegionFilter", function() { return _region_filter__WEBPACK_IMPORTED_MODULE_7__["default"]; }); - - - - - - - - - -//# sourceMappingURL=index.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/annotation/line.js": -/*!*************************************************************!*\ - !*** ./node_modules/@antv/component/esm/annotation/line.js ***! - \*************************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); -/* harmony import */ var _abstract_group_component__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstract/group-component */ "./node_modules/@antv/component/esm/abstract/group-component.js"); -/* harmony import */ var _util_matrix__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/matrix */ "./node_modules/@antv/component/esm/util/matrix.js"); -/* harmony import */ var _util_theme__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../util/theme */ "./node_modules/@antv/component/esm/util/theme.js"); -/* harmony import */ var _util_util__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util/util */ "./node_modules/@antv/component/esm/util/util.js"); - - - - - - -var LineAnnotation = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(LineAnnotation, _super); - function LineAnnotation() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * @protected - * 默认的配置项 - * @returns {object} 默认的配置项 - */ - LineAnnotation.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { name: 'annotation', type: 'line', locationType: 'region', start: null, end: null, style: {}, text: null, defaultCfg: { - style: { - fill: _util_theme__WEBPACK_IMPORTED_MODULE_4__["default"].textColor, - fontSize: 12, - textAlign: 'center', - textBaseline: 'bottom', - fontFamily: _util_theme__WEBPACK_IMPORTED_MODULE_4__["default"].fontFamily, - }, - text: { - position: 'center', - autoRotate: true, - content: null, - offsetX: 0, - offsetY: 0, - style: { - stroke: _util_theme__WEBPACK_IMPORTED_MODULE_4__["default"].lineColor, - lineWidth: 1, - }, - }, - } }); - }; - LineAnnotation.prototype.renderInner = function (group) { - this.renderLine(group); - if (this.get('text')) { - this.renderLabel(group); - } - }; - // 绘制线 - LineAnnotation.prototype.renderLine = function (group) { - var start = this.get('start'); - var end = this.get('end'); - var style = this.get('style'); - this.addShape(group, { - type: 'line', - id: this.getElementId('line'), - name: 'annotation-line', - attrs: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ x1: start.x, y1: start.y, x2: end.x, y2: end.y }, style), - }); - }; - // 获取 label 的位置 - LineAnnotation.prototype.getLabelPoint = function (start, end, position) { - var percent; - if (position === 'start') { - percent = 0; - } - else if (position === 'center') { - percent = 0.5; - } - else if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["isString"])(position) && position.indexOf('%') !== -1) { - percent = parseInt(position, 10) / 100; - } - else if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["isNumber"])(position)) { - percent = position; - } - else { - percent = 1; - } - if (percent > 1 || percent < 0) { - percent = 1; - } - return { - x: Object(_util_util__WEBPACK_IMPORTED_MODULE_5__["getValueByPercent"])(start.x, end.x, percent), - y: Object(_util_util__WEBPACK_IMPORTED_MODULE_5__["getValueByPercent"])(start.y, end.y, percent), - }; - }; - // 绘制 label - LineAnnotation.prototype.renderLabel = function (group) { - var text = this.get('text'); - var start = this.get('start'); - var end = this.get('end'); - var position = text.position, content = text.content, style = text.style, offsetX = text.offsetX, offsetY = text.offsetY, autoRotate = text.autoRotate; - var point = this.getLabelPoint(start, end, position); - var attrs = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ x: point.x + offsetX, y: point.y + offsetY, text: content }, style); - // 如果自动旋转,需要计算矩阵 - if (autoRotate) { - var vector = [end.x - start.x, end.y - start.y]; - var angle = Math.atan2(vector[1], vector[0]); - var matrix = Object(_util_matrix__WEBPACK_IMPORTED_MODULE_3__["getMatrixByAngle"])(point, angle); - attrs.matrix = matrix; - } - this.addShape(group, { - type: 'text', - id: this.getElementId('line-text'), - name: 'annotation-line-text', - attrs: attrs, - }); - }; - return LineAnnotation; -}(_abstract_group_component__WEBPACK_IMPORTED_MODULE_2__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (LineAnnotation); -//# sourceMappingURL=line.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/annotation/region-filter.js": -/*!**********************************************************************!*\ - !*** ./node_modules/@antv/component/esm/annotation/region-filter.js ***! - \**********************************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); -/* harmony import */ var _abstract_group_component__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstract/group-component */ "./node_modules/@antv/component/esm/abstract/group-component.js"); -/* harmony import */ var _util_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/util */ "./node_modules/@antv/component/esm/util/util.js"); - - - - -var RegionFilterAnnotation = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RegionFilterAnnotation, _super); - function RegionFilterAnnotation() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * 默认的配置项 - * @returns {object} 默认的配置项 - */ - RegionFilterAnnotation.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { name: 'annotation', type: 'regionFilter', locationType: 'region', start: null, end: null, color: null, shape: [] }); - }; - RegionFilterAnnotation.prototype.renderInner = function (group) { - var _this = this; - var start = this.get('start'); - var end = this.get('end'); - // 1. add region layer - var layer = this.addGroup(group, { - id: this.getElementId('region-filter'), - capture: false, - }); - // 2. clone shape & color it - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(this.get('shapes'), function (shape, shapeIdx) { - var type = shape.get('type'); - var attrs = Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["clone"])(shape.attr()); - _this.adjustShapeAttrs(attrs); - _this.addShape(layer, { - id: _this.getElementId("shape-" + type + "-" + shapeIdx), - capture: false, - type: type, - attrs: attrs, - }); - }); - // 3. clip - var clipBBox = Object(_util_util__WEBPACK_IMPORTED_MODULE_3__["regionToBBox"])({ start: start, end: end }); - layer.setClip({ - type: 'rect', - attrs: { - x: clipBBox.minX, - y: clipBBox.minY, - width: clipBBox.width, - height: clipBBox.height, - }, - }); - }; - RegionFilterAnnotation.prototype.adjustShapeAttrs = function (attr) { - var color = this.get('color'); - if (attr.fill) { - attr.fill = attr.fillStyle = color; - } - attr.stroke = attr.strokeStyle = color; - }; - return RegionFilterAnnotation; -}(_abstract_group_component__WEBPACK_IMPORTED_MODULE_2__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (RegionFilterAnnotation); -//# sourceMappingURL=region-filter.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/annotation/region.js": -/*!***************************************************************!*\ - !*** ./node_modules/@antv/component/esm/annotation/region.js ***! - \***************************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _abstract_group_component__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../abstract/group-component */ "./node_modules/@antv/component/esm/abstract/group-component.js"); -/* harmony import */ var _util_theme__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/theme */ "./node_modules/@antv/component/esm/util/theme.js"); -/* harmony import */ var _util_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/util */ "./node_modules/@antv/component/esm/util/util.js"); - - - - -var RegionAnnotation = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(RegionAnnotation, _super); - function RegionAnnotation() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * @protected - * 默认的配置项 - * @returns {object} 默认的配置项 - */ - RegionAnnotation.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { name: 'annotation', type: 'region', locationType: 'region', start: null, end: null, style: {}, defaultCfg: { - style: { - lineWidth: 0, - fill: _util_theme__WEBPACK_IMPORTED_MODULE_2__["default"].regionColor, - opacity: 0.4, - }, - } }); - }; - RegionAnnotation.prototype.renderInner = function (group) { - this.renderRegion(group); - }; - RegionAnnotation.prototype.renderRegion = function (group) { - var start = this.get('start'); - var end = this.get('end'); - var style = this.get('style'); - var bbox = Object(_util_util__WEBPACK_IMPORTED_MODULE_3__["regionToBBox"])({ start: start, end: end }); - this.addShape(group, { - type: 'rect', - id: this.getElementId('region'), - name: 'annotation-region', - attrs: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ x: bbox.x, y: bbox.y, width: bbox.width, height: bbox.height }, style), - }); - }; - return RegionAnnotation; -}(_abstract_group_component__WEBPACK_IMPORTED_MODULE_1__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (RegionAnnotation); -//# sourceMappingURL=region.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/annotation/text.js": -/*!*************************************************************!*\ - !*** ./node_modules/@antv/component/esm/annotation/text.js ***! - \*************************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _abstract_group_component__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../abstract/group-component */ "./node_modules/@antv/component/esm/abstract/group-component.js"); -/* harmony import */ var _util_matrix__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/matrix */ "./node_modules/@antv/component/esm/util/matrix.js"); -/* harmony import */ var _util_theme__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/theme */ "./node_modules/@antv/component/esm/util/theme.js"); - - - - -var TextAnnotation = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(TextAnnotation, _super); - function TextAnnotation() { - return _super !== null && _super.apply(this, arguments) || this; - } - /** - * @protected - * 默认的配置项 - * @returns {object} 默认的配置项 - */ - TextAnnotation.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { name: 'annotation', type: 'text', locationType: 'point', x: 0, y: 0, content: '', rotate: null, style: {}, defaultCfg: { - style: { - fill: _util_theme__WEBPACK_IMPORTED_MODULE_3__["default"].textColor, - fontSize: 12, - textAlign: 'center', - textBaseline: 'middle', - fontFamily: _util_theme__WEBPACK_IMPORTED_MODULE_3__["default"].fontFamily, - }, - } }); - }; - // 复写 setLocation 方法,不需要重新创建 text - TextAnnotation.prototype.setLocation = function (location) { - this.set('x', location.x); - this.set('y', location.y); - this.resetLocation(); - }; - TextAnnotation.prototype.renderInner = function (group) { - this.renderText(group); - }; - TextAnnotation.prototype.renderText = function (group) { - var _a = this.getLocation(), x = _a.x, y = _a.y; - var content = this.get('content'); - var style = this.get('style'); - var text = this.addShape(group, { - type: 'text', - id: this.getElementId('text'), - name: 'annotation-text', - attrs: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ x: x, - y: y, text: content }, style), - }); - this.applyRotate(text, x, y); - }; - TextAnnotation.prototype.applyRotate = function (textShape, x, y) { - var rotate = this.get('rotate'); - var matrix = null; - if (rotate) { - matrix = Object(_util_matrix__WEBPACK_IMPORTED_MODULE_2__["getMatrixByAngle"])({ x: x, y: y }, rotate); - } - textShape.attr('matrix', matrix); - }; - TextAnnotation.prototype.resetLocation = function () { - var textShape = this.getElementByLocalId('text'); - if (textShape) { - var _a = this.getLocation(), x = _a.x, y = _a.y; - textShape.attr({ - x: x, - y: y, - }); - this.applyRotate(textShape, x, y); - } - }; - return TextAnnotation; -}(_abstract_group_component__WEBPACK_IMPORTED_MODULE_1__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (TextAnnotation); -//# sourceMappingURL=text.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/axis/base.js": -/*!*******************************************************!*\ - !*** ./node_modules/@antv/component/esm/axis/base.js ***! - \*******************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _antv_matrix_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @antv/matrix-util */ "./node_modules/@antv/matrix-util/esm/index.js"); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); -/* harmony import */ var _abstract_group_component__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstract/group-component */ "./node_modules/@antv/component/esm/abstract/group-component.js"); -/* harmony import */ var _util_matrix__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../util/matrix */ "./node_modules/@antv/component/esm/util/matrix.js"); -/* harmony import */ var _util_state__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util/state */ "./node_modules/@antv/component/esm/util/state.js"); -/* harmony import */ var _util_theme__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../util/theme */ "./node_modules/@antv/component/esm/util/theme.js"); - - - - - - - -var AxisBase = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(AxisBase, _super); - function AxisBase() { - return _super !== null && _super.apply(this, arguments) || this; - } - AxisBase.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { name: 'axis', ticks: [], line: {}, tickLine: {}, subTickLine: null, title: null, - /** - * 文本标签的配置项 - */ - label: {}, - /** - * 垂直于坐标轴方向的因子,决定文本、title、tickLine 在坐标轴的哪一侧 - */ - verticalFactor: 1, - // 垂直方向限制的长度,对文本自适应有很大影响 - verticalLimitLength: null, overlapOrder: ['autoRotate', 'autoEllipsis', 'autoHide'], tickStates: {}, defaultCfg: { - line: { - // @type {Attrs} 坐标轴线的图形属性,如果设置成null,则不显示轴线 - style: { - lineWidth: 1, - stroke: _util_theme__WEBPACK_IMPORTED_MODULE_6__["default"].lineColor, - }, - }, - tickLine: { - // @type {Attrs} 标注坐标线的图形属性 - style: { - lineWidth: 1, - stroke: _util_theme__WEBPACK_IMPORTED_MODULE_6__["default"].lineColor, - }, - alignTick: true, - length: 5, - displayWithLabel: true, - }, - subTickLine: { - // @type {Attrs} 标注坐标线的图形属性 - style: { - lineWidth: 1, - stroke: _util_theme__WEBPACK_IMPORTED_MODULE_6__["default"].lineColor, - }, - count: 4, - length: 2, - }, - label: { - autoRotate: true, - autoHide: false, - autoEllipsis: false, - style: { - fontSize: 12, - fill: _util_theme__WEBPACK_IMPORTED_MODULE_6__["default"].textColor, - textBaseline: 'middle', - fontFamily: _util_theme__WEBPACK_IMPORTED_MODULE_6__["default"].fontFamily, - fontWeight: 'normal', - }, - offset: 10, - }, - title: { - autoRotate: true, - spacing: 5, - position: 'center', - style: { - fontSize: 12, - fill: _util_theme__WEBPACK_IMPORTED_MODULE_6__["default"].textColor, - textBaseline: 'middle', - fontFamily: _util_theme__WEBPACK_IMPORTED_MODULE_6__["default"].fontFamily, - textAlign: 'center', - }, - offset: 48, - }, - tickStates: { - active: { - labelStyle: { - fontWeight: 500, - }, - tickLineStyle: { - lineWidth: 2, - }, - }, - inactive: { - labelStyle: { - fill: _util_theme__WEBPACK_IMPORTED_MODULE_6__["default"].uncheckedColor, - }, - }, - }, - } }); - }; - /** - * 绘制组件 - */ - AxisBase.prototype.renderInner = function (group) { - if (this.get('line')) { - this.drawLine(group); - } - // drawTicks 包括 drawLabels 和 drawTickLines - this.drawTicks(group); - if (this.get('title')) { - this.drawTitle(group); - } - }; - // 实现 IList 接口 - AxisBase.prototype.isList = function () { - return true; - }; - /** - * 获取图例项 - * @return {ListItem[]} 列表项集合 - */ - AxisBase.prototype.getItems = function () { - return this.get('ticks'); - }; - /** - * 设置列表项 - * @param {ListItem[]} items 列表项集合 - */ - AxisBase.prototype.setItems = function (items) { - this.update({ - ticks: items, - }); - }; - /** - * 更新列表项 - * @param {ListItem} item 列表项 - * @param {object} cfg 列表项 - */ - AxisBase.prototype.updateItem = function (item, cfg) { - Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["mix"])(item, cfg); - this.clear(); // 由于单个图例项变化,会引起全局变化,所以全部更新 - this.render(); - }; - /** - * 清空列表 - */ - AxisBase.prototype.clearItems = function () { - var itemGroup = this.getElementByLocalId('label-group'); - itemGroup && itemGroup.clear(); - }; - /** - * 设置列表项的状态 - * @param {ListItem} item 列表项 - * @param {string} state 状态名 - * @param {boolean} value 状态值, true, false - */ - AxisBase.prototype.setItemState = function (item, state, value) { - item[state] = value; - this.updateTickStates(item); // 应用状态样式 - }; - /** - * 是否存在指定的状态 - * @param {ListItem} item 列表项 - * @param {boolean} state 状态名 - */ - AxisBase.prototype.hasState = function (item, state) { - return !!item[state]; - }; - AxisBase.prototype.getItemStates = function (item) { - var tickStates = this.get('tickStates'); - var rst = []; - Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["each"])(tickStates, function (v, k) { - if (item[k]) { - // item.selected - rst.push(k); - } - }); - return rst; - }; - /** - * 清楚所有列表项的状态 - * @param {string} state 状态值 - */ - AxisBase.prototype.clearItemsState = function (state) { - var _this = this; - var items = this.getItemsByState(state); - Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["each"])(items, function (item) { - _this.setItemState(item, state, false); - }); - }; - /** - * 根据状态获取图例项 - * @param {string} state [description] - * @return {ListItem[]} [description] - */ - AxisBase.prototype.getItemsByState = function (state) { - var _this = this; - var items = this.getItems(); - return Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["filter"])(items, function (item) { - return _this.hasState(item, state); - }); - }; - AxisBase.prototype.getSidePoint = function (point, offset) { - var self = this; - var vector = self.getSideVector(offset, point); - return { - x: point.x + vector[0], - y: point.y + vector[1], - }; - }; - AxisBase.prototype.getTextAnchor = function (vector) { - var align; - if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["isNumberEqual"])(vector[0], 0)) { - align = 'center'; - } - else if (vector[0] > 0) { - align = 'start'; - } - else if (vector[0] < 0) { - align = 'end'; - } - return align; - }; - AxisBase.prototype.processOverlap = function (labelGroup) { }; - // 绘制坐标轴线 - AxisBase.prototype.drawLine = function (group) { - var path = this.getLinePath(); - var line = this.get('line'); // line 的判空在调用 drawLine 之前,不在这里判定 - this.addShape(group, { - type: 'path', - id: this.getElementId('line'), - name: 'axis-line', - attrs: Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["mix"])({ - path: path, - }, line.style), - }); - }; - AxisBase.prototype.getTickLineItems = function (ticks) { - var _this = this; - var tickLineItems = []; - var tickLine = this.get('tickLine'); - var alignTick = tickLine.alignTick; - var tickLineLength = tickLine.length; - var tickSegment = 1; - var tickCount = ticks.length; - if (tickCount >= 2) { - tickSegment = ticks[1].value - ticks[0].value; - } - Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["each"])(ticks, function (tick) { - var point = tick.point; - if (!alignTick) { - // tickLine 不同 tick 对齐时需要调整 point - point = _this.getTickPoint(tick.value - tickSegment / 2); - } - var endPoint = _this.getSidePoint(point, tickLineLength); - tickLineItems.push({ - startPoint: point, - tickValue: tick.value, - endPoint: endPoint, - tickId: tick.id, - id: "tickline-" + tick.id, - }); - }); - // 如果 tickLine 不居中对齐,则需要在最后面补充一个 tickLine - // if (!alignTick && tickCount > 0) { - // const tick = ticks[tickCount - 1]; - // const point = this.getTickPoint(tick.value + tickSegment / 2); - // } - return tickLineItems; - }; - AxisBase.prototype.getSubTickLineItems = function (tickLineItems) { - var subTickLineItems = []; - var subTickLine = this.get('subTickLine'); - var subCount = subTickLine.count; - var tickLineCount = tickLineItems.length; - // 刻度线的数量大于 2 时,才绘制子刻度 - if (tickLineCount >= 2) { - for (var i = 0; i < tickLineCount - 1; i++) { - var pre = tickLineItems[i]; - var next = tickLineItems[i + 1]; - for (var j = 0; j < subCount; j++) { - var percent = (j + 1) / (subCount + 1); - var tickValue = (1 - percent) * pre.tickValue + percent * next.tickValue; - var point = this.getTickPoint(tickValue); - var endPoint = this.getSidePoint(point, subTickLine.length); - subTickLineItems.push({ - startPoint: point, - endPoint: endPoint, - tickValue: tickValue, - id: "sub-" + pre.id + "-" + j, - }); - } - } - } - return subTickLineItems; - }; - AxisBase.prototype.getTickLineAttrs = function (tickItem) { - var tickLineStyle = this.get('tickLine').style; - var startPoint = tickItem.startPoint, endPoint = tickItem.endPoint; - var attrs = Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["mix"])({ - x1: startPoint.x, - y1: startPoint.y, - x2: endPoint.x, - y2: endPoint.y, - }, tickLineStyle); - return attrs; - }; - // 绘制坐标轴刻度线 - AxisBase.prototype.drawTick = function (tickItem, tickLineGroup) { - this.addShape(tickLineGroup, { - type: 'line', - id: this.getElementId(tickItem.id), - name: 'axis-tickline', - attrs: this.getTickLineAttrs(tickItem), - }); - }; - // 绘制坐标轴刻度线,包括子刻度线 - AxisBase.prototype.drawTickLines = function (group) { - var _this = this; - var ticks = this.get('ticks'); - var subTickLine = this.get('subTickLine'); - var tickLineItems = this.getTickLineItems(ticks); - var tickLineGroup = this.addGroup(group, { - name: 'axis-tickline-group', - id: this.getElementId('tickline-group'), - }); - var tickCfg = this.get('tickLine'); - Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["each"])(tickLineItems, function (item) { - if (tickCfg.displayWithLabel) { - // 如果跟随 label 显示,则检测是否存在对应的 label - var labelId = _this.getElementId("label-" + item.tickId); - if (group.findById(labelId)) { - _this.drawTick(item, tickLineGroup); - } - } - else { - _this.drawTick(item, tickLineGroup); - } - }); - if (subTickLine) { - var subTickLineItems = this.getSubTickLineItems(tickLineItems); - Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["each"])(subTickLineItems, function (item) { - _this.drawTick(item, tickLineGroup); - }); - } - }; - // 预处理 ticks 确定位置和补充 id - AxisBase.prototype.processTicks = function () { - var _this = this; - var ticks = this.get('ticks'); - Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["each"])(ticks, function (tick) { - tick.point = _this.getTickPoint(tick.value); - // 补充 tick 的 id,为动画和更新做准备 - if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["isNil"])(tick.id)) { - // 默认使用 tick.name 作为id - tick.id = tick.name; - } - }); - }; - // 绘制 ticks 包括文本和 tickLine - AxisBase.prototype.drawTicks = function (group) { - var _this = this; - this.processTicks(); - if (this.get('label')) { - this.drawLabels(group); - } - if (this.get('tickLine')) { - this.drawTickLines(group); - } - var ticks = this.get('ticks'); - Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["each"])(ticks, function (tick) { - _this.applyTickStates(tick, group); - }); - }; - // 获取 label 的配置项 - AxisBase.prototype.getLabelAttrs = function (tick, index) { - var labelCfg = this.get('label'); - var offset = labelCfg.offset, style = labelCfg.style, rotate = labelCfg.rotate, formatter = labelCfg.formatter; - var point = this.getSidePoint(tick.point, offset); - var vector = this.getSideVector(offset, point); - var text = formatter ? formatter(tick.name, tick, index) : tick.name; - var attrs = Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["mix"])({ - x: point.x, - y: point.y, - text: text, - textAlign: this.getTextAnchor(vector), - }, style); - if (rotate) { - attrs.matrix = Object(_util_matrix__WEBPACK_IMPORTED_MODULE_4__["getMatrixByAngle"])(point, rotate); - } - return attrs; - }; - // 绘制文本 - AxisBase.prototype.drawLabels = function (group) { - var _this = this; - var ticks = this.get('ticks'); - var labelGroup = this.addGroup(group, { - name: 'axis-label-group', - id: this.getElementId('label-group'), - }); - Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["each"])(ticks, function (tick, index) { - _this.addShape(labelGroup, { - type: 'text', - name: 'axis-label', - id: _this.getElementId("label-" + tick.id), - attrs: _this.getLabelAttrs(tick, index), - delegateObject: { - tick: tick, - item: tick, - index: index, - }, - }); - }); - this.processOverlap(labelGroup); - }; - // 标题的属性 - AxisBase.prototype.getTitleAttrs = function () { - var titleCfg = this.get('title'); - var style = titleCfg.style, position = titleCfg.position, offset = titleCfg.offset, autoRotate = titleCfg.autoRotate; - var percent = 0.5; - if (position === 'start') { - percent = 0; - } - else if (position === 'end') { - percent = 1; - } - var point = this.getTickPoint(percent); // 标题对应的坐标轴上的点 - var titlePoint = this.getSidePoint(point, offset); // 标题的点 - var attrs = Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["mix"])({ - x: titlePoint.x, - y: titlePoint.y, - text: titleCfg.text, - }, style); - var rotate = titleCfg.rotate; // rotate 是角度值 - var angle = rotate; - if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["isNil"])(rotate) && autoRotate) { - // 用户没有设定旋转角度,同时设置自动旋转 - var vector = this.getAxisVector(point); - var v1 = [1, 0]; // 水平方向的向量 - angle = _antv_matrix_util__WEBPACK_IMPORTED_MODULE_1__["vec2"].angleTo(vector, v1, true); - } - if (angle) { - var matrix = Object(_util_matrix__WEBPACK_IMPORTED_MODULE_4__["getMatrixByAngle"])(titlePoint, angle); - attrs.matrix = matrix; - } - return attrs; - }; - // 绘制标题 - AxisBase.prototype.drawTitle = function (group) { - this.addShape(group, { - type: 'text', - id: this.getElementId('title'), - name: 'axis-title', - attrs: this.getTitleAttrs(), - }); - }; - AxisBase.prototype.applyTickStates = function (tick, group) { - var states = this.getItemStates(tick); - if (states.length) { - var tickStates = this.get('tickStates'); - // 分别更新 label 和 tickLine - var labelId = this.getElementId("label-" + tick.id); - var labelShape = group.findById(labelId); - if (labelShape) { - var labelStateStyle = Object(_util_state__WEBPACK_IMPORTED_MODULE_5__["getStatesStyle"])(tick, 'label', tickStates); - labelStateStyle && labelShape.attr(labelStateStyle); - } - var tickLineId = this.getElementId("tickline-" + tick.id); - var tickLineShape = group.findById(tickLineId); - if (tickLineShape) { - var tickLineStateStyle = Object(_util_state__WEBPACK_IMPORTED_MODULE_5__["getStatesStyle"])(tick, 'tickLine', tickStates); - tickLineStateStyle && tickLineShape.attr(tickLineStateStyle); - } - } - }; - AxisBase.prototype.updateTickStates = function (tick) { - var states = this.getItemStates(tick); - var tickStates = this.get('tickStates'); - var labelCfg = this.get('label'); - var labelShape = this.getElementByLocalId("label-" + tick.id); - var tickLineCfg = this.get('tickLine'); - var tickLineShape = this.getElementByLocalId("tickline-" + tick.id); - if (states.length) { - if (labelShape) { - var labelStateStyle = Object(_util_state__WEBPACK_IMPORTED_MODULE_5__["getStatesStyle"])(tick, 'label', tickStates); - labelStateStyle && labelShape.attr(labelStateStyle); - } - if (tickLineShape) { - var tickLineStateStyle = Object(_util_state__WEBPACK_IMPORTED_MODULE_5__["getStatesStyle"])(tick, 'tickLine', tickStates); - tickLineStateStyle && tickLineShape.attr(tickLineStateStyle); - } - } - else { - if (labelShape) { - labelShape.attr(labelCfg.style); - } - if (tickLineShape) { - tickLineShape.attr(tickLineCfg.style); - } - } - }; - return AxisBase; -}(_abstract_group_component__WEBPACK_IMPORTED_MODULE_3__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (AxisBase); -//# sourceMappingURL=base.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/axis/circle.js": -/*!*********************************************************!*\ - !*** ./node_modules/@antv/component/esm/axis/circle.js ***! - \*********************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _antv_matrix_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @antv/matrix-util */ "./node_modules/@antv/matrix-util/esm/index.js"); -/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base */ "./node_modules/@antv/component/esm/axis/base.js"); - - - -var Circle = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Circle, _super); - function Circle() { - return _super !== null && _super.apply(this, arguments) || this; - } - Circle.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { type: 'circle', locationType: 'circle', center: null, radius: null, startAngle: -Math.PI / 2, endAngle: (Math.PI * 3) / 2 }); - }; - Circle.prototype.getLinePath = function () { - var center = this.get('center'); - var x = center.x; - var y = center.y; - var rx = this.get('radius'); - var ry = rx; - var startAngle = this.get('startAngle'); - var endAngle = this.get('endAngle'); - var path = []; - if (Math.abs(endAngle - startAngle) === Math.PI * 2) { - path = [['M', x, y - ry], ['A', rx, ry, 0, 1, 1, x, y + ry], ['A', rx, ry, 0, 1, 1, x, y - ry], ['Z']]; - } - else { - var startPoint = this.getCirclePoint(startAngle); - var endPoint = this.getCirclePoint(endAngle); - var large = Math.abs(endAngle - startAngle) > Math.PI ? 1 : 0; - var sweep = startAngle > endAngle ? 0 : 1; - path = [ - ['M', x, y], - ['L', startPoint.x, startPoint.y], - ['A', rx, ry, 0, large, sweep, endPoint.x, endPoint.y], - ['L', x, y], - ]; - } - return path; - }; - Circle.prototype.getTickPoint = function (tickValue) { - var startAngle = this.get('startAngle'); - var endAngle = this.get('endAngle'); - var angle = startAngle + (endAngle - startAngle) * tickValue; - return this.getCirclePoint(angle); - }; - // 获取垂直于坐标轴的向量 - Circle.prototype.getSideVector = function (offset, point) { - var center = this.get('center'); - var vector = [point.x - center.x, point.y - center.y]; - var factor = this.get('verticalFactor'); - var vecLen = _antv_matrix_util__WEBPACK_IMPORTED_MODULE_1__["vec2"].length(vector); - _antv_matrix_util__WEBPACK_IMPORTED_MODULE_1__["vec2"].scale(vector, vector, (factor * offset) / vecLen); - return vector; - }; - // 获取沿坐标轴方向的向量 - Circle.prototype.getAxisVector = function (point) { - var center = this.get('center'); - var vector = [point.x - center.x, point.y - center.y]; - return [vector[1], -1 * vector[0]]; // 获取顺时针方向的向量 - }; - // 根据圆心和半径获取点 - Circle.prototype.getCirclePoint = function (angle, radius) { - var center = this.get('center'); - radius = radius || this.get('radius'); - return { - x: center.x + Math.cos(angle) * radius, - y: center.y + Math.sin(angle) * radius, - }; - }; - return Circle; -}(_base__WEBPACK_IMPORTED_MODULE_2__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (Circle); -//# sourceMappingURL=circle.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/axis/index.js": -/*!********************************************************!*\ - !*** ./node_modules/@antv/component/esm/axis/index.js ***! - \********************************************************/ -/*! exports provided: Line, Circle, Base */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./line */ "./node_modules/@antv/component/esm/axis/line.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_0__["default"]; }); - -/* harmony import */ var _circle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./circle */ "./node_modules/@antv/component/esm/axis/circle.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Circle", function() { return _circle__WEBPACK_IMPORTED_MODULE_1__["default"]; }); - -/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base */ "./node_modules/@antv/component/esm/axis/base.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Base", function() { return _base__WEBPACK_IMPORTED_MODULE_2__["default"]; }); - - - - -//# sourceMappingURL=index.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/axis/line.js": -/*!*******************************************************!*\ - !*** ./node_modules/@antv/component/esm/axis/line.js ***! - \*******************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _antv_matrix_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @antv/matrix-util */ "./node_modules/@antv/matrix-util/esm/index.js"); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); -/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./base */ "./node_modules/@antv/component/esm/axis/base.js"); -/* harmony import */ var _overlap__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./overlap */ "./node_modules/@antv/component/esm/axis/overlap/index.js"); - - - - - -var Line = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super); - function Line() { - return _super !== null && _super.apply(this, arguments) || this; - } - Line.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { type: 'line', locationType: 'region', - /** - * 起始点, x, y - * @type {object} - */ - start: null, - /** - * 结束点, x, y - * @type {object} - */ - end: null }); - }; - // 获取坐标轴线的 path - Line.prototype.getLinePath = function () { - var start = this.get('start'); - var end = this.get('end'); - var path = []; - path.push(['M', start.x, start.y]); - path.push(['L', end.x, end.y]); - return path; - }; - // 重新计算 layout bbox,考虑到 line 不显示 - Line.prototype.getInnerLayoutBBox = function () { - var start = this.get('start'); - var end = this.get('end'); - var bbox = _super.prototype.getInnerLayoutBBox.call(this); - var minX = Math.min(start.x, end.x, bbox.x); - var minY = Math.min(start.y, end.y, bbox.y); - var maxX = Math.max(start.x, end.x, bbox.maxX); - var maxY = Math.max(start.y, end.y, bbox.maxY); - return { - x: minX, - y: minY, - minX: minX, - minY: minY, - maxX: maxX, - maxY: maxY, - width: maxX - minX, - height: maxY - minY, - }; - }; - Line.prototype.isVertical = function () { - var start = this.get('start'); - var end = this.get('end'); - return Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["isNumberEqual"])(start.x, end.x); - }; - Line.prototype.isHorizontal = function () { - var start = this.get('start'); - var end = this.get('end'); - return Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["isNumberEqual"])(start.y, end.y); - }; - Line.prototype.getTickPoint = function (tickValue) { - var self = this; - var start = self.get('start'); - var end = self.get('end'); - var regionX = end.x - start.x; - var regionY = end.y - start.y; - return { - x: start.x + regionX * tickValue, - y: start.y + regionY * tickValue, - }; - }; - // 直线坐标轴下任一点的向量方向都相同 - Line.prototype.getSideVector = function (offset) { - var axisVector = this.getAxisVector(); - var normal = _antv_matrix_util__WEBPACK_IMPORTED_MODULE_1__["vec2"].normalize([], axisVector); - var factor = this.get('verticalFactor'); - var verticalVector = [normal[1], normal[0] * -1]; // 垂直方向,逆时针方向 - return _antv_matrix_util__WEBPACK_IMPORTED_MODULE_1__["vec2"].scale([], verticalVector, offset * factor); - }; - // 获取坐标轴的向量 - Line.prototype.getAxisVector = function () { - var start = this.get('start'); - var end = this.get('end'); - return [end.x - start.x, end.y - start.y]; - }; - Line.prototype.processOverlap = function (labelGroup) { - var _this = this; - var isVertical = this.isVertical(); - var isHorizontal = this.isHorizontal(); - // 非垂直,或者非水平时不处理遮挡问题 - if (!isVertical && !isHorizontal) { - return; - } - var labelCfg = this.get('label'); - var titleCfg = this.get('title'); - var verticalLimitLength = this.get('verticalLimitLength'); - var labelOffset = labelCfg.offset; - var limitLength = verticalLimitLength; - var titleHeight = 0; - var titleSpacing = 0; - if (titleCfg) { - titleHeight = titleCfg.style.fontSize; - titleSpacing = titleCfg.spacing; - } - if (limitLength) { - limitLength = limitLength - labelOffset - titleSpacing - titleHeight; - } - var overlapOrder = this.get('overlapOrder'); - Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["each"])(overlapOrder, function (name) { - if (labelCfg[name]) { - _this.autoProcessOverlap(name, labelCfg[name], labelGroup, limitLength); - } - }); - if (titleCfg) { - // 调整 title 的 offset - var bbox = labelGroup.getBBox(); - var length_1 = isVertical ? bbox.width : bbox.height; - titleCfg.offset = labelOffset + length_1 + titleSpacing + titleHeight / 2; - } - }; - Line.prototype.autoProcessOverlap = function (name, value, labelGroup, limitLength) { - var _this = this; - var isVertical = this.isVertical(); - var hasAdjusted = false; - var util = _overlap__WEBPACK_IMPORTED_MODULE_4__[name]; - if (value === true) { - // 默认使用固定角度的旋转方案 - hasAdjusted = util.getDefault()(isVertical, labelGroup, limitLength); - } - else if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["isFunction"])(value)) { - // 用户可以传入回调函数 - hasAdjusted = value(isVertical, labelGroup, limitLength); - } - else if (util[value]) { - // 按照名称执行旋转函数 - hasAdjusted = util[value](isVertical, labelGroup, limitLength); - } - if (name === 'autoRotate') { - // 文本旋转后,文本的对齐方式可能就不合适了 - if (hasAdjusted) { - var labels = labelGroup.getChildren(); - var verticalFactor_1 = this.get('verticalFactor'); - Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["each"])(labels, function (label) { - var textAlign = label.attr('textAlign'); - if (textAlign === 'center') { - // 居中的文本需要调整旋转度 - var newAlign = verticalFactor_1 > 0 ? 'end' : 'start'; - label.attr('textAlign', newAlign); - } - }); - } - } - else if (name === 'autoHide') { - var children = labelGroup.getChildren().slice(0); // 复制数组,删除时不会出错 - Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["each"])(children, function (label) { - if (!label.get('visible')) { - if (_this.get('isRegister')) { - // 已经注册过了,则删除 - _this.unregisterElement(label); - } - label.remove(); // 防止 label 数量太多,所以统一删除 - } - }); - } - }; - return Line; -}(_base__WEBPACK_IMPORTED_MODULE_3__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (Line); -//# sourceMappingURL=line.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/axis/overlap/auto-ellipsis.js": -/*!************************************************************************!*\ - !*** ./node_modules/@antv/component/esm/axis/overlap/auto-ellipsis.js ***! - \************************************************************************/ -/*! exports provided: getDefault, ellipsisHead, ellipsisTail, ellipsisMiddle */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getDefault", function() { return getDefault; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ellipsisHead", function() { return ellipsisHead; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ellipsisTail", function() { return ellipsisTail; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ellipsisMiddle", function() { return ellipsisMiddle; }); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); - -var ELLIPSIS_CODE = '\u2026'; -var ELLIPSIS_CODE_LENGTH = 2; // 省略号的长度 -function strLen(str) { - var len = 0; - for (var i = 0; i < str.length; i++) { - len += charAtLength(str, i); - } - return len; -} -function charAtLength(str, i) { - if (str.charCodeAt(i) > 0 && str.charCodeAt(i) < 128) { - return 1; - } - else { - return 2; - } -} -function getLabelLength(isVertical, label) { - var bbox = label.getCanvasBBox(); - return isVertical ? bbox.width : bbox.height; -} -function ellipsisLabel(isVertical, label, limitLength, position) { - var text = label.attr('text'); - var labelLength = getLabelLength(isVertical, label); - var codeLength = strLen(text); - var ellipsised = false; - if (limitLength < labelLength) { - var reseveLength = Math.floor((limitLength / labelLength) * codeLength) - ELLIPSIS_CODE_LENGTH; // 计算出来的应该保存的长度 - var newText = void 0; - if (reseveLength >= 0) { - newText = ellipsisString(text, reseveLength, position); - } - else { - newText = ELLIPSIS_CODE; - } - if (newText) { - label.attr('text', newText); - ellipsised = true; - } - } - if (ellipsised) { - label.set('tip', text); - } - else { - label.set('tip', null); - } - return ellipsised; -} -function ellipsisString(str, reseveLength, position) { - var count = str.length; - var rst = ''; - if (position === 'tail') { - for (var i = 0, index = 0; i < reseveLength;) { - var charLength = charAtLength(str, index); - if (i + charLength <= reseveLength) { - rst += str[index]; - i += charAtLength(str, index); - index++; - } - else { - break; - } - } - rst += ELLIPSIS_CODE; - } - else if (position === 'head') { - for (var i = 0, index = count - 1; i < reseveLength;) { - var charLength = charAtLength(str, index); - if (i + charLength <= reseveLength) { - rst += str[index]; - i += charAtLength(str, index); - index--; - } - else { - break; - } - } - rst = ELLIPSIS_CODE + rst; - } - else { - var startStr = ''; - var endStr = ''; - for (var i = 0, startIndex = 0, endIndex = count - 1; i < reseveLength;) { - var startCodeLen = charAtLength(str, startIndex); - var hasAdd = false; // 设置标志位,防止头尾都没有附加字符 - if (startCodeLen + i <= reseveLength) { - startStr += str[startIndex]; - startIndex++; - i += startCodeLen; - hasAdd = true; - } - var endCodeLen = charAtLength(str, endIndex); - if (endCodeLen + i <= reseveLength) { - endStr = str[endIndex] + endStr; - i += endCodeLen; - endIndex--; - hasAdd = true; - } - if (!hasAdd) { - // 如果都没有增加字符,说明都不适合则中断 - break; - } - } - rst = startStr + ELLIPSIS_CODE + endStr; - } - return rst; -} -function ellipseLabels(isVertical, labelGroup, limitLength, position) { - var children = labelGroup.getChildren(); - var ellipsised = false; - Object(_antv_util__WEBPACK_IMPORTED_MODULE_0__["each"])(children, function (label) { - var rst = ellipsisLabel(isVertical, label, limitLength, position); - ellipsised = ellipsised || rst; - }); - return ellipsised; -} -function getDefault() { - return ellipsisTail; -} -function ellipsisHead(isVertical, labelGroup, limitLength) { - return ellipseLabels(isVertical, labelGroup, limitLength, 'head'); -} -function ellipsisTail(isVertical, labelGroup, limitLength) { - return ellipseLabels(isVertical, labelGroup, limitLength, 'tail'); -} -function ellipsisMiddle(isVertical, labelGroup, limitLength) { - return ellipseLabels(isVertical, labelGroup, limitLength, 'middle'); -} -//# sourceMappingURL=auto-ellipsis.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/axis/overlap/auto-hide.js": -/*!********************************************************************!*\ - !*** ./node_modules/@antv/component/esm/axis/overlap/auto-hide.js ***! - \********************************************************************/ -/*! exports provided: getDefault, reserveFirst, reserveLast, reserveBoth, equidistance */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getDefault", function() { return getDefault; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reserveFirst", function() { return reserveFirst; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reserveLast", function() { return reserveLast; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reserveBoth", function() { return reserveBoth; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equidistance", function() { return equidistance; }); -/* harmony import */ var _util_label__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../util/label */ "./node_modules/@antv/component/esm/util/label.js"); - -// 文本是否旋转 -function isRotate(label) { - var matrix = label.attr('matrix'); - return matrix && matrix[0] !== 1; // 仅在这个场景下判定 -} -// autohide 不再考虑超出限制 -// function isOutLimit(isVertical: boolean, label: IElement, limitLength: number) { -// if (!limitLength) { -// // 如果没限制 limitLength 则直接返回 false -// return false; -// } -// const canvasBBox = label.getCanvasBBox(); -// let isOut = false; -// if (isVertical) { -// isOut = canvasBBox.width > limitLength; -// } else { -// isOut = canvasBBox.height > limitLength; -// } -// return isOut; -// } -// 是否重叠 -function isOverlap(isVertical, rotated, preBox, curBox, reversed) { - if (reversed === void 0) { reversed = false; } - var overlap = false; - if (isVertical) { - // 垂直时检测边高 - overlap = Math.abs(preBox.y - curBox.y) < preBox.height; - } - else { - // 水平时检测 - if (rotated) { - // 如果旋转了,则检测两者 x 之间的间距是否小于前一个的高度 - var height = reversed ? curBox.height : preBox.height; - overlap = Math.abs(preBox.x - curBox.x) < height; - } - else { - // 检测两者是否 x 方向重合 - var width = reversed ? curBox.width : preBox.width; - overlap = Math.abs(preBox.x - curBox.x) < width; - } - } - return overlap; -} -// 保留第一个或者最后一个 -function reserveOne(isVertical, labelsGroup, reversed) { - var labels = labelsGroup.getChildren().slice(); // 复制数组 - if (!labels.length) { - return false; - } - var hasHide = false; - if (reversed) { - // 翻转 - labels.reverse(); - } - var count = labels.length; - var first = labels[0]; - var rotated = isRotate(first); - var preBox = first.getBBox(); - for (var i = 1; i < count; i++) { - var label = labels[i]; - var curBBox = label.getBBox(); - // 不再考虑超出限制,而仅仅根据是否重叠进行隐藏 isOutLimit(isVertical, label, limitLength) || - var isHide = isOverlap(isVertical, rotated, preBox, curBBox, reversed); - if (isHide) { - label.hide(); - hasHide = true; - } - else { - preBox = curBBox; - } - } - return hasHide; -} -function getDefault() { - return equidistance; -} -/** - * 保证首个 label 可见,即使超过 limitLength 也不隐藏 - * @param {boolean} isVertical 是否垂直 - * @param {IGroup} labelsGroup label 的分组 - */ -function reserveFirst(isVertical, labelsGroup) { - return reserveOne(isVertical, labelsGroup, false); -} -/** - * 保证最后一个 label 可见,即使超过 limitLength 也不隐藏 - * @param {boolean} isVertical 是否垂直 - * @param {IGroup} labelsGroup label 的分组 - */ -function reserveLast(isVertical, labelsGroup) { - return reserveOne(isVertical, labelsGroup, true); -} -/** - * 保证第一个最后一个 label 可见,即使超过 limitLength 也不隐藏 - * @param {boolean} isVertical 是否垂直 - * @param {IGroup} labelsGroup label 的分组 - */ -function reserveBoth(isVertical, labelsGroup) { - var labels = labelsGroup.getChildren().slice(); // 复制数组 - if (labels.length <= 2) { - // 如果数量小于或等于 2 则直接返回 - return false; - } - var hasHide = false; - var count = labels.length; - var first = labels[0]; - var last = labels[count - 1]; - var rotated = isRotate(first); - var preBox = first.getBBox(); - var preLabel = first; - // 按照先保存第一个的逻辑循环一遍,最后一个不参与循环 - for (var i = 1; i < count - 1; i++) { - var label = labels[i]; - var curBBox = label.getBBox(); - // 废弃 isOutLimit(isVertical, label, limitLength) || - var isHide = isOverlap(isVertical, rotated, preBox, curBBox); - if (isHide) { - label.hide(); - hasHide = true; - } - else { - preBox = curBBox; - preLabel = label; - } - } - var lastBBox = last.getBBox(); - var overlap = isOverlap(isVertical, rotated, preBox, lastBBox); // 不检测超出 limit - if (overlap) { - // 发生冲突,则隐藏前一个保留后一个 - preLabel.hide(); - hasHide = true; - } - return hasHide; -} -/** - * 保证 label 均匀显示,主要解决文本层叠的问题,对于 limitLength 不处理 - * @param {boolean} isVertical 是否垂直 - * @param {IGroup} labelsGroup label 的分组 - */ -function equidistance(isVertical, labelsGroup) { - var labels = labelsGroup.getChildren().slice(); // 复制数组 - if (labels.length < 2) { - // 如果数量小于 2 则直接返回,等于 2 时可能也会重合 - return false; - } - var hasHide = false; - var first = labels[0]; - var firstBBox = first.getBBox(); - var second = labels[1]; - var rotated = isRotate(first); - var count = labels.length; - var interval = 0; // 不重叠的坐标文本间距个数 - if (isVertical) { - // 垂直的坐标轴计算垂直方向的间距 - var distance = Math.abs(second.attr('y') - first.attr('y')); - interval = firstBBox.height / distance; - } - else { - // 水平坐标轴 - if (rotated) { - var distance = Math.abs(second.attr('x') - first.attr('x')); - interval = firstBBox.width / distance; - } - else { - var maxWidth = Object(_util_label__WEBPACK_IMPORTED_MODULE_0__["getMaxLabelWidth"])(labels); - var distance = Math.abs(second.attr('x') - first.attr('x')); - interval = maxWidth / distance; - } - } - // interval > 1 时需要对 label 进行隐藏 - if (interval > 1) { - interval = Math.ceil(interval); - for (var i = 0; i < count; i++) { - if (i % interval !== 0) { - // 仅保留被整除的 label - labels[i].hide(); - hasHide = true; - } - } - } - return hasHide; -} -//# sourceMappingURL=auto-hide.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/axis/overlap/auto-rotate.js": -/*!**********************************************************************!*\ - !*** ./node_modules/@antv/component/esm/axis/overlap/auto-rotate.js ***! - \**********************************************************************/ -/*! exports provided: getDefault, fixedAngle, unfixedAngle */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getDefault", function() { return getDefault; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fixedAngle", function() { return fixedAngle; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "unfixedAngle", function() { return unfixedAngle; }); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); -/* harmony import */ var _util_label__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../util/label */ "./node_modules/@antv/component/esm/util/label.js"); -/* harmony import */ var _util_matrix__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../util/matrix */ "./node_modules/@antv/component/esm/util/matrix.js"); -/* harmony import */ var _util_theme__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../util/theme */ "./node_modules/@antv/component/esm/util/theme.js"); - - - - -// 统一设置文本的角度 -function setLabelsAngle(labels, angle) { - Object(_antv_util__WEBPACK_IMPORTED_MODULE_0__["each"])(labels, function (label) { - var x = label.attr('x'); - var y = label.attr('y'); - var matrix = Object(_util_matrix__WEBPACK_IMPORTED_MODULE_2__["getMatrixByAngle"])({ x: x, y: y }, angle); - label.attr('matrix', matrix); - }); -} -// 旋转文本 -function labelRotate(isVertical, labelsGroup, limitLength, getAngle) { - var labels = labelsGroup.getChildren(); - if (!labels.length) { - return false; - } - if (!isVertical && labels.length < 2) { - // 水平时至少有两个时才旋转 - return false; - } - var maxWidth = Object(_util_label__WEBPACK_IMPORTED_MODULE_1__["getMaxLabelWidth"])(labels); - var isOverlap = false; - if (isVertical) { - // limitLength 为 0 或者 null 时不生效 - isOverlap = !!limitLength && maxWidth > limitLength; - } - else { - // 同 limitLength 无关 - var tickWidth = Math.abs(labels[1].attr('x') - labels[0].attr('x')); - isOverlap = maxWidth > tickWidth; - } - if (isOverlap) { - var angle = getAngle(limitLength, maxWidth); - setLabelsAngle(labels, angle); - } - return isOverlap; -} -function getDefault() { - return fixedAngle; -} -/** - * 固定角度旋转文本 - * @param {boolean} isVertical 是否垂直方向 - * @param {IGroup} labelsGroup 文本的 group - * @param {number} limitLength 限定长度 - * @return {boolean} 是否发生了旋转 - */ -function fixedAngle(isVertical, labelsGroup, limitLength) { - return labelRotate(isVertical, labelsGroup, limitLength, function () { - return isVertical ? _util_theme__WEBPACK_IMPORTED_MODULE_3__["default"].verticalAxisRotate : _util_theme__WEBPACK_IMPORTED_MODULE_3__["default"].horizontalAxisRotate; - }); -} -/** - * 非固定角度旋转文本 - * @param {boolean} isVertical 是否垂直方向 - * @param {IGroup} labelsGroup 文本的 group - * @param {number} limitLength 限定长度 - * @return {boolean} 是否发生了旋转 - */ -function unfixedAngle(isVertical, labelsGroup, limitLength) { - return labelRotate(isVertical, labelsGroup, limitLength, function (length, maxWidth) { - if (!length) { - // 如果没有设置 limitLength,则使用固定的角度旋转 - return isVertical ? _util_theme__WEBPACK_IMPORTED_MODULE_3__["default"].verticalAxisRotate : _util_theme__WEBPACK_IMPORTED_MODULE_3__["default"].horizontalAxisRotate; - } - if (isVertical) { - // 垂直时不需要判定 limitLength > maxWidth ,因为此时不会 overlap - return -Math.acos(length / maxWidth); - } - else { - var angle = 0; - if (length > maxWidth) { - // 需要判定,asin 的参数 -1, 1 - angle = Math.PI / 4; - } - else { - angle = Math.asin(length / maxWidth); - if (angle > Math.PI / 4) { - // 大于 Math.PI / 4 时没意义 - angle = Math.PI / 4; - } - } - return angle; - } - }); -} -//# sourceMappingURL=auto-rotate.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/axis/overlap/index.js": -/*!****************************************************************!*\ - !*** ./node_modules/@antv/component/esm/axis/overlap/index.js ***! - \****************************************************************/ -/*! exports provided: autoHide, autoRotate, autoEllipsis */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _auto_ellipsis__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./auto-ellipsis */ "./node_modules/@antv/component/esm/axis/overlap/auto-ellipsis.js"); -/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "autoEllipsis", function() { return _auto_ellipsis__WEBPACK_IMPORTED_MODULE_0__; }); -/* harmony import */ var _auto_hide__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./auto-hide */ "./node_modules/@antv/component/esm/axis/overlap/auto-hide.js"); -/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "autoHide", function() { return _auto_hide__WEBPACK_IMPORTED_MODULE_1__; }); -/* harmony import */ var _auto_rotate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./auto-rotate */ "./node_modules/@antv/component/esm/axis/overlap/auto-rotate.js"); -/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "autoRotate", function() { return _auto_rotate__WEBPACK_IMPORTED_MODULE_2__; }); - - - - -//# sourceMappingURL=index.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/crosshair/base.js": -/*!************************************************************!*\ - !*** ./node_modules/@antv/component/esm/crosshair/base.js ***! - \************************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); -/* harmony import */ var _abstract_group_component__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstract/group-component */ "./node_modules/@antv/component/esm/abstract/group-component.js"); -/* harmony import */ var _util_matrix__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/matrix */ "./node_modules/@antv/component/esm/util/matrix.js"); -/* harmony import */ var _util_theme__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../util/theme */ "./node_modules/@antv/component/esm/util/theme.js"); -/* harmony import */ var _util_util__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util/util */ "./node_modules/@antv/component/esm/util/util.js"); - - - - - - -var CrosshairBase = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(CrosshairBase, _super); - function CrosshairBase() { - return _super !== null && _super.apply(this, arguments) || this; - } - CrosshairBase.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { name: 'crosshair', type: 'base', line: {}, text: null, textBackground: {}, capture: false, defaultCfg: { - line: { - style: { - lineWidth: 1, - stroke: _util_theme__WEBPACK_IMPORTED_MODULE_4__["default"].lineColor, - }, - }, - text: { - position: 'start', - offset: 10, - autoRotate: false, - content: null, - style: { - fill: _util_theme__WEBPACK_IMPORTED_MODULE_4__["default"].textColor, - textAlign: 'center', - textBaseline: 'middle', - fontFamily: _util_theme__WEBPACK_IMPORTED_MODULE_4__["default"].fontFamily, - }, - }, - textBackground: { - padding: 5, - style: { - stroke: _util_theme__WEBPACK_IMPORTED_MODULE_4__["default"].lineColor, - }, - }, - } }); - }; - CrosshairBase.prototype.renderInner = function (group) { - if (this.get('line')) { - this.renderLine(group); - } - if (this.get('text')) { - this.renderText(group); - this.renderBackground(group); - } - }; - CrosshairBase.prototype.renderText = function (group) { - var text = this.get('text'); - var style = text.style, autoRotate = text.autoRotate, content = text.content; - if (!Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["isNil"])(content)) { - var textPoint = this.getTextPoint(); - var matrix = null; - if (autoRotate) { - var angle = this.getRotateAngle(); - matrix = Object(_util_matrix__WEBPACK_IMPORTED_MODULE_3__["getMatrixByAngle"])(textPoint, angle); - } - this.addShape(group, { - type: 'text', - name: 'crosshair-text', - id: this.getElementId('text'), - attrs: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, textPoint), { text: content, matrix: matrix }), style), - }); - } - }; - CrosshairBase.prototype.renderLine = function (group) { - var path = this.getLinePath(); - var line = this.get('line'); - var style = line.style; - this.addShape(group, { - type: 'path', - name: 'crosshair-line', - id: this.getElementId('line'), - attrs: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ path: path }, style), - }); - }; - // 绘制文本的背景 - CrosshairBase.prototype.renderBackground = function (group) { - var textId = this.getElementId('text'); - var textShape = group.findById(textId); // 查找文本 - var textBackground = this.get('textBackground'); - if (textBackground && textShape) { - var textBBox = textShape.getBBox(); - var padding = Object(_util_util__WEBPACK_IMPORTED_MODULE_5__["formatPadding"])(textBackground.padding); // 用户传入的 padding 格式不定 - var style = textBackground.style; - var backgroundShape = this.addShape(group, { - type: 'rect', - name: 'crosshair-text-background', - id: this.getElementId('text-background'), - attrs: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ x: textBBox.x - padding[3], y: textBBox.y - padding[0], width: textBBox.width + padding[1] + padding[3], height: textBBox.height + padding[0] + padding[2], matrix: textShape.attr('matrix') }, style), - }); - backgroundShape.toBack(); - } - }; - return CrosshairBase; -}(_abstract_group_component__WEBPACK_IMPORTED_MODULE_2__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (CrosshairBase); -//# sourceMappingURL=base.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/crosshair/circle.js": -/*!**************************************************************!*\ - !*** ./node_modules/@antv/component/esm/crosshair/circle.js ***! - \**************************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _util_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/util */ "./node_modules/@antv/component/esm/util/util.js"); -/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base */ "./node_modules/@antv/component/esm/crosshair/base.js"); - - - -var LineCrosshair = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(LineCrosshair, _super); - function LineCrosshair() { - return _super !== null && _super.apply(this, arguments) || this; - } - LineCrosshair.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { type: 'circle', locationType: 'circle', center: null, radius: 100, startAngle: -Math.PI / 2, endAngle: (Math.PI * 3) / 2 }); - }; - LineCrosshair.prototype.getRotateAngle = function () { - var _a = this.getLocation(), startAngle = _a.startAngle, endAngle = _a.endAngle; - var position = this.get('text').position; - var tangentAngle = position === 'start' ? startAngle + Math.PI / 2 : endAngle - Math.PI / 2; - return tangentAngle; - }; - LineCrosshair.prototype.getTextPoint = function () { - var text = this.get('text'); - var position = text.position, offset = text.offset; - var _a = this.getLocation(), center = _a.center, radius = _a.radius, startAngle = _a.startAngle, endAngle = _a.endAngle; - var angle = position === 'start' ? startAngle : endAngle; - var tangentAngle = this.getRotateAngle() - Math.PI; - var point = Object(_util_util__WEBPACK_IMPORTED_MODULE_1__["getCirclePoint"])(center, radius, angle); - // 这个地方其实应该求切线向量然后在乘以 offset,但是太啰嗦了,直接给出结果 - // const tangent = [Math.cos(tangentAngle), Math.sin(tangentAngle)]; - // const offsetVector = vec2.scale([], tangent, offset); - var offsetX = Math.cos(tangentAngle) * offset; - var offsetY = Math.sin(tangentAngle) * offset; - return { - x: point.x + offsetX, - y: point.y + offsetY, - }; - }; - LineCrosshair.prototype.getLinePath = function () { - var _a = this.getLocation(), center = _a.center, radius = _a.radius, startAngle = _a.startAngle, endAngle = _a.endAngle; - var path = null; - if (endAngle - startAngle === Math.PI * 2) { - // 整圆 - var x = center.x, y = center.y; - path = [ - ['M', x, y - radius], - ['A', radius, radius, 0, 1, 1, x, y + radius], - ['A', radius, radius, 0, 1, 1, x, y - radius], - ['Z'], - ]; - } - else { - var startPoint = Object(_util_util__WEBPACK_IMPORTED_MODULE_1__["getCirclePoint"])(center, radius, startAngle); - var endPoint = Object(_util_util__WEBPACK_IMPORTED_MODULE_1__["getCirclePoint"])(center, radius, endAngle); - var large = Math.abs(endAngle - startAngle) > Math.PI ? 1 : 0; - var sweep = startAngle > endAngle ? 0 : 1; - path = [ - ['M', startPoint.x, startPoint.y], - ['A', radius, radius, 0, large, sweep, endPoint.x, endPoint.y], - ]; - } - return path; - }; - return LineCrosshair; -}(_base__WEBPACK_IMPORTED_MODULE_2__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (LineCrosshair); -//# sourceMappingURL=circle.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/crosshair/index.js": -/*!*************************************************************!*\ - !*** ./node_modules/@antv/component/esm/crosshair/index.js ***! - \*************************************************************/ -/*! exports provided: Line, Circle, Base */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./line */ "./node_modules/@antv/component/esm/crosshair/line.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_0__["default"]; }); - -/* harmony import */ var _circle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./circle */ "./node_modules/@antv/component/esm/crosshair/circle.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Circle", function() { return _circle__WEBPACK_IMPORTED_MODULE_1__["default"]; }); - -/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base */ "./node_modules/@antv/component/esm/crosshair/base.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Base", function() { return _base__WEBPACK_IMPORTED_MODULE_2__["default"]; }); - - - - -//# sourceMappingURL=index.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/crosshair/line.js": -/*!************************************************************!*\ - !*** ./node_modules/@antv/component/esm/crosshair/line.js ***! - \************************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _util_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../util/util */ "./node_modules/@antv/component/esm/util/util.js"); -/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base */ "./node_modules/@antv/component/esm/crosshair/base.js"); - - - -var LineCrosshair = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(LineCrosshair, _super); - function LineCrosshair() { - return _super !== null && _super.apply(this, arguments) || this; - } - LineCrosshair.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { type: 'line', locationType: 'region', start: null, end: null }); - }; - // 直线的文本需要同直线垂直 - LineCrosshair.prototype.getRotateAngle = function () { - var _a = this.getLocation(), start = _a.start, end = _a.end; - var position = this.get('text').position; - var angle = Math.atan2(end.y - start.y, end.x - start.x); - var tangentAngle = position === 'start' ? angle - Math.PI / 2 : angle + Math.PI / 2; - return tangentAngle; - }; - LineCrosshair.prototype.getTextPoint = function () { - var _a = this.getLocation(), start = _a.start, end = _a.end; - var text = this.get('text'); - var position = text.position, offset = text.offset; - var lineLength = Object(_util_util__WEBPACK_IMPORTED_MODULE_1__["distance"])(start, end); - var offsetPercent = offset / lineLength; // 计算间距同线的比例,用于计算最终的位置 - var percent = 0; - if (position === 'start') { - percent = 0 - offsetPercent; - } - else if (position === 'end') { - percent = 1 + offsetPercent; - } - return { - x: Object(_util_util__WEBPACK_IMPORTED_MODULE_1__["getValueByPercent"])(start.x, end.x, percent), - y: Object(_util_util__WEBPACK_IMPORTED_MODULE_1__["getValueByPercent"])(start.y, end.y, percent), - }; - }; - LineCrosshair.prototype.getLinePath = function () { - var _a = this.getLocation(), start = _a.start, end = _a.end; - return [ - ['M', start.x, start.y], - ['L', end.x, end.y], - ]; - }; - return LineCrosshair; -}(_base__WEBPACK_IMPORTED_MODULE_2__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (LineCrosshair); -//# sourceMappingURL=line.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/grid/base.js": -/*!*******************************************************!*\ - !*** ./node_modules/@antv/component/esm/grid/base.js ***! - \*******************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); -/* harmony import */ var _abstract_group_component__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstract/group-component */ "./node_modules/@antv/component/esm/abstract/group-component.js"); -/* harmony import */ var _util_theme__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/theme */ "./node_modules/@antv/component/esm/util/theme.js"); - - - - -var GridBase = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(GridBase, _super); - function GridBase() { - return _super !== null && _super.apply(this, arguments) || this; - } - GridBase.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { name: 'grid', line: {}, alternateColor: null, capture: false, items: [], closed: false, defaultCfg: { - line: { - type: 'line', - style: { - lineWidth: 1, - stroke: _util_theme__WEBPACK_IMPORTED_MODULE_3__["default"].lineColor, - }, - }, - } }); - }; - /** - * 获取栅格线的类型 - * @return {string} 栅格线类型 - */ - GridBase.prototype.getLineType = function () { - var line = this.get('line') || this.get('defaultCfg').line; - return line.type; - }; - GridBase.prototype.renderInner = function (group) { - this.drawGrid(group); - }; - GridBase.prototype.getAlternatePath = function (prePoints, points) { - var regionPath = this.getGridPath(prePoints); - var reversePoints = points.slice(0).reverse(); - var nextPath = this.getGridPath(reversePoints, true); - var closed = this.get('closed'); - if (closed) { - regionPath = regionPath.concat(nextPath); - } - else { - nextPath[0][0] = 'L'; // 更新第一个节点 - regionPath = regionPath.concat(nextPath); - regionPath.push(['Z']); - } - return regionPath; - }; - // 获取路径的配置项 - GridBase.prototype.getPathStyle = function () { - return this.get('line').style; - }; - // 绘制栅格 - GridBase.prototype.drawGrid = function (group) { - var _this = this; - var line = this.get('line'); - var items = this.get('items'); - var alternateColor = this.get('alternateColor'); - var preItem = null; - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(items, function (item, index) { - var id = item.id || index; - // 绘制栅格线 - if (line) { - var style = _this.getPathStyle(); - var lineId = _this.getElementId("line-" + id); - var gridPath = _this.getGridPath(item.points); - _this.addShape(group, { - type: 'path', - name: 'grid-line', - id: lineId, - attrs: Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["mix"])({ - path: gridPath, - }, style), - }); - } - // 如果存在 alternateColor 则绘制矩形 - // 从第二个栅格线开始绘制 - if (alternateColor && index > 0) { - var regionId = _this.getElementId("region-" + id); - var isEven = index % 2 === 0; - if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["isString"])(alternateColor)) { - // 如果颜色是单值,则是仅绘制偶数时的区域 - if (isEven) { - _this.drawAlternateRegion(regionId, group, preItem.points, item.points, alternateColor); - } - } - else { - var color = isEven ? alternateColor[1] : alternateColor[0]; - _this.drawAlternateRegion(regionId, group, preItem.points, item.points, color); - } - } - preItem = item; - }); - }; - // 绘制栅格线间的间隔 - GridBase.prototype.drawAlternateRegion = function (id, group, prePoints, points, color) { - var regionPath = this.getAlternatePath(prePoints, points); - this.addShape(group, { - type: 'path', - id: id, - name: 'grid-region', - attrs: { - path: regionPath, - fill: color, - }, - }); - }; - return GridBase; -}(_abstract_group_component__WEBPACK_IMPORTED_MODULE_2__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (GridBase); -//# sourceMappingURL=base.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/grid/circle.js": -/*!*********************************************************!*\ - !*** ./node_modules/@antv/component/esm/grid/circle.js ***! - \*********************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); -/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base */ "./node_modules/@antv/component/esm/grid/base.js"); - - - -function distance(x1, y1, x2, y2) { - var dx = x2 - x1; - var dy = y2 - y1; - return Math.sqrt(dx * dx + dy * dy); -} -var Circle = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Circle, _super); - function Circle() { - return _super !== null && _super.apply(this, arguments) || this; - } - Circle.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { type: 'circle', - /** - * 中心点 - * @type {object} - */ - center: null, - /** - * 栅格线是否封闭 - * @type {true} - */ - closed: true }); - }; - Circle.prototype.getGridPath = function (points, reversed) { - var lineType = this.getLineType(); - var closed = this.get('closed'); - var path = []; - if (points.length) { - // 防止出错 - if (lineType === 'circle') { - var center = this.get('center'); - var firstPoint = points[0]; - var radius_1 = distance(center.x, center.y, firstPoint.x, firstPoint.y); - var sweepFlag_1 = reversed ? 0 : 1; // 顺时针还是逆时针 - if (closed) { - // 封闭时,绘制整个圆 - path.push(['M', center.x, center.y - radius_1]); - path.push(['A', radius_1, radius_1, 0, 0, sweepFlag_1, center.x, center.y + radius_1]); - path.push(['A', radius_1, radius_1, 0, 0, sweepFlag_1, center.x, center.y - radius_1]); - path.push(['Z']); - } - else { - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(points, function (point, index) { - if (index === 0) { - path.push(['M', point.x, point.y]); - } - else { - path.push(['A', radius_1, radius_1, 0, 0, sweepFlag_1, point.x, point.y]); - } - }); - } - } - else { - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(points, function (point, index) { - if (index === 0) { - path.push(['M', point.x, point.y]); - } - else { - path.push(['L', point.x, point.y]); - } - }); - if (closed) { - path.push(['Z']); - } - } - } - return path; - }; - return Circle; -}(_base__WEBPACK_IMPORTED_MODULE_2__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (Circle); -//# sourceMappingURL=circle.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/grid/index.js": -/*!********************************************************!*\ - !*** ./node_modules/@antv/component/esm/grid/index.js ***! - \********************************************************/ -/*! exports provided: Base, Circle, Line */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./base */ "./node_modules/@antv/component/esm/grid/base.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Base", function() { return _base__WEBPACK_IMPORTED_MODULE_0__["default"]; }); - -/* harmony import */ var _circle__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./circle */ "./node_modules/@antv/component/esm/grid/circle.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Circle", function() { return _circle__WEBPACK_IMPORTED_MODULE_1__["default"]; }); - -/* harmony import */ var _line__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./line */ "./node_modules/@antv/component/esm/grid/line.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Line", function() { return _line__WEBPACK_IMPORTED_MODULE_2__["default"]; }); - - - - -//# sourceMappingURL=index.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/grid/line.js": -/*!*******************************************************!*\ - !*** ./node_modules/@antv/component/esm/grid/line.js ***! - \*******************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); -/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base */ "./node_modules/@antv/component/esm/grid/base.js"); - - - -var Line = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Line, _super); - function Line() { - return _super !== null && _super.apply(this, arguments) || this; - } - Line.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { type: 'line' }); - }; - Line.prototype.getGridPath = function (points) { - var path = []; - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(points, function (point, index) { - if (index === 0) { - path.push(['M', point.x, point.y]); - } - else { - path.push(['L', point.x, point.y]); - } - }); - return path; - }; - return Line; -}(_base__WEBPACK_IMPORTED_MODULE_2__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (Line); -//# sourceMappingURL=line.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/index.js": -/*!***************************************************!*\ - !*** ./node_modules/@antv/component/esm/index.js ***! - \***************************************************/ -/*! exports provided: Component, GroupComponent, HtmlComponent, Axis, Annotation, Grid, Legend, Tooltip, Crosshair, Slider, Scrollbar */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _annotation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./annotation */ "./node_modules/@antv/component/esm/annotation/index.js"); -/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "Annotation", function() { return _annotation__WEBPACK_IMPORTED_MODULE_0__; }); -/* harmony import */ var _axis__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axis */ "./node_modules/@antv/component/esm/axis/index.js"); -/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _axis__WEBPACK_IMPORTED_MODULE_1__; }); -/* harmony import */ var _crosshair__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./crosshair */ "./node_modules/@antv/component/esm/crosshair/index.js"); -/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "Crosshair", function() { return _crosshair__WEBPACK_IMPORTED_MODULE_2__; }); -/* harmony import */ var _grid__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./grid */ "./node_modules/@antv/component/esm/grid/index.js"); -/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "Grid", function() { return _grid__WEBPACK_IMPORTED_MODULE_3__; }); -/* harmony import */ var _legend__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./legend */ "./node_modules/@antv/component/esm/legend/index.js"); -/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "Legend", function() { return _legend__WEBPACK_IMPORTED_MODULE_4__; }); -/* harmony import */ var _tooltip__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tooltip */ "./node_modules/@antv/component/esm/tooltip/index.js"); -/* harmony reexport (module object) */ __webpack_require__.d(__webpack_exports__, "Tooltip", function() { return _tooltip__WEBPACK_IMPORTED_MODULE_5__; }); -/* harmony import */ var _abstract_component__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./abstract/component */ "./node_modules/@antv/component/esm/abstract/component.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Component", function() { return _abstract_component__WEBPACK_IMPORTED_MODULE_6__["default"]; }); - -/* harmony import */ var _abstract_group_component__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./abstract/group-component */ "./node_modules/@antv/component/esm/abstract/group-component.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroupComponent", function() { return _abstract_group_component__WEBPACK_IMPORTED_MODULE_7__["default"]; }); - -/* harmony import */ var _abstract_html_component__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./abstract/html-component */ "./node_modules/@antv/component/esm/abstract/html-component.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HtmlComponent", function() { return _abstract_html_component__WEBPACK_IMPORTED_MODULE_8__["default"]; }); - -/* harmony import */ var _slider__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./slider */ "./node_modules/@antv/component/esm/slider/index.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _slider__WEBPACK_IMPORTED_MODULE_9__["Slider"]; }); - -/* harmony import */ var _scrollbar__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./scrollbar */ "./node_modules/@antv/component/esm/scrollbar/index.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scrollbar", function() { return _scrollbar__WEBPACK_IMPORTED_MODULE_10__["Scrollbar"]; }); - - - - - - - - - - - - - -//# sourceMappingURL=index.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/legend/base.js": -/*!*********************************************************!*\ - !*** ./node_modules/@antv/component/esm/legend/base.js ***! - \*********************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _abstract_group_component__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../abstract/group-component */ "./node_modules/@antv/component/esm/abstract/group-component.js"); -/* harmony import */ var _util_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/util */ "./node_modules/@antv/component/esm/util/util.js"); - - - -var LegendBase = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(LegendBase, _super); - function LegendBase() { - return _super !== null && _super.apply(this, arguments) || this; - } - LegendBase.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { name: 'legend', - /** - * 布局方式: horizontal,vertical - * @type {String} - */ - layout: 'horizontal', locationType: 'point', x: 0, y: 0, offsetX: 0, offsetY: 0, title: null, background: null }); - }; - LegendBase.prototype.getLayoutBBox = function () { - var bbox = _super.prototype.getLayoutBBox.call(this); - var x = this.get('x'); - var y = this.get('y'); - var offsetX = this.get('offsetX'); - var offsetY = this.get('offsetY'); - var maxWidth = this.get('maxWidth'); - var maxHeight = this.get('maxHeight'); - var minX = x + offsetX; - var minY = y + offsetY; - var width = bbox.maxX - minX; - var height = bbox.maxY - minY; - if (maxWidth) { - width = Math.min(width, maxWidth); - } - if (maxHeight) { - height = Math.min(height, maxHeight); - } - return Object(_util_util__WEBPACK_IMPORTED_MODULE_2__["createBBox"])(minX, minY, width, height); - }; - LegendBase.prototype.setLocation = function (cfg) { - this.set('x', cfg.x); - this.set('y', cfg.y); - this.resetLocation(); - }; - LegendBase.prototype.resetLocation = function () { - var x = this.get('x'); - var y = this.get('y'); - var offsetX = this.get('offsetX'); - var offsetY = this.get('offsetY'); - this.moveElementTo(this.get('group'), { - x: x + offsetX, - y: y + offsetY, - }); - }; - LegendBase.prototype.applyOffset = function () { - this.resetLocation(); - }; - // 获取当前绘制的点 - LegendBase.prototype.getDrawPoint = function () { - return this.get('currentPoint'); - }; - LegendBase.prototype.setDrawPoint = function (point) { - return this.set('currentPoint', point); - }; - // 复写父类定义的绘制方法 - LegendBase.prototype.renderInner = function (group) { - this.resetDraw(); - if (this.get('title')) { - this.drawTitle(group); - } - this.drawLegendContent(group); - if (this.get('background')) { - this.drawBackground(group); - } - // this.resetLocation(); // 在顶层已经在处理偏移时一起处理了 - }; - // 绘制背景 - LegendBase.prototype.drawBackground = function (group) { - var background = this.get('background'); - var bbox = group.getBBox(); - var padding = Object(_util_util__WEBPACK_IMPORTED_MODULE_2__["formatPadding"])(background.padding); - var attrs = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ - // 背景从 (0,0) 开始绘制 - x: 0, y: 0, width: bbox.width + padding[1] + padding[3], height: bbox.height + padding[0] + padding[2] }, background.style); - var backgroundShape = this.addShape(group, { - type: 'rect', - id: this.getElementId('background'), - name: 'legend-background', - attrs: attrs, - }); - backgroundShape.toBack(); - }; - // 绘制标题,标题在图例项的上面 - LegendBase.prototype.drawTitle = function (group) { - var currentPoint = this.get('currentPoint'); - var titleCfg = this.get('title'); - var spacing = titleCfg.spacing, style = titleCfg.style, text = titleCfg.text; - var shape = this.addShape(group, { - type: 'text', - id: this.getElementId('title'), - name: 'legend-title', - attrs: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ text: text, x: currentPoint.x, y: currentPoint.y }, style), - }); - var bbox = shape.getBBox(); - // 标题单独在一行 - this.set('currentPoint', { x: currentPoint.x, y: bbox.maxY + spacing }); - }; - // 重置绘制时开始的位置,如果绘制边框,考虑边框的 padding - LegendBase.prototype.resetDraw = function () { - var background = this.get('background'); - var currentPoint = { x: 0, y: 0 }; - if (background) { - var padding = Object(_util_util__WEBPACK_IMPORTED_MODULE_2__["formatPadding"])(background.padding); - currentPoint.x = padding[3]; // 左边 padding - currentPoint.y = padding[0]; // 上面 padding - } - this.set('currentPoint', currentPoint); // 设置绘制的初始位置 - }; - return LegendBase; -}(_abstract_group_component__WEBPACK_IMPORTED_MODULE_1__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (LegendBase); -//# sourceMappingURL=base.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/legend/category.js": -/*!*************************************************************!*\ - !*** ./node_modules/@antv/component/esm/legend/category.js ***! - \*************************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); -/* harmony import */ var _util_matrix__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/matrix */ "./node_modules/@antv/component/esm/util/matrix.js"); -/* harmony import */ var _util_state__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/state */ "./node_modules/@antv/component/esm/util/state.js"); -/* harmony import */ var _util_theme__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../util/theme */ "./node_modules/@antv/component/esm/util/theme.js"); -/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./base */ "./node_modules/@antv/component/esm/legend/base.js"); - - - - - - -var Category = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Category, _super); - function Category() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.currentPageIndex = 1; - _this.totalPagesCnt = 1; - _this.pageWidth = 0; - _this.pageHeight = 0; - _this.startX = 0; - _this.startY = 0; - _this.onNavigationBack = function () { - var itemGroup = _this.getElementByLocalId('item-group'); - if (_this.currentPageIndex > 1) { - _this.currentPageIndex -= 1; - _this.updateNavigation(); - var matrix = _this.getCurrentNavigationMatrix(); - if (_this.get('animate')) { - itemGroup.animate({ - matrix: matrix, - }, 100); - } - else { - itemGroup.attr({ matrix: matrix }); - } - } - }; - _this.onNavigationAfter = function () { - var itemGroup = _this.getElementByLocalId('item-group'); - if (_this.currentPageIndex < _this.totalPagesCnt) { - _this.currentPageIndex += 1; - _this.updateNavigation(); - var matrix = _this.getCurrentNavigationMatrix(); - if (_this.get('animate')) { - itemGroup.animate({ - matrix: matrix, - }, 100); - } - else { - itemGroup.attr({ matrix: matrix }); - } - } - }; - return _this; - } - Category.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { name: 'legend', type: 'category', itemSpacing: 24, itemWidth: null, itemHeight: null, itemName: {}, itemValue: null, maxWidth: null, maxHeight: null, marker: {}, items: [], itemStates: {}, itemBackground: {}, defaultCfg: { - title: { - spacing: 5, - style: { - fill: _util_theme__WEBPACK_IMPORTED_MODULE_4__["default"].textColor, - fontSize: 12, - textAlign: 'start', - textBaseline: 'top', - }, - }, - background: { - padding: 5, - style: { - stroke: _util_theme__WEBPACK_IMPORTED_MODULE_4__["default"].lineColor, - }, - }, - itemBackground: { - style: { - opacity: 0, - fill: '#fff', - }, - }, - itemName: { - spacing: 16, - style: { - fill: _util_theme__WEBPACK_IMPORTED_MODULE_4__["default"].textColor, - fontSize: 12, - textAlign: 'start', - textBaseline: 'middle', - }, - }, - marker: { - spacing: 8, - style: { - r: 6, - symbol: 'circle', - }, - }, - itemValue: { - alignRight: false, - formatter: null, - style: { - fill: _util_theme__WEBPACK_IMPORTED_MODULE_4__["default"].textColor, - fontSize: 12, - textAlign: 'start', - textBaseline: 'middle', - }, - }, - itemStates: { - active: { - nameStyle: { - opacity: 0.8, - }, - }, - unchecked: { - nameStyle: { - fill: _util_theme__WEBPACK_IMPORTED_MODULE_4__["default"].uncheckedColor, - }, - markerStyle: { - fill: _util_theme__WEBPACK_IMPORTED_MODULE_4__["default"].uncheckedColor, - stroke: _util_theme__WEBPACK_IMPORTED_MODULE_4__["default"].uncheckedColor, - }, - }, - inactive: { - nameStyle: { - fill: _util_theme__WEBPACK_IMPORTED_MODULE_4__["default"].uncheckedColor, - }, - markerStyle: { - opacity: 0.2, - }, - }, - }, - } }); - }; - // 实现 IList 接口 - Category.prototype.isList = function () { - return true; - }; - /** - * 获取图例项 - * @return {ListItem[]} 列表项集合 - */ - Category.prototype.getItems = function () { - return this.get('items'); - }; - /** - * 设置列表项 - * @param {ListItem[]} items 列表项集合 - */ - Category.prototype.setItems = function (items) { - this.update({ - items: items, - }); - }; - /** - * 更新列表项 - * @param {ListItem} item 列表项 - * @param {object} cfg 列表项 - */ - Category.prototype.updateItem = function (item, cfg) { - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["mix"])(item, cfg); - this.clear(); // 由于单个图例项变化,会引起全局变化,所以全部更新 - this.render(); - }; - /** - * 清空列表 - */ - Category.prototype.clearItems = function () { - var itemGroup = this.getElementByLocalId('item-group'); - itemGroup && itemGroup.clear(); - }; - /** - * 设置列表项的状态 - * @param {ListItem} item 列表项 - * @param {string} state 状态名 - * @param {boolean} value 状态值, true, false - */ - Category.prototype.setItemState = function (item, state, value) { - item[state] = value; - var itemElement = this.getElementByLocalId("item-" + item.id); - if (itemElement) { - var items = this.getItems(); - var index = items.indexOf(item); - var offsetGroup = this.createOffScreenGroup(); // 离屏的 group - var newElement = this.drawItem(item, index, this.getItemHeight(), offsetGroup); - this.updateElements(newElement, itemElement); // 更新整个分组 - this.clearUpdateStatus(itemElement); // 清理更新状态,防止出现 bug - } - }; - /** - * 是否存在指定的状态 - * @param {ListItem} item 列表项 - * @param {boolean} state 状态名 - */ - Category.prototype.hasState = function (item, state) { - return !!item[state]; - }; - Category.prototype.getItemStates = function (item) { - var itemStates = this.get('itemStates'); - var rst = []; - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(itemStates, function (v, k) { - if (item[k]) { - // item.selected - rst.push(k); - } - }); - return rst; - }; - /** - * 清楚所有列表项的状态 - * @param {string} state 状态值 - */ - Category.prototype.clearItemsState = function (state) { - var _this = this; - var items = this.getItemsByState(state); - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(items, function (item) { - _this.setItemState(item, state, false); - }); - }; - /** - * 根据状态获取图例项 - * @param {string} state [description] - * @return {ListItem[]} [description] - */ - Category.prototype.getItemsByState = function (state) { - var _this = this; - var items = this.getItems(); - return Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["filter"])(items, function (item) { - return _this.hasState(item, state); - }); - }; - // 绘制 legend 的选项 - Category.prototype.drawLegendContent = function (group) { - this.processItems(); - this.drawItems(group); - }; - // 防止未设置 id - Category.prototype.processItems = function () { - var items = this.get('items'); - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(items, function (item) { - if (!item.id) { - // 如果没有设置 id,默认使用 name - item.id = item.name; - } - }); - }; - // 绘制所有的图例选项 - Category.prototype.drawItems = function (group) { - var _this = this; - var itemContainerGroup = this.addGroup(group, { - id: this.getElementId('item-container-group'), - name: 'legend-item-container-group', - }); - var itemGroup = this.addGroup(itemContainerGroup, { - id: this.getElementId('item-group'), - name: 'legend-item-group', - }); - var itemHeight = this.getItemHeight(); - var itemWidth = this.get('itemWidth'); - var itemSpacing = this.get('itemSpacing'); - var currentPoint = this.get('currentPoint'); - var startX = currentPoint.x; - var startY = currentPoint.y; - var layout = this.get('layout'); - var items = this.get('items'); - var wrapped = false; - var pageWidth = 0; - var maxWidth = this.get('maxWidth'); // 最大宽度,会导致 layout : 'horizontal' 时自动换行 - var maxHeight = this.get('maxHeight'); // 最大高度,会导致出现分页 - // 暂时不考虑分页 - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(items, function (item, index) { - var subGroup = _this.drawItem(item, index, itemHeight, itemGroup); - var bbox = subGroup.getBBox(); - var width = itemWidth || bbox.width; - if (width > pageWidth) { - pageWidth = width; - } - if (layout === 'horizontal') { - // 如果水平布局 - if (maxWidth && maxWidth < currentPoint.x + width - startX) { - // 检测是否换行 - wrapped = true; - currentPoint.x = startX; - currentPoint.y += itemHeight; - } - _this.moveElementTo(subGroup, currentPoint); - currentPoint.x += width + itemSpacing; - } - else { - // 如果垂直布局 - if (maxHeight && maxHeight < currentPoint.y + itemHeight - startY) { - // 换行 - wrapped = true; - currentPoint.x += pageWidth + itemSpacing; - currentPoint.y = startY; - pageWidth = 0; - } - _this.moveElementTo(subGroup, currentPoint); - currentPoint.y += itemHeight; // itemSpacing 仅影响水平间距 - } - }); - if (wrapped && this.get('flipPage')) { - this.pageHeight = 0; - this.pageWidth = 0; - this.totalPagesCnt = 1; - this.startX = startX; - this.startY = startY; - this.adjustNavigation(group, itemGroup); - } - }; - // 获取图例项的高度,如果未定义,则按照 name 的高度计算 - Category.prototype.getItemHeight = function () { - var itemHeight = this.get('itemHeight'); - if (!itemHeight) { - var nameCfg = this.get('itemName'); - if (nameCfg) { - itemHeight = nameCfg.style.fontSize + 8; - } - } - return itemHeight; - }; - // 绘制 marker - Category.prototype.drawMarker = function (container, markerCfg, item, itemHeight) { - var markerAttrs = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ x: 0, y: itemHeight / 2 }, markerCfg.style), { symbol: Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(item.marker, 'symbol', 'circle') }), Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(item.marker, 'style', {})); - var shape = this.addShape(container, { - type: 'marker', - id: this.getElementId("item-" + item.id + "-marker"), - name: 'legend-item-marker', - attrs: markerAttrs, - }); - var bbox = shape.getBBox(); - shape.attr('x', bbox.width / 2); // marker 需要左对齐,所以不能占用左侧的空间 - var _a = shape.attr(), stroke = _a.stroke, fill = _a.fill; - if (stroke) { - shape.set('isStroke', true); - } - if (fill) { - shape.set('isFill', true); - } - return shape; - }; - // 绘制文本 - Category.prototype.drawItemText = function (container, textName, cfg, item, itemHeight, xPosition, index) { - var formatter = cfg.formatter; - var attrs = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ x: xPosition, y: itemHeight / 2, text: formatter ? formatter(item[textName], item, index) : item[textName] }, cfg.style); - return this.addShape(container, { - type: 'text', - id: this.getElementId("item-" + item.id + "-" + textName), - name: "legend-item-" + textName, - attrs: attrs, - }); - }; - // 绘制图例项 - Category.prototype.drawItem = function (item, index, itemHeight, itemGroup) { - var groupId = "item-" + item.id; - var subGroup = this.addGroup(itemGroup, { - name: 'legend-item', - id: this.getElementId(groupId), - delegateObject: { - item: item, - index: index, - }, - }); - var marker = this.get('marker'); - var itemName = this.get('itemName'); - var itemValue = this.get('itemValue'); - var itemBackground = this.get('itemBackground'); - var curX = 0; // 记录当前 x 的位置 - if (marker) { - var markerShape = this.drawMarker(subGroup, marker, item, itemHeight); - curX = markerShape.getBBox().maxX + marker.spacing; - } - if (itemName) { - var nameShape = this.drawItemText(subGroup, 'name', itemName, item, itemHeight, curX, index); - curX = nameShape.getBBox().maxX + itemName.spacing; - } - if (itemValue) { - var valueShape = this.drawItemText(subGroup, 'value', itemValue, item, itemHeight, curX, index); - var itemWidth = this.get('itemWidth'); - if (itemWidth && itemValue.alignRight) { - // 当文本右对齐,同时制定了列宽度时,调整文本位置和对齐方式 - valueShape.attr({ - textAlign: 'right', - x: itemWidth, - }); - } // 如果考虑 value 和 name 的覆盖,这个地方需要做文本自动省略的功能 - } - // 添加透明的背景,便于拾取和包围盒计算 - if (itemBackground) { - var bbox = subGroup.getBBox(); - var backShape = this.addShape(subGroup, { - type: 'rect', - name: 'legend-item-background', - id: this.getElementId(groupId + "-background"), - attrs: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ x: 0, y: 0, width: bbox.width, height: itemHeight }, itemBackground.style), - }); - backShape.toBack(); - } - this.applyItemStates(item, subGroup); - return subGroup; - }; - // 加上分页器并重新排序 items - Category.prototype.adjustNavigation = function (container, itemGroup) { - var _this = this; - var startX = this.startX; - var startY = this.startY; - var layout = this.get('layout'); - var subGroups = itemGroup.findAll(function (item) { return item.get('name') === 'legend-item'; }); - var maxWidth = this.get('maxWidth'); - var maxHeight = this.get('maxHeight'); - var itemWidth = this.get('itemWidth'); - var itemSpacing = this.get('itemSpacing'); - var itemHeight = this.getItemHeight(); - var navigation = this.drawNavigation(container, layout, '00/00', 12); - var navigationBBox = navigation.getBBox(); - var currentPoint = { x: startX, y: startY }; - var pages = 1; - var widthLimit = 0; - var pageWidth = 0; - var maxItemWidth = 0; - if (layout === 'horizontal') { - this.pageHeight = itemHeight; - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(subGroups, function (item) { - var bbox = item.getBBox(); - var width = itemWidth || bbox.width; - if ((widthLimit && widthLimit < currentPoint.x + width + itemSpacing) || - maxWidth < currentPoint.x + width + itemSpacing + navigationBBox.width) { - if (pages === 1) { - widthLimit = currentPoint.x + itemSpacing; - _this.pageWidth = widthLimit; - _this.moveElementTo(navigation, { - x: maxWidth - itemSpacing - navigationBBox.width - navigationBBox.minX, - y: currentPoint.y + itemHeight / 2 - navigationBBox.height / 2 - navigationBBox.minY, - }); - } - pages += 1; - currentPoint.x = startX; - currentPoint.y += itemHeight; - } - _this.moveElementTo(item, currentPoint); - currentPoint.x += width + itemSpacing; - }); - } - else { - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(subGroups, function (item) { - var bbox = item.getBBox(); - if (bbox.width > pageWidth) { - pageWidth = bbox.width; - } - }); - maxItemWidth = pageWidth; - pageWidth += itemSpacing; - if (maxWidth) { - // maxWidth 限制加上 - pageWidth = Math.min(maxWidth, pageWidth); - maxItemWidth = Math.min(maxWidth, maxItemWidth); - } - this.pageWidth = pageWidth; - this.pageHeight = maxHeight - Math.max(navigationBBox.height, itemHeight); - var cntPerPage_1 = Math.floor(this.pageHeight / itemHeight); - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(subGroups, function (item, index) { - if (index !== 0 && index % cntPerPage_1 === 0) { - pages += 1; - currentPoint.x += pageWidth; - currentPoint.y = startY; - } - _this.moveElementTo(item, currentPoint); - // item.setClip({ - // type: 'rect', - // attrs: { - // x: currentPoint.x, - // y: currentPoint.y, - // width: pageWidth, - // height: itemHeight, - // }, - // }); - currentPoint.y += itemHeight; - }); - this.totalPagesCnt = pages; - this.moveElementTo(navigation, { - x: startX + maxItemWidth / 2 - navigationBBox.width / 2 - navigationBBox.minX, - y: maxHeight - navigationBBox.height - navigationBBox.minY, - }); - } - if (this.pageHeight && this.pageWidth) { - // 为了使固定的 clip 生效,clip 设置在 itemContainerGroup 上,itemGroup 需要在翻页时会设置 matrix - itemGroup.getParent().setClip({ - type: 'rect', - attrs: { - x: this.startX, - y: this.startY, - width: this.pageWidth, - height: this.pageHeight, - }, - }); - } - this.totalPagesCnt = pages; - if (this.currentPageIndex > this.totalPagesCnt) { - this.currentPageIndex = 1; - } - this.updateNavigation(navigation); - // update initial matrix - itemGroup.attr('matrix', this.getCurrentNavigationMatrix()); - }; - Category.prototype.drawNavigation = function (group, layout, text, size) { - var currentPoint = { x: 0, y: 0 }; - var subGroup = this.addGroup(group, { - id: this.getElementId('navigation-group'), - name: 'legend-navigation', - }); - var leftArrow = this.drawArrow(subGroup, currentPoint, 'navigation-arrow-left', layout === 'horizontal' ? 'up' : 'left', size); - leftArrow.on('click', this.onNavigationBack); - var leftArrowBBox = leftArrow.getBBox(); - currentPoint.x += leftArrowBBox.width + 2; - var textShape = this.addShape(subGroup, { - type: 'text', - id: this.getElementId('navigation-text'), - name: 'navigation-text', - attrs: { - x: currentPoint.x, - y: currentPoint.y + size / 2, - text: text, - fontSize: 12, - fill: '#ccc', - textBaseline: 'middle', - }, - }); - var textBBox = textShape.getBBox(); - currentPoint.x += textBBox.width + 2; - var rightArrow = this.drawArrow(subGroup, currentPoint, 'navigation-arrow-right', layout === 'horizontal' ? 'down' : 'right', size); - rightArrow.on('click', this.onNavigationAfter); - return subGroup; - }; - Category.prototype.updateNavigation = function (navigation) { - var text = this.currentPageIndex + "/" + this.totalPagesCnt; - var textShape = navigation ? navigation.getChildren()[1] : this.getElementByLocalId('navigation-text'); - var leftArrow = navigation - ? navigation.findById(this.getElementId('navigation-arrow-left')) - : this.getElementByLocalId('navigation-arrow-left'); - var rightArrow = navigation - ? navigation.findById(this.getElementId('navigation-arrow-right')) - : this.getElementByLocalId('navigation-arrow-right'); - var origBBox = textShape.getBBox(); - textShape.attr('text', text); - var newBBox = textShape.getBBox(); - textShape.attr('x', textShape.attr('x') - (newBBox.width - origBBox.width) / 2); - leftArrow.attr('opacity', this.currentPageIndex === 1 ? 0.45 : 1); - leftArrow.attr('cursor', this.currentPageIndex === 1 ? 'not-allowed' : 'pointer'); - rightArrow.attr('opacity', this.currentPageIndex === this.totalPagesCnt ? 0.45 : 1); - rightArrow.attr('cursor', this.currentPageIndex === this.totalPagesCnt ? 'not-allowed' : 'pointer'); - }; - Category.prototype.drawArrow = function (group, currentPoint, name, direction, size) { - var x = currentPoint.x, y = currentPoint.y; - var rotateMap = { - right: (90 * Math.PI) / 180, - left: ((360 - 90) * Math.PI) / 180, - up: 0, - down: (180 * Math.PI) / 180, - }; - var shape = this.addShape(group, { - type: 'path', - id: this.getElementId(name), - name: name, - attrs: { - path: [['M', x + size / 2, y], ['L', x, y + size], ['L', x + size, y + size], ['Z']], - fill: '#000', - cursor: 'pointer', - }, - }); - shape.attr('matrix', Object(_util_matrix__WEBPACK_IMPORTED_MODULE_2__["getMatrixByAngle"])({ x: x + size / 2, y: y + size / 2 }, rotateMap[direction])); - return shape; - }; - Category.prototype.getCurrentNavigationMatrix = function () { - var _a = this, currentPageIndex = _a.currentPageIndex, pageWidth = _a.pageWidth, pageHeight = _a.pageHeight; - var layout = this.get('layout'); - var translate = layout === 'horizontal' - ? { - x: 0, - y: pageHeight * (1 - currentPageIndex), - } - : { - x: pageWidth * (1 - currentPageIndex), - y: 0, - }; - return Object(_util_matrix__WEBPACK_IMPORTED_MODULE_2__["getMatrixByTranslate"])(translate); - }; - // 附加状态对应的样式 - Category.prototype.applyItemStates = function (item, subGroup) { - var states = this.getItemStates(item); - var hasStates = states.length > 0; - if (hasStates) { - var children = subGroup.getChildren(); - var itemStates_1 = this.get('itemStates'); - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(children, function (element) { - var name = element.get('name'); - var elName = name.split('-')[2]; // marker, name, value - var statesStyle = Object(_util_state__WEBPACK_IMPORTED_MODULE_3__["getStatesStyle"])(item, elName, itemStates_1); - if (statesStyle) { - element.attr(statesStyle); - if (elName === 'marker' && !(element.get('isStroke') && element.get('isFill'))) { - // 如果 marker 是单填充或者单描边的话,就不要额外添加 stroke 或这 fill 属性,否则会影响 unchecked 后的显示 - if (element.get('isStroke')) { - element.attr('fill', null); - } - if (element.get('isFill')) { - element.attr('stroke', null); - } - } - } - }); - } - }; - return Category; -}(_base__WEBPACK_IMPORTED_MODULE_5__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (Category); -//# sourceMappingURL=category.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/legend/continuous.js": -/*!***************************************************************!*\ - !*** ./node_modules/@antv/component/esm/legend/continuous.js ***! - \***************************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); -/* harmony import */ var _util_theme__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../util/theme */ "./node_modules/@antv/component/esm/util/theme.js"); -/* harmony import */ var _util_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../util/util */ "./node_modules/@antv/component/esm/util/util.js"); -/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./base */ "./node_modules/@antv/component/esm/legend/base.js"); - - - - - -var HANDLER_HEIGHT_RATIO = 1.4; -var HANDLER_TRIANGLE_RATIO = 0.4; -var ContinueLegend = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(ContinueLegend, _super); - function ContinueLegend() { - return _super !== null && _super.apply(this, arguments) || this; - } - ContinueLegend.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { type: 'continue', min: 0, max: 100, value: null, colors: [], track: {}, rail: {}, label: {}, handler: {}, slidable: true, tip: null, step: null, maxWidth: null, maxHeight: null, defaultCfg: { - label: { - align: 'rail', - spacing: 5, - formatter: null, - style: { - fontSize: 12, - fill: _util_theme__WEBPACK_IMPORTED_MODULE_2__["default"].textColor, - textBaseline: 'middle', - fontFamily: _util_theme__WEBPACK_IMPORTED_MODULE_2__["default"].fontFamily, - }, - }, - handler: { - size: 10, - style: { - fill: '#fff', - stroke: '#333', - }, - }, - track: {}, - rail: { - type: 'color', - size: 20, - defaultLength: 100, - style: { - fill: '#DCDEE2', - }, - }, - title: { - spacing: 5, - style: { - fill: _util_theme__WEBPACK_IMPORTED_MODULE_2__["default"].textColor, - fontSize: 12, - textAlign: 'start', - textBaseline: 'top', - }, - }, - } }); - }; - ContinueLegend.prototype.isSlider = function () { - return true; - }; - // 实现 IList 接口 - ContinueLegend.prototype.getValue = function () { - return this.getCurrentValue(); - }; - ContinueLegend.prototype.getRange = function () { - return { - min: this.get('min'), - max: this.get('max'), - }; - }; - // 改变 range - ContinueLegend.prototype.setRange = function (min, max) { - this.update({ - min: min, - max: max, - }); - }; - ContinueLegend.prototype.setValue = function (value) { - var originValue = this.getValue(); - this.set('value', value); - var group = this.get('group'); - this.resetTrackClip(); - if (this.get('slidable')) { - this.resetHandlers(group); - } - this.delegateEmit('valuechanged', { - originValue: originValue, - value: value, - }); - }; - ContinueLegend.prototype.initEvent = function () { - var group = this.get('group'); - this.bindSliderEvent(group); - this.bindRailEvent(group); - this.bindTrackEvent(group); - }; - ContinueLegend.prototype.drawLegendContent = function (group) { - this.drawRail(group); - this.drawLabels(group); - this.fixedElements(group); // 调整各个图形位置,适应宽高的限制 - this.resetTrack(group); - this.resetTrackClip(group); - if (this.get('slidable')) { - this.resetHandlers(group); - } - }; - ContinueLegend.prototype.bindSliderEvent = function (group) { - this.bindHandlersEvent(group); - }; - ContinueLegend.prototype.bindHandlersEvent = function (group) { - var _this = this; - group.on('legend-handler-min:drag', function (ev) { - var minValue = _this.getValueByCanvasPoint(ev.x, ev.y); - var currentValue = _this.getCurrentValue(); - var maxValue = currentValue[1]; - if (maxValue < minValue) { - // 如果小于最小值,则调整最小值 - maxValue = minValue; - } - _this.setValue([minValue, maxValue]); - }); - group.on('legend-handler-max:drag', function (ev) { - var maxValue = _this.getValueByCanvasPoint(ev.x, ev.y); - var currentValue = _this.getCurrentValue(); - var minValue = currentValue[0]; - if (minValue > maxValue) { - // 如果小于最小值,则调整最小值 - minValue = maxValue; - } - _this.setValue([minValue, maxValue]); - }); - }; - ContinueLegend.prototype.bindRailEvent = function (group) { }; - ContinueLegend.prototype.bindTrackEvent = function (group) { - var _this = this; - var prePoint = null; - group.on('legend-track:dragstart', function (ev) { - prePoint = { - x: ev.x, - y: ev.y - }; - }); - group.on('legend-track:drag', function (ev) { - if (!prePoint) { - return; - } - var preValue = _this.getValueByCanvasPoint(prePoint.x, prePoint.y); - var curValue = _this.getValueByCanvasPoint(ev.x, ev.y); - var currentValue = _this.getCurrentValue(); - var curDiff = currentValue[1] - currentValue[0]; - var range = _this.getRange(); - var dValue = curValue - preValue; - if (dValue < 0) { // 减小, 同时未出边界 - if (currentValue[0] + dValue > range.min) { - _this.setValue([currentValue[0] + dValue, currentValue[1] + dValue]); - } - else { - _this.setValue([range.min, range.min + curDiff]); - } - // && || - } - else if (dValue > 0) { - if ((dValue > 0 && currentValue[1] + dValue < range.max)) { - _this.setValue([currentValue[0] + dValue, currentValue[1] + dValue]); - } - else { - _this.setValue([range.max - curDiff, range.max]); - } - } - prePoint = { - x: ev.x, - y: ev.y - }; - }); - group.on('legend-track:dragend', function (ev) { - prePoint = null; - }); - }; - ContinueLegend.prototype.drawLabels = function (group) { - this.drawLabel('min', group); - this.drawLabel('max', group); - }; - ContinueLegend.prototype.drawLabel = function (name, group) { - var labelCfg = this.get('label'); - var style = labelCfg.style; - var labelAlign = labelCfg.align; - var value = this.get(name); - var alignAttrs = this.getLabelAlignAttrs(name, labelAlign); - var localId = "label-" + name; - this.addShape(group, { - type: 'text', - id: this.getElementId(localId), - name: "legend-label-" + name, - attrs: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ x: 0, y: 0, text: value }, style), alignAttrs), - }); - }; - // 获取文本的对齐方式,为了自适应真实操碎了心 - ContinueLegend.prototype.getLabelAlignAttrs = function (name, align) { - var isVertical = this.isVertical(); - var textAlign = 'center'; - var textBaseline = 'middle'; - if (isVertical) { - // 垂直布局的所有的文本都左对齐 - textAlign = 'start'; - if (align !== 'rail') { - if (name === 'min') { - textBaseline = 'top'; - } - else { - textBaseline = 'bottom'; - } - } - else { - textBaseline = 'top'; - } - } - else { - if (align !== 'rail') { - textBaseline = 'top'; - if (name === 'min') { - textAlign = 'start'; - } - else { - textAlign = 'end'; - } - } - else { - textAlign = 'start'; - textBaseline = 'middle'; - } - } - return { - textAlign: textAlign, - textBaseline: textBaseline, - }; - }; - ContinueLegend.prototype.getRailPath = function (x, y, w, h) { - var railCfg = this.get('rail'); - var size = railCfg.size, defaultLength = railCfg.defaultLength, type = railCfg.type; - var isVertical = this.isVertical(); - var length = defaultLength; - var width = w; - var height = h; - if (!width) { - width = isVertical ? size : length; - } - if (!height) { - height = isVertical ? length : size; - } - var path = []; - if (type === 'color') { - path.push(['M', x, y]); - path.push(['L', x + width, y]); - path.push(['L', x + width, y + height]); - path.push(['L', x, y + height]); - path.push(['Z']); - } - else { - path.push(['M', x + width, y]); - path.push(['L', x + width, y + height]); - path.push(['L', x, y + height]); - path.push(['Z']); - } - return path; - }; - ContinueLegend.prototype.drawRail = function (group) { - var railCfg = this.get('rail'); - var style = railCfg.style; - this.addShape(group, { - type: 'path', - id: this.getElementId('rail'), - name: 'legend-rail', - attrs: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ path: this.getRailPath(0, 0) }, style), - }); - }; - // 将传入的颜色转换成渐变色 - ContinueLegend.prototype.getTrackColor = function (colors) { - var count = colors.length; - if (!count) { - return null; - } - if (count === 1) { - return colors[0]; - } - var color; // 最终形态 l(0) 0:colors[0] 0.5:colors[1] 1:colors[2]; - if (this.isVertical()) { - // 根据方向设置渐变方向 - color = 'l(90)'; - } - else { - color = 'l(0)'; - } - for (var i = 0; i < count; i++) { - var percent = i / (count - 1); - color += " " + percent + ":" + colors[i]; - } - return color; - }; - ContinueLegend.prototype.getTrackPath = function (group) { - var railShape = this.getRailShape(group); - var path = railShape.attr('path'); - return Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["clone"])(path); - }; - ContinueLegend.prototype.getClipTrackAttrs = function (group) { - var value = this.getCurrentValue(); - var min = value[0], max = value[1]; - var railBBox = this.getRailBBox(group); - var startPoint = this.getPointByValue(min, group); - var endPoint = this.getPointByValue(max, group); - var isVertical = this.isVertical(); - var x; - var y; - var width; - var height; - if (isVertical) { - x = railBBox.minX; - y = startPoint.y; - width = railBBox.width; - height = endPoint.y - startPoint.y; - } - else { - x = startPoint.x; - y = railBBox.minY; - width = endPoint.x - startPoint.x; - height = railBBox.height; - } - return { - x: x, - y: y, - width: width, - height: height, - }; - }; - // 获取 track 的属性,由 path 和 颜色构成 - ContinueLegend.prototype.getTrackAttrs = function (group) { - var trackCfg = this.get('track'); - var colors = this.get('colors'); - var path = this.getTrackPath(group); - return Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["mix"])({ - path: path, - fill: this.getTrackColor(colors), - }, trackCfg.style); - }; - ContinueLegend.prototype.resetTrackClip = function (group) { - var container = group || this.get('group'); - var trackId = this.getElementId('track'); - var trackShape = container.findById(trackId); - var clipShape = trackShape.getClip(); - var attrs = this.getClipTrackAttrs(group); - if (!clipShape) { - trackShape.setClip({ - type: 'rect', - attrs: attrs, - }); - } - else { - clipShape.attr(attrs); - } - }; - ContinueLegend.prototype.resetTrack = function (group) { - var trackId = this.getElementId('track'); - var trackShape = group.findById(trackId); - var trackAttrs = this.getTrackAttrs(group); - if (trackShape) { - trackShape.attr(trackAttrs); - } - else { - this.addShape(group, { - type: 'path', - id: trackId, - draggable: this.get('slidable'), - name: 'legend-track', - attrs: trackAttrs, - }); - } - }; - ContinueLegend.prototype.getPointByValue = function (value, group) { - var _a = this.getRange(), min = _a.min, max = _a.max; - var percent = (value - min) / (max - min); - var bbox = this.getRailBBox(group); - var isVertcal = this.isVertical(); - var point = { x: 0, y: 0 }; - if (isVertcal) { - point.x = bbox.minX + bbox.width / 2; - point.y = Object(_util_util__WEBPACK_IMPORTED_MODULE_3__["getValueByPercent"])(bbox.minY, bbox.maxY, percent); - } - else { - point.x = Object(_util_util__WEBPACK_IMPORTED_MODULE_3__["getValueByPercent"])(bbox.minX, bbox.maxX, percent); - point.y = bbox.minY + bbox.height / 2; - } - return point; - }; - ContinueLegend.prototype.getRailShape = function (group) { - var container = group || this.get('group'); - return container.findById(this.getElementId('rail')); - }; - // 获取滑轨的宽高信息 - ContinueLegend.prototype.getRailBBox = function (group) { - var railShape = this.getRailShape(group); - var bbox = railShape.getBBox(); - return bbox; - }; - ContinueLegend.prototype.getRailCanvasBBox = function () { - var container = this.get('group'); - var railShape = container.findById(this.getElementId('rail')); - var bbox = railShape.getCanvasBBox(); - return bbox; - }; - // 是否垂直 - ContinueLegend.prototype.isVertical = function () { - return this.get('layout') === 'vertical'; - }; - // 用于交互时 - ContinueLegend.prototype.getValueByCanvasPoint = function (x, y) { - var _a = this.getRange(), min = _a.min, max = _a.max; - var bbox = this.getRailCanvasBBox(); // 因为 x, y 是画布坐标 - var isVertcal = this.isVertical(); - var step = this.get('step'); - var percent; - if (isVertcal) { - // 垂直时计算 y - percent = (y - bbox.minY) / bbox.height; - } - else { - // 水平时计算 x - percent = (x - bbox.minX) / bbox.width; - } - var value = Object(_util_util__WEBPACK_IMPORTED_MODULE_3__["getValueByPercent"])(min, max, percent); - if (step) { - var count = Math.round((value - min) / step); - value = min + count * step; // 移动到最近的 - } - if (value > max) { - value = max; - } - if (value < min) { - value = min; - } - return value; - }; - // 当前选中的范围 - ContinueLegend.prototype.getCurrentValue = function () { - var value = this.get('value'); - if (!value) { - // 如果没有定义,取最大范围 - value = [this.get('min'), this.get('max')]; - } - return value; - }; - // 重置滑块 handler - ContinueLegend.prototype.resetHandlers = function (group) { - var currentValue = this.getCurrentValue(); - var min = currentValue[0], max = currentValue[1]; - this.resetHandler(group, 'min', min); - this.resetHandler(group, 'max', max); - }; - // 获取滑块的 path - ContinueLegend.prototype.getHandlerPath = function (handlerCfg, point) { - var isVertical = this.isVertical(); - var path = []; - var width = handlerCfg.size; - var x = point.x, y = point.y; - var height = width * HANDLER_HEIGHT_RATIO; - var halfWidth = width / 2; - var oneSixthWidth = width / 6; - if (isVertical) { - /** - * 竖直情况下的滑块 handler,左侧顶点是 x,y - * /----| - * -- | - * -- | - * \----| - */ - var triangleX = x + height * HANDLER_TRIANGLE_RATIO; - path.push(['M', x, y]); - path.push(['L', triangleX, y + halfWidth]); - path.push(['L', x + height, y + halfWidth]); - path.push(['L', x + height, y - halfWidth]); - path.push(['L', triangleX, y - halfWidth]); - path.push(['Z']); - // 绘制两条横线 - path.push(['M', triangleX, y + oneSixthWidth]); - path.push(['L', x + height - 2, y + oneSixthWidth]); - path.push(['M', triangleX, y - oneSixthWidth]); - path.push(['L', x + height - 2, y - oneSixthWidth]); - } - else { - /** - * 水平情况下的滑块,上面顶点处是 x,y - * / \ - * | | | | - * | | | | - * ----- - */ - var triangleY = y + height * HANDLER_TRIANGLE_RATIO; - path.push(['M', x, y]); - path.push(['L', x - halfWidth, triangleY]); - path.push(['L', x - halfWidth, y + height]); - path.push(['L', x + halfWidth, y + height]); - path.push(['L', x + halfWidth, triangleY]); - path.push(['Z']); - // 绘制两条竖线 - path.push(['M', x - oneSixthWidth, triangleY]); - path.push(['L', x - oneSixthWidth, y + height - 2]); - path.push(['M', x + oneSixthWidth, triangleY]); - path.push(['L', x + oneSixthWidth, y + height - 2]); - } - return path; - }; - // 调整 handler 的位置,如果未存在则绘制 - ContinueLegend.prototype.resetHandler = function (group, name, value) { - var point = this.getPointByValue(value, group); - var handlerCfg = this.get('handler'); - var path = this.getHandlerPath(handlerCfg, point); - var id = this.getElementId("handler-" + name); - var handlerShape = group.findById(id); - var isVertical = this.isVertical(); - if (handlerShape) { - handlerShape.attr('path', path); - } - else { - this.addShape(group, { - type: 'path', - name: "legend-handler-" + name, - draggable: true, - id: id, - attrs: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ path: path }, handlerCfg.style), { cursor: isVertical ? 'ns-resize' : 'ew-resize' }), - }); - } - }; - // 当设置了 maxWidth, maxHeight 时调整 rail 的宽度, - // 文本的位置 - ContinueLegend.prototype.fixedElements = function (group) { - var railShape = group.findById(this.getElementId('rail')); - var minLabel = group.findById(this.getElementId('label-min')); - var maxLabel = group.findById(this.getElementId('label-max')); - var startPoint = this.getDrawPoint(); - if (this.isVertical()) { - // 横向布局 - this.fixedVertail(minLabel, maxLabel, railShape, startPoint); - } - else { - // 水平布局 - this.fixedHorizontal(minLabel, maxLabel, railShape, startPoint); - } - }; - ContinueLegend.prototype.fitRailLength = function (minLabelBBox, maxLabelBBox, railBBox, railShape) { - var isVertical = this.isVertical(); - var lengthField = isVertical ? 'height' : 'width'; - var labelCfg = this.get('label'); - var labelAlign = labelCfg.align; - var spacing = labelCfg.spacing; - var maxLength = this.get("max" + Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["upperFirst"])(lengthField)); // get('maxWidth') - if (maxLength) { - var elementsLength = labelAlign === 'rail' - ? railBBox[lengthField] + minLabelBBox[lengthField] + maxLabelBBox[lengthField] + spacing * 2 - : railBBox[lengthField]; - var diff = elementsLength - maxLength; - if (diff > 0) { - // 大于限制的长度 - this.changeRailLength(railShape, lengthField, railBBox[lengthField] - diff); - } - } - }; - ContinueLegend.prototype.changeRailLength = function (railShape, lengthField, length) { - var bbox = railShape.getBBox(); - var path; - if (lengthField === 'height') { - path = this.getRailPath(bbox.x, bbox.y, bbox.width, length); - } - else { - path = this.getRailPath(bbox.x, bbox.y, length, bbox.height); - } - railShape.attr('path', path); - }; - ContinueLegend.prototype.changeRailPosition = function (railShape, x, y) { - var bbox = railShape.getBBox(); - var path = this.getRailPath(x, y, bbox.width, bbox.height); - railShape.attr('path', path); - }; - ContinueLegend.prototype.fixedHorizontal = function (minLabel, maxLabel, railShape, startPoint) { - var labelCfg = this.get('label'); - var labelAlign = labelCfg.align; - var spacing = labelCfg.spacing; - var railBBox = railShape.getBBox(); - var minLabelBBox = minLabel.getBBox(); - var maxLabelBBox = maxLabel.getBBox(); - var railHeight = railBBox.height; // 取 rail 的高度,作为高度 - this.fitRailLength(minLabelBBox, maxLabelBBox, railBBox, railShape); - railBBox = railShape.getBBox(); - if (labelAlign === 'rail') { - // 沿着 rail 方向 - minLabel.attr({ - x: startPoint.x, - y: startPoint.y + railHeight / 2, - }); - this.changeRailPosition(railShape, startPoint.x + minLabelBBox.width + spacing, startPoint.y); - maxLabel.attr({ - x: startPoint.x + minLabelBBox.width + railBBox.width + spacing * 2, - y: startPoint.y + railHeight / 2, - }); - } - else if (labelAlign === 'top') { - minLabel.attr({ - x: startPoint.x, - y: startPoint.y, - }); - maxLabel.attr({ - x: startPoint.x + railBBox.width, - y: startPoint.y, - }); - this.changeRailPosition(railShape, startPoint.x, startPoint.y + minLabelBBox.height + spacing); - } - else { - this.changeRailPosition(railShape, startPoint.x, startPoint.y); - minLabel.attr({ - x: startPoint.x, - y: startPoint.y + railBBox.height + spacing, - }); - maxLabel.attr({ - x: startPoint.x + railBBox.width, - y: startPoint.y + railBBox.height + spacing, - }); - } - }; - ContinueLegend.prototype.fixedVertail = function (minLabel, maxLabel, railShape, startPoint) { - var labelCfg = this.get('label'); - var labelAlign = labelCfg.align; - var spacing = labelCfg.spacing; - var railBBox = railShape.getBBox(); - var minLabelBBox = minLabel.getBBox(); - var maxLabelBBox = maxLabel.getBBox(); - this.fitRailLength(minLabelBBox, maxLabelBBox, railBBox, railShape); - railBBox = railShape.getBBox(); - if (labelAlign === 'rail') { - // 沿着 rail 方向 - minLabel.attr({ - x: startPoint.x, - y: startPoint.y, - }); - this.changeRailPosition(railShape, startPoint.x, startPoint.y + minLabelBBox.height + spacing); - maxLabel.attr({ - x: startPoint.x, - y: startPoint.y + minLabelBBox.height + railBBox.height + spacing * 2, - }); - } - else if (labelAlign === 'right') { - minLabel.attr({ - x: startPoint.x + railBBox.width + spacing, - y: startPoint.y, - }); - this.changeRailPosition(railShape, startPoint.x, startPoint.y); - maxLabel.attr({ - x: startPoint.x + railBBox.width + spacing, - y: startPoint.y + railBBox.height, - }); - } - else { - // left - var maxLabelWidth = Math.max(minLabelBBox.width, maxLabelBBox.width); - minLabel.attr({ - x: startPoint.x, - y: startPoint.y, - }); - this.changeRailPosition(railShape, startPoint.x + maxLabelWidth + spacing, startPoint.y); - maxLabel.attr({ - x: startPoint.x, - y: startPoint.y + railBBox.height, - }); - } - }; - return ContinueLegend; -}(_base__WEBPACK_IMPORTED_MODULE_4__["default"])); -/* harmony default export */ __webpack_exports__["default"] = (ContinueLegend); -//# sourceMappingURL=continuous.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/legend/index.js": -/*!**********************************************************!*\ - !*** ./node_modules/@antv/component/esm/legend/index.js ***! - \**********************************************************/ -/*! exports provided: Category, Continuous, Base */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _category__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./category */ "./node_modules/@antv/component/esm/legend/category.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Category", function() { return _category__WEBPACK_IMPORTED_MODULE_0__["default"]; }); - -/* harmony import */ var _continuous__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./continuous */ "./node_modules/@antv/component/esm/legend/continuous.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Continuous", function() { return _continuous__WEBPACK_IMPORTED_MODULE_1__["default"]; }); - -/* harmony import */ var _base__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./base */ "./node_modules/@antv/component/esm/legend/base.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Base", function() { return _base__WEBPACK_IMPORTED_MODULE_2__["default"]; }); - - - - -//# sourceMappingURL=index.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/scrollbar/index.js": -/*!*************************************************************!*\ - !*** ./node_modules/@antv/component/esm/scrollbar/index.js ***! - \*************************************************************/ -/*! exports provided: DEFAULT_THEME, Scrollbar */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _scrollbar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./scrollbar */ "./node_modules/@antv/component/esm/scrollbar/scrollbar.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_THEME", function() { return _scrollbar__WEBPACK_IMPORTED_MODULE_0__["DEFAULT_THEME"]; }); - -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scrollbar", function() { return _scrollbar__WEBPACK_IMPORTED_MODULE_0__["Scrollbar"]; }); - - -//# sourceMappingURL=index.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/scrollbar/scrollbar.js": -/*!*****************************************************************!*\ - !*** ./node_modules/@antv/component/esm/scrollbar/scrollbar.js ***! - \*****************************************************************/ -/*! exports provided: DEFAULT_THEME, Scrollbar */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_THEME", function() { return DEFAULT_THEME; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scrollbar", function() { return Scrollbar; }); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _antv_dom_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @antv/dom-util */ "./node_modules/@antv/dom-util/esm/index.js"); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); -/* harmony import */ var _abstract_group_component__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstract/group-component */ "./node_modules/@antv/component/esm/abstract/group-component.js"); - - - - -var DEFAULT_STYLE = { - trackColor: 'rgba(0,0,0,0)', - thumbColor: 'rgba(0,0,0,0.15)', - size: 8, - lineCap: 'round', -}; -var DEFAULT_THEME = { - // 默认样式 - default: DEFAULT_STYLE, - // 鼠标 hover 的样式 - hover: { - thumbColor: 'rgba(0,0,0,0.2)', - }, -}; -var Scrollbar = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Scrollbar, _super); - function Scrollbar() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.clearEvents = _antv_util__WEBPACK_IMPORTED_MODULE_2__["noop"]; - _this.onStartEvent = function (isMobile) { return function (e) { - _this.isMobile = isMobile; - e.originalEvent.preventDefault(); - var clientX = isMobile ? Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["get"])(e.originalEvent, 'touches.0.clientX') : e.clientX; - var clientY = isMobile ? Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["get"])(e.originalEvent, 'touches.0.clientY') : e.clientY; - // 将开始的点记录下来 - _this.startPos = _this.cfg.isHorizontal ? clientX : clientY; - _this.bindLaterEvent(); - }; }; - _this.bindLaterEvent = function () { - var containerDOM = _this.getContainerDOM(); - var events = []; - if (_this.isMobile) { - events = [ - Object(_antv_dom_util__WEBPACK_IMPORTED_MODULE_1__["addEventListener"])(containerDOM, 'touchmove', _this.onMouseMove), - Object(_antv_dom_util__WEBPACK_IMPORTED_MODULE_1__["addEventListener"])(containerDOM, 'touchend', _this.onMouseUp), - Object(_antv_dom_util__WEBPACK_IMPORTED_MODULE_1__["addEventListener"])(containerDOM, 'touchcancel', _this.onMouseUp), - ]; - } - else { - events = [ - Object(_antv_dom_util__WEBPACK_IMPORTED_MODULE_1__["addEventListener"])(containerDOM, 'mousemove', _this.onMouseMove), - Object(_antv_dom_util__WEBPACK_IMPORTED_MODULE_1__["addEventListener"])(containerDOM, 'mouseup', _this.onMouseUp), - // 为了保证划出 canvas containerDom 时还没触发 mouseup - Object(_antv_dom_util__WEBPACK_IMPORTED_MODULE_1__["addEventListener"])(containerDOM, 'mouseleave', _this.onMouseUp), - ]; - } - _this.clearEvents = function () { - events.forEach(function (e) { - e.remove(); - }); - }; - }; - // 拖拽滑块的事件回调 - // 这里是 dom 原生事件,绑定在 dom 元素上的 - _this.onMouseMove = function (e) { - var _a = _this.cfg, isHorizontal = _a.isHorizontal, thumbOffset = _a.thumbOffset; - e.preventDefault(); - var clientX = _this.isMobile ? Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["get"])(e, 'touches.0.clientX') : e.clientX; - var clientY = _this.isMobile ? Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["get"])(e, 'touches.0.clientY') : e.clientY; - // 鼠标松开的位置 - var endPos = isHorizontal ? clientX : clientY; - // 滑块需要移动的距离, 由于这里是对滑块监听,所以移动的距离就是 diffDis, 如果监听对象是 container dom,则需要算比例 - var diff = endPos - _this.startPos; - // 更新 _startPos - _this.startPos = endPos; - _this.updateThumbOffset(thumbOffset + diff); - }; - _this.onMouseUp = function (e) { - e.preventDefault(); - _this.clearEvents(); - }; - // 点击滑道的事件回调,移动滑块位置 - _this.onTrackClick = function (e) { - var _a = _this.cfg, isHorizontal = _a.isHorizontal, x = _a.x, y = _a.y, thumbLen = _a.thumbLen; - var containerDOM = _this.getContainerDOM(); - var rect = containerDOM.getBoundingClientRect(); - var clientX = e.clientX, clientY = e.clientY; - var offset = isHorizontal ? clientX - rect.left - x - thumbLen / 2 : clientY - rect.top - y - thumbLen / 2; - var newOffset = _this.validateRange(offset); - _this.updateThumbOffset(newOffset); - }; - _this.onThumbMouseOver = function () { - var thumbColor = _this.cfg.theme.hover.thumbColor; - _this.getElementByLocalId('thumb').attr('stroke', thumbColor); - _this.draw(); - }; - _this.onThumbMouseOut = function () { - var thumbColor = _this.cfg.theme.default.thumbColor; - _this.getElementByLocalId('thumb').attr('stroke', thumbColor); - _this.draw(); - }; - return _this; - } - Scrollbar.prototype.setRange = function (min, max) { - this.set('minLimit', min); - this.set('maxLimit', max); - }; - Scrollbar.prototype.getRange = function () { - var min = this.get('minLimit'); - var max = this.get('maxLimit'); - return { min: min, max: max }; - }; - Scrollbar.prototype.setValue = function (value) { - var originalValue = this.getValue(); - this.update({ - thumbOffset: this.get('trackLen') - this.get('thumbLen') * Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["clamp"])(value, 0, 1), - }); - this.delegateEmit('valuechange', { - originalValue: originalValue, - value: this.getValue(), - }); - }; - Scrollbar.prototype.getValue = function () { - return Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["clamp"])(this.get('thumbOffset') / (this.get('trackLen') - this.get('thumbLen')), 0, 1); - }; - Scrollbar.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { name: 'scrollbar', isHorizontal: true, minThumbLen: 20, thumbOffset: 0, theme: DEFAULT_THEME }); - }; - Scrollbar.prototype.renderInner = function (group) { - this.renderTrackShape(group); - this.renderThumbShape(group); - }; - Scrollbar.prototype.applyOffset = function () { - this.moveElementTo(this.get('group'), { - x: this.get('x'), - y: this.get('y'), - }); - }; - Scrollbar.prototype.initEvent = function () { - this.bindEvents(); - }; - // 创建滑道的 shape - Scrollbar.prototype.renderTrackShape = function (group) { - var _a = this.cfg, trackLen = _a.trackLen, _b = _a.theme, theme = _b === void 0 ? { default: {} } : _b; - var _c = theme.default, lineCap = _c.lineCap, trackColor = _c.trackColor, size = _c.size; - var attrs = this.get('isHorizontal') - ? { - x1: 0 + size / 2, - y1: size / 2, - x2: trackLen - size / 2, - y2: size / 2, - lineWidth: size, - stroke: trackColor, - lineCap: lineCap, - } - : { - x1: size / 2, - y1: 0 + size / 2, - x2: size / 2, - y2: trackLen - size / 2, - lineWidth: size, - stroke: trackColor, - lineCap: lineCap, - }; - return this.addShape(group, { - id: this.getElementId('track'), - name: 'track', - type: 'line', - attrs: attrs, - }); - }; - // 创建滑块的 shape - Scrollbar.prototype.renderThumbShape = function (group) { - var _a = this.cfg, thumbOffset = _a.thumbOffset, thumbLen = _a.thumbLen, _b = _a.theme, theme = _b === void 0 ? { default: {} } : _b; - var _c = theme.default, size = _c.size, lineCap = _c.lineCap, thumbColor = _c.thumbColor; - var attrs = this.get('isHorizontal') - ? { - x1: thumbOffset + size / 2, - y1: size / 2, - x2: thumbOffset + thumbLen - size / 2, - y2: size / 2, - lineWidth: size, - stroke: thumbColor, - lineCap: lineCap, - cursor: 'default', - } - : { - x1: size / 2, - y1: thumbOffset + size / 2, - x2: size / 2, - y2: thumbOffset + thumbLen - size / 2, - lineWidth: size, - stroke: thumbColor, - lineCap: lineCap, - cursor: 'default', - }; - return this.addShape(group, { - id: this.getElementId('thumb'), - name: 'thumb', - type: 'line', - attrs: attrs, - }); - }; - Scrollbar.prototype.bindEvents = function () { - var group = this.get('group'); - group.on('mousedown', this.onStartEvent(false)); - group.on('mouseup', this.onMouseUp); - group.on('touchstart', this.onStartEvent(true)); - group.on('touchend', this.onMouseUp); - var trackShape = group.findById(this.getElementId('track')); - trackShape.on('click', this.onTrackClick); - var thumbShape = group.findById(this.getElementId('thumb')); - thumbShape.on('mouseover', this.onThumbMouseOver); - thumbShape.on('mouseout', this.onThumbMouseOut); - }; - Scrollbar.prototype.getContainerDOM = function () { - var container = this.get('container'); - var canvas = container && container.get('canvas'); - return canvas && canvas.get('container'); - }; - Scrollbar.prototype.validateRange = function (offset) { - var _a = this.cfg, thumbLen = _a.thumbLen, trackLen = _a.trackLen; - var newOffset = offset; - if (offset + thumbLen > trackLen) { - newOffset = trackLen - thumbLen; - } - else if (offset + thumbLen < thumbLen) { - newOffset = 0; - } - return newOffset; - }; - Scrollbar.prototype.draw = function () { - var container = this.get('container'); - var canvas = container && container.get('canvas'); - if (canvas) { - canvas.draw(); - } - }; - Scrollbar.prototype.updateThumbOffset = function (offset) { - var _a = this.cfg, thumbOffset = _a.thumbOffset, isHorizontal = _a.isHorizontal, thumbLen = _a.thumbLen, size = _a.size; - var newOffset = this.validateRange(offset); - if (newOffset === thumbOffset) { - // 如果更新后的 offset 与原值相同,则不改变 - return; - } - var thumbShape = this.getElementByLocalId('thumb'); - if (isHorizontal) { - thumbShape.attr({ - x1: newOffset + size / 2, - x2: newOffset + thumbLen - size / 2, - }); - } - else { - thumbShape.attr({ - y1: newOffset + size / 2, - y2: newOffset + thumbLen - size / 2, - }); - } - this.emitOffsetChange(newOffset); - }; - Scrollbar.prototype.emitOffsetChange = function (offset) { - var _a = this.cfg, originalValue = _a.thumbOffset, trackLen = _a.trackLen, thumbLen = _a.thumbLen; - this.cfg.thumbOffset = offset; - // 发送事件 - this.emit('scrollchange', { - thumbOffset: offset, - ratio: Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["clamp"])(offset / (trackLen - thumbLen), 0, 1), - }); - this.delegateEmit('valuechange', { - originalValue: originalValue, - value: offset, - }); - }; - return Scrollbar; -}(_abstract_group_component__WEBPACK_IMPORTED_MODULE_3__["default"])); - -//# sourceMappingURL=scrollbar.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/slider/constant.js": -/*!*************************************************************!*\ - !*** ./node_modules/@antv/component/esm/slider/constant.js ***! - \*************************************************************/ -/*! exports provided: BACKGROUND_STYLE, FOREGROUND_STYLE, DEFAULT_HANDLER_WIDTH, HANDLER_STYLE, TEXT_STYLE, SLIDER_CHANGE */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BACKGROUND_STYLE", function() { return BACKGROUND_STYLE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FOREGROUND_STYLE", function() { return FOREGROUND_STYLE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DEFAULT_HANDLER_WIDTH", function() { return DEFAULT_HANDLER_WIDTH; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HANDLER_STYLE", function() { return HANDLER_STYLE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TEXT_STYLE", function() { return TEXT_STYLE; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SLIDER_CHANGE", function() { return SLIDER_CHANGE; }); -/** - * 一些默认的样式配置 - */ -var BACKGROUND_STYLE = { - fill: '#416180 ', - opacity: 0.05, -}; -var FOREGROUND_STYLE = { - fill: '#5B8FF9', - opacity: 0.15, - cursor: 'move', -}; -var DEFAULT_HANDLER_WIDTH = 10; -var HANDLER_STYLE = { - width: DEFAULT_HANDLER_WIDTH, - height: 24, -}; -var TEXT_STYLE = { - textBaseline: 'middle', - fill: '#000', - opacity: 0.45, -}; -var SLIDER_CHANGE = 'sliderchange'; -//# sourceMappingURL=constant.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/slider/handler.js": -/*!************************************************************!*\ - !*** ./node_modules/@antv/component/esm/slider/handler.js ***! - \************************************************************/ -/*! exports provided: Handler, default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Handler", function() { return Handler; }); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _abstract_group_component__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../abstract/group-component */ "./node_modules/@antv/component/esm/abstract/group-component.js"); - - -var DEFAULT_STYLE = { - fill: '#F7F7F7', - stroke: '#BFBFBF', - radius: 2, - opacity: 1, - cursor: 'ew-resize', - // 高亮的颜色 - highLightFill: '#FFF', -}; -var Handler = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Handler, _super); - function Handler() { - return _super !== null && _super.apply(this, arguments) || this; - } - Handler.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { name: 'handler', x: 0, y: 0, width: 10, height: 24, style: DEFAULT_STYLE }); - }; - Handler.prototype.renderInner = function (group) { - var _a = this.cfg, width = _a.width, height = _a.height, style = _a.style; - var fill = style.fill, stroke = style.stroke, radius = style.radius, opacity = style.opacity, cursor = style.cursor; - // 按钮框框 - this.addShape(group, { - type: 'rect', - id: this.getElementId('background'), - attrs: { - x: 0, - y: 0, - width: width, - height: height, - fill: fill, - stroke: stroke, - radius: radius, - opacity: opacity, - cursor: cursor, - }, - }); - // 两根竖线 - var x1 = (1 / 3) * width; - var x2 = (2 / 3) * width; - var y1 = (1 / 4) * height; - var y2 = (3 / 4) * height; - this.addShape(group, { - id: this.getElementId('line-left'), - type: 'line', - attrs: { - x1: x1, - y1: y1, - x2: x1, - y2: y2, - stroke: stroke, - cursor: cursor, - }, - }); - this.addShape(group, { - id: this.getElementId('line-right'), - type: 'line', - attrs: { - x1: x2, - y1: y1, - x2: x2, - y2: y2, - stroke: stroke, - cursor: cursor, - }, - }); - }; - Handler.prototype.applyOffset = function () { - this.moveElementTo(this.get('group'), { - x: this.get('x'), - y: this.get('y'), - }); - }; - Handler.prototype.initEvent = function () { - this.bindEvents(); - }; - Handler.prototype.bindEvents = function () { - var _this = this; - this.get('group').on('mouseenter', function () { - var highLightFill = _this.get('style').highLightFill; - _this.getElementByLocalId('background').attr('fill', highLightFill); - _this.draw(); - }); - this.get('group').on('mouseleave', function () { - var fill = _this.get('style').fill; - _this.getElementByLocalId('background').attr('fill', fill); - _this.draw(); - }); - }; - Handler.prototype.draw = function () { - var canvas = this.get('container').get('canvas'); - if (canvas) { - canvas.draw(); - } - }; - return Handler; -}(_abstract_group_component__WEBPACK_IMPORTED_MODULE_1__["default"])); - -/* harmony default export */ __webpack_exports__["default"] = (Handler); -//# sourceMappingURL=handler.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/slider/index.js": -/*!**********************************************************!*\ - !*** ./node_modules/@antv/component/esm/slider/index.js ***! - \**********************************************************/ -/*! exports provided: Slider */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _slider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./slider */ "./node_modules/@antv/component/esm/slider/slider.js"); -/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return _slider__WEBPACK_IMPORTED_MODULE_0__["Slider"]; }); - - -//# sourceMappingURL=index.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/slider/slider.js": -/*!***********************************************************!*\ - !*** ./node_modules/@antv/component/esm/slider/slider.js ***! - \***********************************************************/ -/*! exports provided: Slider, default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Slider", function() { return Slider; }); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); -/* harmony import */ var _abstract_group_component__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstract/group-component */ "./node_modules/@antv/component/esm/abstract/group-component.js"); -/* harmony import */ var _trend_trend__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../trend/trend */ "./node_modules/@antv/component/esm/trend/trend.js"); -/* harmony import */ var _constant__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./constant */ "./node_modules/@antv/component/esm/slider/constant.js"); -/* harmony import */ var _handler__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./handler */ "./node_modules/@antv/component/esm/slider/handler.js"); - - - - - - -var Slider = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Slider, _super); - function Slider() { - var _this = _super !== null && _super.apply(this, arguments) || this; - _this.onMouseDown = function (target) { return function (e) { - _this.currentTarget = target; - // 取出原生事件 - var event = e.originalEvent; - // 2. 存储当前点击位置 - event.stopPropagation(); - event.preventDefault(); - // 兼容移动端获取数据 - _this.prevX = Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(event, 'touches.0.pageX', event.pageX); - _this.prevY = Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(event, 'touches.0.pageY', event.pageY); - // 3. 开始滑动的时候,绑定 move 和 up 事件 - var containerDOM = _this.getContainerDOM(); - containerDOM.addEventListener('mousemove', _this.onMouseMove); - containerDOM.addEventListener('mouseup', _this.onMouseUp); - containerDOM.addEventListener('mouseleave', _this.onMouseUp); - // 移动端事件 - containerDOM.addEventListener('touchmove', _this.onMouseMove); - containerDOM.addEventListener('touchend', _this.onMouseUp); - containerDOM.addEventListener('touchcancel', _this.onMouseUp); - }; }; - _this.onMouseMove = function (event) { - var width = _this.cfg.width; - var originValue = [_this.get('start'), _this.get('end')]; - // 滑动过程中,计算偏移,更新滑块,然后 emit 数据出去 - event.stopPropagation(); - event.preventDefault(); - var x = Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(event, 'touches.0.pageX', event.pageX); - var y = Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(event, 'touches.0.pageY', event.pageY); - // 横向的 slider 只处理 x - var offsetX = x - _this.prevX; - var offsetXRange = _this.adjustOffsetRange(offsetX / width); - // 更新 start end range 范围 - _this.updateStartEnd(offsetXRange); - // 更新 ui - _this.updateUI(_this.getElementByLocalId('foreground'), _this.getElementByLocalId('minText'), _this.getElementByLocalId('maxText')); - _this.prevX = x; - _this.prevY = y; - _this.draw(); - // 因为存储的 start、end 可能不一定是按大小存储的,所以排序一下,对外是 end >= start - _this.emit(_constant__WEBPACK_IMPORTED_MODULE_4__["SLIDER_CHANGE"], [_this.get('start'), _this.get('end')].sort()); - _this.delegateEmit('valuechanged', { - originValue: originValue, - value: [_this.get('start'), _this.get('end')], - }); - }; - _this.onMouseUp = function () { - // 结束之后,取消绑定的事件 - if (_this.currentTarget) { - _this.currentTarget = undefined; - } - var containerDOM = _this.getContainerDOM(); - if (containerDOM) { - containerDOM.removeEventListener('mousemove', _this.onMouseMove); - containerDOM.removeEventListener('mouseup', _this.onMouseUp); - // 防止滑动到 canvas 外部之后,状态丢失 - containerDOM.removeEventListener('mouseleave', _this.onMouseUp); - // 移动端事件 - containerDOM.removeEventListener('touchmove', _this.onMouseMove); - containerDOM.removeEventListener('touchend', _this.onMouseUp); - containerDOM.removeEventListener('touchcancel', _this.onMouseUp); - } - }; - return _this; - } - Slider.prototype.setRange = function (min, max) { - this.set('minLimit', min); - this.set('maxLimit', max); - }; - Slider.prototype.getRange = function () { - return { - min: this.get('minLimit') || 0, - max: this.get('maxLimit') || 1, - }; - }; - Slider.prototype.setValue = function (value) { - if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["isArray"])(value) && value.length === 2) { - var originValue = [this.get('start'), this.get('end')]; - this.update({ - start: value[0], - end: value[1], - }); - if (!this.get('updateAutoRender')) { - this.render(); - } - this.delegateEmit('valuechanged', { - originValue: originValue, - value: value, - }); - } - }; - Slider.prototype.getValue = function () { - return [this.get('start'), this.get('end')]; - }; - Slider.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { name: 'slider', x: 0, y: 0, width: 100, height: 16, backgroundStyle: {}, foregroundStyle: {}, handlerStyle: {}, textStyle: {}, defaultCfg: { - backgroundStyle: _constant__WEBPACK_IMPORTED_MODULE_4__["BACKGROUND_STYLE"], - foregroundStyle: _constant__WEBPACK_IMPORTED_MODULE_4__["FOREGROUND_STYLE"], - handlerStyle: _constant__WEBPACK_IMPORTED_MODULE_4__["HANDLER_STYLE"], - textStyle: _constant__WEBPACK_IMPORTED_MODULE_4__["TEXT_STYLE"], - } }); - }; - Slider.prototype.update = function (cfg) { - var start = cfg.start, end = cfg.end; - var validCfg = Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg); - if (!Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["isNil"])(start)) { - validCfg.start = Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["clamp"])(start, 0, 1); - } - if (!Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["isNil"])(end)) { - validCfg.end = Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["clamp"])(end, 0, 1); - } - _super.prototype.update.call(this, validCfg); - this.minHandler = this.getChildComponentById(this.getElementId('minHandler')); - this.maxHandler = this.getChildComponentById(this.getElementId('maxHandler')); - }; - Slider.prototype.init = function () { - this.set('start', Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["clamp"])(this.get('start'), 0, 1)); - this.set('end', Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["clamp"])(this.get('end'), 0, 1)); - _super.prototype.init.call(this); - }; - Slider.prototype.renderInner = function (group) { - var _a = this.cfg, start = _a.start, end = _a.end, width = _a.width, height = _a.height, _b = _a.trendCfg, trendCfg = _b === void 0 ? {} : _b, minText = _a.minText, maxText = _a.maxText, _c = _a.backgroundStyle, backgroundStyle = _c === void 0 ? {} : _c, _d = _a.foregroundStyle, foregroundStyle = _d === void 0 ? {} : _d, _e = _a.textStyle, textStyle = _e === void 0 ? {} : _e, _f = _a.handlerStyle, handlerStyle = _f === void 0 ? {} : _f; - var min = start * width; - var max = end * width; - // 趋势图数据 - if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["size"])(Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(trendCfg, 'data'))) { - this.addComponent(group, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ component: _trend_trend__WEBPACK_IMPORTED_MODULE_3__["Trend"], id: this.getElementId('trend'), x: 0, y: 0, width: width, - height: height }, trendCfg)); - } - // 1. 背景 - this.addShape(group, { - id: this.getElementId('background'), - type: 'rect', - attrs: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ x: 0, y: 0, width: width, - height: height }, backgroundStyle), - }); - // 2. 左右文字 - var minTextShape = this.addShape(group, { - id: this.getElementId('minText'), - type: 'text', - attrs: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ - // x: 0, - y: height / 2, textAlign: 'right', text: minText, silent: false }, textStyle), - }); - var maxTextShape = this.addShape(group, { - id: this.getElementId('maxText'), - type: 'text', - attrs: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ - // x: 0, - y: height / 2, textAlign: 'left', text: maxText, silent: false }, textStyle), - }); - // 3. 前景 选中背景框 - var foregroundShape = this.addShape(group, { - id: this.getElementId('foreground'), - name: 'foreground', - type: 'rect', - attrs: Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ - // x: 0, - y: 0, - // width: 0, - height: height }, foregroundStyle), - }); - // 滑块相关的大小信息 - // const handlerWidth = get(handlerStyle, 'width', 10); - var handlerHeight = Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(handlerStyle, 'height', 24); - // 4. 左右滑块 - this.minHandler = this.addComponent(group, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ component: _handler__WEBPACK_IMPORTED_MODULE_5__["Handler"], id: this.getElementId('minHandler'), name: 'handler-min', x: 0, y: (height - handlerHeight) / 2, width: width, height: handlerHeight, cursor: 'ew-resize' }, handlerStyle)); - this.maxHandler = this.addComponent(group, Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({ component: _handler__WEBPACK_IMPORTED_MODULE_5__["Handler"], id: this.getElementId('maxHandler'), name: 'handler-max', x: 0, y: (height - handlerHeight) / 2, width: width, height: handlerHeight, cursor: 'ew-resize' }, handlerStyle)); - this.updateUI(foregroundShape, minTextShape, maxTextShape); - }; - Slider.prototype.applyOffset = function () { - this.moveElementTo(this.get('group'), { - x: this.get('x'), - y: this.get('y'), - }); - }; - Slider.prototype.initEvent = function () { - this.bindEvents(); - }; - Slider.prototype.updateUI = function (foregroundShape, minTextShape, maxTextShape) { - var _a = this.cfg, start = _a.start, end = _a.end, width = _a.width, minText = _a.minText, maxText = _a.maxText, handlerStyle = _a.handlerStyle; - var min = start * width; - var max = end * width; - // 1. foreground - foregroundShape.attr('x', min); - foregroundShape.attr('width', max - min); - // 滑块相关的大小信息 - var handlerWidth = Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(handlerStyle, 'width', _constant__WEBPACK_IMPORTED_MODULE_4__["DEFAULT_HANDLER_WIDTH"]); - // 设置文本 - minTextShape.attr('text', minText); - maxTextShape.attr('text', maxText); - var _b = this._dodgeText([min, max], minTextShape, maxTextShape), minAttrs = _b[0], maxAttrs = _b[1]; - // 2. 左侧滑块和文字位置 - if (this.minHandler) { - this.minHandler.update({ - x: min - handlerWidth / 2, - }); - if (!this.get('updateAutoRender')) { - this.minHandler.render(); - } - } - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(minAttrs, function (v, k) { return minTextShape.attr(k, v); }); - // 3. 右侧滑块和文字位置 - if (this.maxHandler) { - this.maxHandler.update({ - x: max - handlerWidth / 2, - }); - if (!this.get('updateAutoRender')) { - this.maxHandler.render(); - } - } - Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["each"])(maxAttrs, function (v, k) { return maxTextShape.attr(k, v); }); - }; - Slider.prototype.bindEvents = function () { - var group = this.get('group'); - group.on('handler-min:mousedown', this.onMouseDown('minHandler')); - group.on('handler-min:touchstart', this.onMouseDown('minHandler')); - // 2. 右滑块的滑动 - group.on('handler-max:mousedown', this.onMouseDown('maxHandler')); - group.on('handler-max:touchstart', this.onMouseDown('maxHandler')); - // 3. 前景选中区域 - var foreground = group.findById(this.getElementId('foreground')); - foreground.on('mousedown', this.onMouseDown('foreground')); - foreground.on('touchstart', this.onMouseDown('foreground')); - }; - /** - * 调整 offsetRange,因为一些范围的限制 - * @param offsetRange - */ - Slider.prototype.adjustOffsetRange = function (offsetRange) { - var _a = this.cfg, start = _a.start, end = _a.end; - // 针对不同的滑动组件,处理的方式不同 - switch (this.currentTarget) { - case 'minHandler': { - var min = 0 - start; - var max = 1 - start; - return Math.min(max, Math.max(min, offsetRange)); - } - case 'maxHandler': { - var min = 0 - end; - var max = 1 - end; - return Math.min(max, Math.max(min, offsetRange)); - } - case 'foreground': { - var min = 0 - start; - var max = 1 - end; - return Math.min(max, Math.max(min, offsetRange)); - } - default: - return 0; - } - }; - Slider.prototype.updateStartEnd = function (offsetRange) { - var _a = this.cfg, start = _a.start, end = _a.end; - // 操作不同的组件,反馈不一样 - switch (this.currentTarget) { - case 'minHandler': - start += offsetRange; - break; - case 'maxHandler': - end += offsetRange; - break; - case 'foreground': - start += offsetRange; - end += offsetRange; - break; - } - this.set('start', start); - this.set('end', end); - }; - /** - * 调整 text 的位置,自动躲避 - * 根据位置,调整返回新的位置 - * @param range - */ - Slider.prototype._dodgeText = function (range, minTextShape, maxTextShape) { - var _a, _b; - var _c = this.cfg, handlerStyle = _c.handlerStyle, width = _c.width; - var PADDING = 2; - var handlerWidth = Object(_antv_util__WEBPACK_IMPORTED_MODULE_1__["get"])(handlerStyle, 'width', _constant__WEBPACK_IMPORTED_MODULE_4__["DEFAULT_HANDLER_WIDTH"]); - var min = range[0], max = range[1]; - var sorted = false; - // 如果交换了位置,则对应的 min max 也交互 - if (min > max) { - _a = [max, min], min = _a[0], max = _a[1]; - _b = [maxTextShape, minTextShape], minTextShape = _b[0], maxTextShape = _b[1]; - sorted = true; - } - // 避让规则,优先显示在两侧,只有显示不下的时候,才显示在中间 - var minBBox = minTextShape.getBBox(); - var maxBBox = maxTextShape.getBBox(); - var minAttrs = minBBox.width > min - PADDING - ? { x: min + handlerWidth / 2 + PADDING, textAlign: 'left' } - : { x: min - handlerWidth / 2 - PADDING, textAlign: 'right' }; - var maxAttrs = maxBBox.width > width - max - PADDING - ? { x: max - handlerWidth / 2 - PADDING, textAlign: 'right' } - : { x: max + handlerWidth / 2 + PADDING, textAlign: 'left' }; - return !sorted ? [minAttrs, maxAttrs] : [maxAttrs, minAttrs]; - }; - Slider.prototype.draw = function () { - var container = this.get('container'); - var canvas = container && container.get('canvas'); - if (canvas) { - canvas.draw(); - } - }; - Slider.prototype.getContainerDOM = function () { - var container = this.get('container'); - var canvas = container && container.get('canvas'); - return canvas && canvas.get('container'); - }; - return Slider; -}(_abstract_group_component__WEBPACK_IMPORTED_MODULE_2__["default"])); - -/* harmony default export */ __webpack_exports__["default"] = (Slider); -//# sourceMappingURL=slider.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/tooltip/css-const.js": -/*!***************************************************************!*\ - !*** ./node_modules/@antv/component/esm/tooltip/css-const.js ***! - \***************************************************************/ -/*! exports provided: CONTAINER_CLASS, TITLE_CLASS, LIST_CLASS, LIST_ITEM_CLASS, MARKER_CLASS, VALUE_CLASS, NAME_CLASS, CROSSHAIR_X, CROSSHAIR_Y */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONTAINER_CLASS", function() { return CONTAINER_CLASS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TITLE_CLASS", function() { return TITLE_CLASS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LIST_CLASS", function() { return LIST_CLASS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LIST_ITEM_CLASS", function() { return LIST_ITEM_CLASS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MARKER_CLASS", function() { return MARKER_CLASS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VALUE_CLASS", function() { return VALUE_CLASS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NAME_CLASS", function() { return NAME_CLASS; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CROSSHAIR_X", function() { return CROSSHAIR_X; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CROSSHAIR_Y", function() { return CROSSHAIR_Y; }); -var CONTAINER_CLASS = 'g2-tooltip'; -var TITLE_CLASS = 'g2-tooltip-title'; -var LIST_CLASS = 'g2-tooltip-list'; -var LIST_ITEM_CLASS = 'g2-tooltip-list-item'; -var MARKER_CLASS = 'g2-tooltip-marker'; -var VALUE_CLASS = 'g2-tooltip-value'; -var NAME_CLASS = 'g2-tooltip-name'; -var CROSSHAIR_X = 'g2-tooltip-crosshair-x'; -var CROSSHAIR_Y = 'g2-tooltip-crosshair-y'; -//# sourceMappingURL=css-const.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/tooltip/html-theme.js": -/*!****************************************************************!*\ - !*** ./node_modules/@antv/component/esm/tooltip/html-theme.js ***! - \****************************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var _util_theme__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../util/theme */ "./node_modules/@antv/component/esm/util/theme.js"); -/* harmony import */ var _css_const__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./css-const */ "./node_modules/@antv/component/esm/tooltip/css-const.js"); -var _a; - -// tooltip 相关 dom 的 css 类名 - -/* harmony default export */ __webpack_exports__["default"] = (_a = {}, - // css style for tooltip - _a["" + _css_const__WEBPACK_IMPORTED_MODULE_1__["CONTAINER_CLASS"]] = { - position: 'absolute', - visibility: 'visible', - // @2018-07-25 by blue.lb 这里去掉浮动,火狐上存在样式错位 - // whiteSpace: 'nowrap', - zIndex: 8, - transition: 'visibility 0.2s cubic-bezier(0.23, 1, 0.32, 1), ' + - 'left 0.4s cubic-bezier(0.23, 1, 0.32, 1), ' + - 'top 0.4s cubic-bezier(0.23, 1, 0.32, 1)', - backgroundColor: 'rgba(255, 255, 255, 0.9)', - boxShadow: '0px 0px 10px #aeaeae', - borderRadius: '3px', - color: 'rgb(87, 87, 87)', - fontSize: '12px', - fontFamily: _util_theme__WEBPACK_IMPORTED_MODULE_0__["default"].fontFamily, - lineHeight: '20px', - padding: '10px 10px 6px 10px', - }, - _a["" + _css_const__WEBPACK_IMPORTED_MODULE_1__["TITLE_CLASS"]] = { - marginBottom: '4px', - }, - _a["" + _css_const__WEBPACK_IMPORTED_MODULE_1__["LIST_CLASS"]] = { - margin: 0, - listStyleType: 'none', - padding: 0, - }, - _a["" + _css_const__WEBPACK_IMPORTED_MODULE_1__["LIST_ITEM_CLASS"]] = { - listStyleType: 'none', - marginBottom: '4px', - }, - _a["" + _css_const__WEBPACK_IMPORTED_MODULE_1__["MARKER_CLASS"]] = { - width: '8px', - height: '8px', - borderRadius: '50%', - display: 'inline-block', - marginRight: '8px', - }, - _a["" + _css_const__WEBPACK_IMPORTED_MODULE_1__["VALUE_CLASS"]] = { - display: 'inline-block', - float: 'right', - marginLeft: '30px', - }, - _a["" + _css_const__WEBPACK_IMPORTED_MODULE_1__["CROSSHAIR_X"]] = { - position: 'absolute', - width: '1px', - backgroundColor: 'rgba(0, 0, 0, 0.25)', - }, - _a["" + _css_const__WEBPACK_IMPORTED_MODULE_1__["CROSSHAIR_Y"]] = { - position: 'absolute', - height: '1px', - backgroundColor: 'rgba(0, 0, 0, 0.25)', - }, - _a); -//# sourceMappingURL=html-theme.js.map - -/***/ }), - -/***/ "./node_modules/@antv/component/esm/tooltip/html.js": -/*!**********************************************************!*\ - !*** ./node_modules/@antv/component/esm/tooltip/html.js ***! - \**********************************************************/ -/*! exports provided: default */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "./node_modules/tslib/tslib.es6.js"); -/* harmony import */ var _antv_dom_util__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @antv/dom-util */ "./node_modules/@antv/dom-util/esm/index.js"); -/* harmony import */ var _antv_util__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @antv/util */ "./node_modules/@antv/util/esm/index.js"); -/* harmony import */ var _antv_color_util__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @antv/color-util */ "./node_modules/@antv/color-util/esm/index.js"); -/* harmony import */ var _abstract_html_component__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstract/html-component */ "./node_modules/@antv/component/esm/abstract/html-component.js"); -/* harmony import */ var _util_util__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../util/util */ "./node_modules/@antv/component/esm/util/util.js"); -/* harmony import */ var _css_const__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./css-const */ "./node_modules/@antv/component/esm/tooltip/css-const.js"); -/* harmony import */ var _html_theme__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./html-theme */ "./node_modules/@antv/component/esm/tooltip/html-theme.js"); -/* harmony import */ var _util_align__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../util/align */ "./node_modules/@antv/component/esm/util/align.js"); - - - - - - - - - -function toPx(number) { - return number + "px"; -} -function hasOneKey(obj, keys) { - var result = false; - Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["each"])(keys, function (key) { - if (Object(_antv_util__WEBPACK_IMPORTED_MODULE_2__["hasKey"])(obj, key)) { - result = true; - return false; - } - }); - return result; -} -var Tooltip = /** @class */ (function (_super) { - Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"])(Tooltip, _super); - function Tooltip() { - return _super !== null && _super.apply(this, arguments) || this; - } - Tooltip.prototype.getDefaultCfg = function () { - var cfg = _super.prototype.getDefaultCfg.call(this); - return Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])(Object(tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"])({}, cfg), { name: 'tooltip', type: 'html', x: 0, y: 0, items: [], containerTpl: "1&&(e*=b=Math.sqrt(b),r*=b);var _=e*e,w=r*r,P=(i===o?-1:1)*Math.sqrt(Math.abs((_*w-_*x*x-w*M*M)/(_*x*x+w*M*M)));p=P*e*x/r+(t+u)/2,d=P*-r*M/e+(n+s)/2,l=Math.asin(((n-d)/r).toFixed(9)),h=Math.asin(((s-d)/r).toFixed(9)),l=t
h&&(l-=2*Math.PI),!o&&h>l&&(h-=2*Math.PI)}var A=h-l;if(Math.abs(A)>v){var O=h,S=u,C=s;h=l+v*(o&&h>l?1:-1),u=p+e*Math.cos(h),s=d+r*Math.sin(h),y=q(u,s,e,r,a,0,o,S,C,[h,O,p,d])}A=h-l;var E=Math.cos(l),j=Math.sin(l),k=Math.cos(h),T=Math.sin(h),I=Math.tan(A/4),B=4/3*e*I,R=4/3*r*I,Y=[t,n],D=[t+B*j,n-R*E],N=[u+B*T,s-R*k],F=[u,s];if(D[0]=2*Y[0]-D[0],D[1]=2*Y[1]-D[1],c)return[D,N,F].concat(y);for(var L=[],X=0,z=(y=[D,N,F].concat(y).join().split(",")).length;X 1&&(n*=x=Math.sqrt(x),r*=x);var _=n*n,w=r*r,A=(a===o?-1:1)*Math.sqrt(Math.abs((_*w-_*b*b-w*M*M)/(_*b*b+w*M*M)));p=A*n*b/r+(t+u)/2,d=A*-r*M/n+(e+s)/2,f=Math.asin(((e-d)/r).toFixed(9)),h=Math.asin(((s-d)/r).toFixed(9)),f=t h&&(f-=2*Math.PI),!o&&h>f&&(h-=2*Math.PI)}var P=h-f;if(Math.abs(P)>v){var S=h,O=u,C=s;h=f+v*(o&&h>f?1:-1),u=p+n*Math.cos(h),s=d+r*Math.sin(h),y=L(u,s,n,r,i,0,o,O,C,[h,S,p,d])}P=h-f;var T=Math.cos(f),E=Math.sin(f),k=Math.cos(h),j=Math.sin(h),I=Math.tan(P/4),B=4/3*n*I,N=4/3*r*I,D=[t,e],R=[t+B*E,e-N*T],q=[u+B*j,s-N*k],F=[u,s];if(R[0]=2*D[0]-R[0],R[1]=2*D[1]-R[1],c)return[R,q,F].concat(y);for(var Y=[],G=0,X=(y=[R,q,F].concat(y).join().split(",")).length;G=0&&g1&&(e*=Math.sqrt(m),i*=Math.sqrt(m));var M=e*e*(y*y)+i*i*(g*g),x=M?Math.sqrt((e*e*(i*i)-M)/M):1;f===l&&(x*=-1),isNaN(x)&&(x=0);var b=i?x*e*y/i:0,_=e?x*-i*g/e:0,w=(h+d)/2+Math.cos(c)*b-Math.sin(c)*_,P=(p+v)/2+Math.sin(c)*b+Math.cos(c)*_,A=[(g-b)/e,(y-_)/i],O=[(-1*g-b)/e,(-1*y-_)/i],S=u([1,0],A),C=u(A,O);return o(A,O)<=-1&&(C=Math.PI),o(A,O)>=1&&(C=0),0===l&&C>0&&(C-=2*Math.PI),1===l&&C<0&&(C+=2*Math.PI),{cx:w,cy:P,rx:s(t,[d,v])?0:e,ry:s(t,[d,v])?0:i,startAngle:S,endAngle:S+C,xRotation:c,arcFlag:f,sweepFlag:l}}},function(t,n,e){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var r=e(83),a=/[a-z]/;function i(t,n){return[n[0]+(n[0]-t[0]),n[1]+(n[1]-t[1])]}n.default=function(t){var n=r.default(t);if(!n||!n.length)return[["M",0,0]];for(var e=!1,o=0;om&&(m=b)}return{x:f,y:y,width:l-f,height:m-y}},length:function(t,n,e,r,a,i,o){},nearestPoint:function(t,n,e,r,i,o,c,f,l){var h=s(f-t,l-n,-i),p=h[0],d=h[1],v=a.default.nearestPoint(0,0,e,r,p,d),g=function(t,n,e,r){return(Math.atan2(r*t,e*n)+2*Math.PI)%(2*Math.PI)}(e,r,v.x,v.y);g=0&&g1&&(n*=Math.sqrt(m),a*=Math.sqrt(m));var M=n*n*(y*y)+a*a*(g*g),b=M?Math.sqrt((n*n*(a*a)-M)/M):1;l===f&&(b*=-1),isNaN(b)&&(b=0);var x=a?b*n*y/a:0,_=n?b*-a*g/n:0,w=(h+d)/2+Math.cos(c)*x-Math.sin(c)*_,A=(p+v)/2+Math.sin(c)*x+Math.cos(c)*_,P=[(g-x)/n,(y-_)/a],S=[(-1*g-x)/n,(-1*y-_)/a],O=u([1,0],P),C=u(P,S);return o(P,S)<=-1&&(C=Math.PI),o(P,S)>=1&&(C=0),0===f&&C>0&&(C-=2*Math.PI),1===f&&C<0&&(C+=2*Math.PI),{cx:w,cy:A,rx:s(t,[d,v])?0:n,ry:s(t,[d,v])?0:a,startAngle:O,endAngle:O+C,xRotation:c,arcFlag:l,sweepFlag:f}}},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function t(){this._events={}}return t.prototype.on=function(t,e,n){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!n}),this},t.prototype.once=function(t,e){return this.on(t,e,!0),this},t.prototype.emit=function(t){for(var e=this,n=[],r=1;rm&&(m=x)}return{x:l,y:y,width:f-l,height:m-y}},length:function(t,e,n,r,i,a,o){},nearestPoint:function(t,e,n,r,a,o,c,l,f){var h=s(l-t,f-e,-a),p=h[0],d=h[1],v=i.default.nearestPoint(0,0,n,r,p,d),g=function(t,e,n,r){return(Math.atan2(r*t,n*e)+2*Math.PI)%(2*Math.PI)}(n,r,v.x,v.y);g=0?e:n<=0?n:0},e.prototype.createAttrOption=function(t,e,n){if(o.isNil(e)||o.isObject(e))o.isObject(e)&&o.isEqual(Object.keys(e),["values"])?o.set(this.attributeOption,t,{fields:e.values}):o.set(this.attributeOption,t,e);else{var r={};o.isNumber(e)?r.values=[e]:r.fields=g.parseFields(e),n&&(o.isFunction(n)?r.callback=n:r.values=n),o.set(this.attributeOption,t,r)}},e.prototype.initAttributes=function(){var t=this,e=this.attributes,n=this.attributeOption,i=this.theme,s=this.shapeType;o.each(n,(function(n,u){if(n){var c=r.__assign({},n),l=c.callback,h=c.values,f=c.fields,p=void 0===f?[]:f,d=o.map(p,(function(e){return t.scales[e]}));c.scales=d,"position"!==u&&1===d.length&&"identity"===d[0].type?c.values=d[0].values:l||h||("size"===u?c.values=i.sizes:"shape"===u?c.values=i.shapes[s]||[]:"color"===u&&(d.length?c.values=d[0].values.length<=10?i.colors10:i.colors20:c.values=i.colors10));var g=a.getAttribute(u);e[u]=new g(c)}}))},e.prototype.processData=function(t){var e=this,n=this.groupData(t);n=o.map(n,(function(t){var n=e.saveOrigin(t);return e.numeric(n),n}));var r=this.adjustData(n);return this.beforeMappingData=r,r},e.prototype.adjustData=function(t){var e=this,n=this.adjustOption,a=t;if(n){var s=this.getXScale(),u=this.getYScale(),c=s.field,l=u?u.field:null;n.forEach((function(t){var n=r.__assign({xField:c,yField:l},t),h=t.type;if("dodge"===h){var f=[];if(s.isCategory||"identity"===s.type)f.push("x");else{if(u)throw new Error("dodge is not support linear attribute, please use category attribute!");f.push("y")}n.adjustNames=f,n.dodgeRatio=e.theme.columnWidthRatio}else if("stack"===h){var p=e.coordinate;if(!u){n.height=p.getHeight();var d=e.getDefaultValue("size")||3;n.size=d}!p.isTransposed&&o.isNil(n.reverseOrder)&&(n.reverseOrder=!0)}var g=new(i.getAdjust(h))(n);a=g.process(a),e.adjusts[h]=g}))}return a},e.prototype.groupData=function(t){for(var e=this.getGroupScales(),n=this.scaleDefs,r={},i=[],a=0,s=e;a>>1;r(t[u])>e?s=u:o=u+1}return o})(T,(e-t)/n)-1,o=T[a];return a<0?o=T[0]:a>=T.length&&(o=Object(i.last)(T)),o}var j=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return Object(c.__extends)(e,t),e.prototype.translate=function(t){t=P(t);var e=this.values.indexOf(t);return-1===e&&(e=Object(i.isNumber)(t)&&t=0?1:-1;return Math.pow(a,n)*o},e.prototype.initCfg=function(){this.tickMethod="pow",this.exponent=2,this.tickCount=5,this.nice=!0},e.prototype.getScalePercent=function(t){var e=this.max,n=this.min;if(e===n)return 0;var r=this.exponent;return(D(r,t)-D(r,n))/(D(r,e)-D(r,n))},e}(L),G=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.type="time",e}return Object(c.__extends)(e,t),e.prototype.getText=function(t,e){var n=this.translate(t),r=this.formatter;return r?r(n,e):A(n,this.mask)},e.prototype.scale=function(e){var n=e;return(Object(i.isString)(n)||Object(i.isDate)(n))&&(n=this.translate(n)),t.prototype.scale.call(this,n)},e.prototype.translate=function(t){return P(t)},e.prototype.initCfg=function(){this.tickMethod="time-pretty",this.mask="YYYY-MM-DD",this.tickCount=7,this.nice=!1},e.prototype.setDomain=function(){var t=this.values,e=this.getConfig("min"),n=this.getConfig("max");if(Object(i.isNil)(e)&&Object(i.isNumber)(e)||(this.min=this.translate(this.min)),Object(i.isNil)(n)&&Object(i.isNumber)(n)||(this.max=this.translate(this.max)),t&&t.length){var r=[],a=1/0,o=a,s=0;Object(i.each)(t,(function(t){var e=P(t);if(isNaN(e))throw new TypeError("Invalid Time: "+t+" in time scale!");a>e?(o=a,a=e):o>e&&(o=e),s