![]() System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, Directory : /var/www/html/libs/absol-full/dist/js/ |
Upload File : |
/*** module: node_modules/absol-vchart/src/HorizontalRankChart.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _VCore = _interopRequireWildcard(require("./VCore")); var _SvgCanvas = _interopRequireDefault(require("absol-svg/js/svg/SvgCanvas")); var _KeyNote = require("./KeyNote"); var _utils = require("absol-acomp/js/utils"); var _SelectColorSchemeMenu = require("absol-acomp/js/colorpicker/SelectColorSchemeMenu"); var _BChart = _interopRequireWildcard(require("./BChart")); var _AElement = _interopRequireDefault(require("absol/src/HTML5/AElement")); var _helper = require("./helper"); var _Turtle = _interopRequireDefault(require("absol/src/Math/Turtle")); var _int = require("absol/src/Math/int"); var _Object = require("absol/src/DataStructure/Object"); var _DelaySignal = _interopRequireDefault(require("absol/src/HTML5/DelaySignal")); var _HorizontalRangeChart = require("./HorizontalRangeChart"); var _OOP = require("absol/src/HTML5/OOP"); function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } /** * @extends SvgCanvas * @constructor */ function HorizontalRankChart() { this.resizeCtrl = new _BChart.ChartResizeController(this); this.titleCtrl = new _BChart.ChartTitleController(this); this.fixedAxisCtrl = new _HorizontalRangeChart.HRCFixedAxisController(this); this.$attachhook.once('attached', () => { this.fixedAxisCtrl.start(); this.updateContent(); }); this.$title = (0, _VCore.$)('.vc-title', this); this.$body = (0, _VCore.$)('.vc-body', this); this.$axis = (0, _VCore.$)('.vchart-axis', this); this.$oxy = (0, _VCore.$)('#oxy', this); this.$oxArrow = (0, _VCore.$)('#ox-arrow', this); this.$oyLabelCtn = (0, _VCore.$)('.vc-oy-label-ctn', this); this.$oxLabelCtn = (0, _VCore.$)('.vc-ox-label-ctn', this); this.$grid = (0, _VCore.$)('.vc-grid', this); this.$valueName = (0, _VCore.$)('.vc-value-name', this); this.$postionCtn = (0, _VCore.$)('.vc-postion-ctn', this); this.$fixedContentRef = (0, _VCore.$)('.vc-fixed-content-ref', this); this.$oyLabels = []; this.cpData = null; this.colors = ['white', 'rgb(201, 241, 253)', 'rgb(212, 227, 252)', 'rgb(218, 202, 251)', 'rgb(242, 201, 251)', 'rgb(255, 218, 216)', 'rgb(255, 236, 215)', 'rgb(254, 252, 224)', 'rgb(223, 237, 214)', 'rgb(77, 215, 250)', 'rgb(117, 169, 249)', 'rgb(139, 81, 245)', 'rgb(215, 87, 246)', 'rgb(255, 138, 132)', 'rgb(152, 165, 52)', 'rgb(254, 248, 160)', 'rgb(174, 221, 148)', 'rgb(0, 164, 221)', 'rgb(20, 100, 246)', 'rgb(156, 41, 183)']; this.domSignal = new _DelaySignal.default(); this.domSignal.on('updateContent', () => { if (this.isDescendantOf(document.body)) { this.fixedAxisCtrl.start(); this.updateContent(); } }); (0, _OOP.drillProperty)(this, this, 'computedData', 'cpData'); (0, _Object.observePropertyChanges)(this, this.dataKeys, () => this.domSignal.emit('updateContent')); /** * @name positions * @type {{name: string, ranks:number[]}[]} * @memberof HorizontalRankChart# */ /** * @name valueName * @type {string} * @memberof HorizontalRangeChart# */ } HorizontalRankChart.tag = 'HorizontalRankChart'.toLowerCase(); HorizontalRankChart.render = function (data, o, dom) { var res = (0, _VCore._)({ tag: _SvgCanvas.default, class: ['vc-chart', 'vc-horizontal-rank-chart', 'as-height-auto'], style: {}, child: [{ tag: 'text', class: 'vc-title', attr: { 'alignment-baseline': "hanging" }, child: { text: '' } }, { tag: 'rect', class: 'vc-fixed-content-ref', attr: { width: '10', height: '33' }, style: { fill: 'transparent', stroke: 'none' } }, { tag: _KeyNote.KeyNoteGroup }, { tag: 'gcontainer', class: 'vc-body', child: [{ tag: 'path', class: 'vc-grid' }, { tag: 'gcontainer', class: 'vchart-axis', child: [{ tag: 'path', id: 'oxy', attr: { d: 'm0 -1v1 h1', fill: 'none' } }, { tag: 'path', id: "ox-arrow", attr: { d: 'm0 -5v10l6.8 -5z' } }] }, { tag: 'text', class: 'vc-value-name', child: { text: '' } }, { tag: 'gcontainer', class: 'vc-oy-label-ctn' }, { tag: 'gcontainer', class: 'vc-ox-label-ctn' }, { tag: 'gcontainer', class: 'vc-postion-ctn' }] }] }); var colorScheme = o && o.props && o.props.colorScheme; if ((0, _utils.isNaturalNumber)(colorScheme)) { colorScheme = Math.max(0, Math.min(_SelectColorSchemeMenu.DEFAULT_CHART_COLOR_SCHEMES.length, colorScheme)); res.attr('data-color-scheme', colorScheme + ''); } return res; }; HorizontalRankChart.prototype.dataKeys = _BChart.default.prototype.dataKeys.concat(['position', 'valueName']); HorizontalRankChart.prototype.revokeResource = function () { (0, _Object.unobservePropertyChanges)(this, this.dataKeys); (0, _utils.revokeResource)(this.titleCtrl); (0, _utils.revokeResource)(this.resizeCtrl); (0, _utils.revokeResource)(this.domSignal); this.fixedAxisCtrl.revokeResource(); while (this.lastChild) { this.lastChild.remove(); } }; HorizontalRankChart.prototype.addStyle = function (arg0, arg1) { if (arg0 === 'height') { if (arg1 === 'auto') { this.addClass('as-height-auto'); } } else { this.removeClass('as-height-auto'); _AElement.default.prototype.addStyle.apply(this, arguments); } return this; }; HorizontalRankChart.prototype.computeData = function () { var positions = Array.isArray(this.positions) ? this.positions : []; this.cpData = {}; this.cpData.min = positions.reduce((ac, cr) => { return Math.min.apply(Math, [ac].concat(_toConsumableArray(cr.ranks))); }, Infinity); this.cpData.count = positions.reduce((ac, cr) => { return Math.max(ac, cr.ranks.length); }, 0); this.cpData.max = positions.reduce((ac, cr) => { return Math.max.apply(Math, [ac].concat(_toConsumableArray(cr.ranks))); }, -Infinity); if (this.cpData.min > this.cpData.max) { this.cpData = 0; this.cpData.max = 0; } this.cpData.max += 1; if (this.zeroOY) this.cpData.min = Math.min(this.cpData.min, 0); this.colors = this.cpData.count < 10 ? ["#FF5733", // Bright Orange "#33FF57", // Bright Green "#3357FF", // Bright Blue "#FF33A8", // Bright Pink "#FF3333", // Bright Red "#33FFF5", // Bright Cyan "#FFFF33", // Bright Yellow "#FF8C33", // Bright Coral "#33FF8C", // Bright Mint "#8C33FF" // Bright Purple ] : ["#FF5733", // Bright Orange "#33FF57", // Bright Green "#3357FF", // Bright Blue "#FF33A8", // Bright Pink "#FF3333", // Bright Red "#33FFF5", // Bright Cyan "#FFFF33", // Bright Yellow "#FF8C33", // Bright Coral "#33FF8C", // Bright Mint "#8C33FF", // Bright Purple "#FF5733", // Bright Orange "#33FF57", // Bright Green "#3357FF", // Bright Blue "#FF33A8", // Bright Pink "#FF3333", // Bright Red "#33FFF5", // Bright Cyan "#FFFF33", // Bright Yellow "#FF8C33", // Bright Coral "#33FF8C", // Bright Mint "#8C33FF" // Bright Purple ]; }; HorizontalRankChart.prototype.createOYLabel = function () { var positions = Array.isArray(this.positions) ? this.positions : []; this.$oyLabels = positions.map(it => { return (0, _VCore._)({ tag: 'text', attr: { 'alignment-baseline': "middle" }, child: { text: it.name } }); }); this.$oyLabelCtn.addChild(this.$oyLabels); }; HorizontalRankChart.prototype.createPositions = function () { var positions = Array.isArray(this.positions) ? this.positions : []; this.$position = positions.map(it => { var elt = (0, _VCore._)({ tag: 'gcontainer' }); elt.$line = (0, _VCore._)({ tag: 'path', style: { stroke: 'rgb(69, 69, 72)', 'stroke-width': 3 } }); elt.addChild(elt.$line); elt.$ranks = it.ranks.map((r, i) => { return (0, _VCore._)({ tag: 'gcontainer', class: 'rank-chart-group', attr: { title: this.numberToString(r) }, child: [{ tag: 'circle', class: 'vc-circle-plot', style: { fill: this.colors[i], stroke: 'black', strokeWidth: 2 }, attr: { r: 8, x: 0, y: 0 } }] }); }); elt.addChild(elt.$ranks); return elt; }); this.$postionCtn.clearChild().addChild(this.$position); }; HorizontalRankChart.prototype.updateContentPosition = function () { if (!this.cpData) return; var i, j; var width = this.box.width || 0; var positions = Array.isArray(this.positions) ? this.positions : []; var y = 5; this.$title.attr('x', width / 2).attr('y', y); y += 30; var oyLabelWidth = this.$oyLabels.reduce((ac, cr) => Math.max(ac, cr.getBBox().width), 0); oyLabelWidth = Math.ceil(oyLabelWidth); var spacing = 40; this.$body.box.y = y + 24; this.$body.box.x = oyLabelWidth + 10; this.$body.box.width = width - this.$body.box.x - 10; this.$oyLabelCtn.box.x = -this.$body.box.x; this.$axis.box.width = this.$body.box.width; this.$oxArrow.attr('d', 'M' + this.$axis.box.width + ' 0 m0 -5v10l6.8 -5z'); this.$axis.box.height = spacing * this.$oyLabels.length; var valueNameWidth = this.$valueName.getBBox().width; this.$valueName.attr('x', this.$axis.box.width).attr('y', -8); this.$fixedContentRef.attr('y', this.$body.box.y - 24); this.$fixedContentRef.attr('width', this.$body.box.width + this.$body.box.x + 8); /** * * @type {Turtle} */ var turtle = new _Turtle.default().moveTo(this.$axis.box.width, 0).hLineTo(0).vLineTo(this.$axis.box.height); var dx = Math.max(100, Math.floor(20 + (0, _helper.measureArial14TextWidth)(this.numberToString(this.cpData.max)))); var sm = (0, _helper.calBeautySegment)(Math.floor((this.$axis.box.width - valueNameWidth - 10 - dx / 2) / dx), this.cpData.min, this.cpData.max + 1); this.cpData.sm = sm; dx = Math.floor((this.$axis.box.width - valueNameWidth - 10 - dx / 2) / sm.segmentCount); var dv = (sm.maxValue - sm.minValue) / sm.segmentCount; this.cpData.dx = dx; this.cpData.dv = dv; turtle.moveTo(0, 2); for (i = 0; i < sm.segmentCount; ++i) { turtle.moveBy(dx, -4); turtle.vLineBy(4); } this.$oxy.attr('d', turtle.getPath()); this.$oyLabels.forEach((elt, i) => { elt.attr('y', i * spacing + spacing / 2); }); while (this.$oxLabelCtn.childNodes.length > sm.segmentCount + 1) this.$oxLabelCtn.lastChild.remove(); while (this.$oxLabelCtn.childNodes.length < sm.segmentCount + 1) this.$oxLabelCtn.addChild((0, _VCore._)({ tag: 'text', style: { textAnchor: 'middle' }, attr: { y: -8 }, child: { text: '' } })); Array.prototype.forEach.call(this.$oxLabelCtn.childNodes, (elt, i) => { elt.firstChild.data = this.numberToString(sm.minValue + i * dv); elt.attr('x', dx * i); }); /***** draw grid *******/ turtle = new _Turtle.default(); var oxLength = this.$axis.box.width - 5; turtle.moveTo(oxLength, 0); for (i = 0; i < positions.length; ++i) { turtle.moveBy(-oxLength, spacing).hLineBy(oxLength); } turtle.moveTo(0, spacing * positions.length, 0); for (i = 0; i < sm.segmentCount; ++i) { turtle.moveBy(dx, -spacing * positions.length).vLineBy(spacing * positions.length); } this.$grid.attr('d', turtle.getPath()); this.$position.forEach((elt, i) => { elt.box.y = i * spacing + spacing / 2; var position = positions[i]; for (var k = 0; k < position.ranks.length; ++k) { elt.$ranks[k].box.x = (0, _helper.map)(position.ranks[k] - sm.minValue, 0, dv, 0, dx); } if (position.ranks.length > 0) elt.$line.attr('d', `M${(0, _helper.map)(position.ranks[0] - sm.minValue, 0, dv, 0, dx)} 0 L${(0, _helper.map)(position.ranks[position.ranks.length - 1] - sm.minValue, 0, dv, 0, dx)} 0`); }); //auto size this.$body.box.height = this.$axis.box.height + 10; //10px: padding button this.box.height = this.$body.box.y + this.$body.box.height; this.fixedAxisCtrl.updateContentPosition(); }; HorizontalRankChart.prototype.numberToString = function () { return _int.numberToString.apply(this, arguments); }; HorizontalRankChart.prototype.updateContent = function () { this.computeData(); this.$title.firstChild.data = this.title; this.$valueName.firstChild.data = this.valueName || ''; this.createOYLabel(); this.createPositions(); this.fixedAxisCtrl.updateContent(); this.updateContentPosition(); }; HorizontalRankChart.prototype.updateSize = function () { _SvgCanvas.default.prototype.updateSize.call(this); this.updateContentPosition(); }; _VCore.default.install(HorizontalRankChart); var _default = HorizontalRankChart; exports.default = _default;