![]() 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/RankChart.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _VCore = _interopRequireDefault(require("./VCore")); var _template = require("./template"); var _helper = require("./helper"); var _ToolTip = require("./ToolTip"); var _BChart = _interopRequireDefault(require("./BChart")); var _OOP = _interopRequireDefault(require("absol/src/HTML5/OOP")); var _VerticalChart = _interopRequireDefault(require("./VerticalChart")); var _ColumnChart = _interopRequireDefault(require("./ColumnChart")); var _GContainer = _interopRequireDefault(require("absol-svg/js/svg/GContainer")); require("./style/rankchart.css"); var _ = _VCore.default._; var $ = _VCore.default.$; /*** * @extends BChart * @constructor */ function RankChart() { _BChart.default.call(this); _OOP.default.drillProperty(this, this, 'numberToString', 'numberToText'); this.colors = ['transparent', '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.computedData.oyUpdated = false; this.computedData.oy = {}; this.computedData.numberToFixed = 0; this.integerOnly = false; this.positions = []; this.valueName = ''; this.plotRadius = 9; this.zeroOY = true; this.extendOY = true; this.computedData.paddingAxisBottom = this.plotRadius + 30; this.$axisCtn = _({ tag: _GContainer.default.tag, class: 'vc-axis-ctn', child: [{ tag: 'gcontainer', class: 'vc-oxy-space', child: ['gcontainer.vc-ox-label-ctn', 'gcontainer.vc-rank-list-ctn'] }, { tag: 'path', class: 'vc-white-mask', attr: { fill: 'white', stroke: 'white', 'fill-rule': 'evenodd', d: 'M0,0 0,2000 2000,2000 2000,0zM100,0 0,200 200,200 200,0z' } }, 'axis', { tag: 'text', class: 'vc-key-name', attr: { y: 14, x: 5 }, child: { text: '' } }, 'scrollarrow', 'hscrollbar', { tag: 'text', class: 'vc-value-name', attr: { y: 14, x: 5 }, child: { text: '' } }] }); this.$body.addChild(this.$axisCtn); this.$hscrollbar = $('hscrollbar', this.$axisCtn).on('scroll', this.eventHandler.scrollOxySpace); this.$hscrollbar.height = 10; this.$scrollArrow = $('scrollarrow', this.$axisCtn).on('pressleft', this.eventHandler.scrollArrowsPressLeft).on('pressright', this.eventHandler.scrollArrowsPressRight); this.$oxySpace = $('gcontainer.vc-oxy-space', this.$axisCtn); this.$whiteMask = $('.vc-white-mask', this.$axisCtn); this.$axis = $('axis', this.$axisCtn); this.$keyName = $('.vc-key-name', this.$axisCtn); this.$valueName = $('.vc-value-name', this.$axisCtn); this.$oxLabelCtn = $('gcontainer.vc-ox-label-ctn', this.$axisCtn); this.$oxLabels = []; this.$oyValueCtn = _('gcontainer.vc-oy-value-ctn').addTo(this.$body); this.$oyValues = []; this.$postion = []; this.$rankListCtn = $('.vc-rank-list-ctn', this.$axisCtn); } RankChart.tag = 'RankChart'.toLowerCase(); RankChart.property = Object.assign({}, _VerticalChart.default.property); RankChart.eventHandler = Object.assign({}, _VerticalChart.default.eventHandler); _OOP.default.mixClass(RankChart, _VerticalChart.default); RankChart.render = function () { return _BChart.default.render().addClass('vc-rank-chart'); }; RankChart.prototype.updateBodyPosition = function () { this._isAutoWidth = this.style.width === 'auto'; if (this._isAutoWidth) this.addStyle('width', '450px'); _VerticalChart.default.prototype.updateBodyPosition.call(this); this._updateOyDivision(); this._updatePosListPosition(); this._updateScrollerPosition(); if (this._isAutoWidth) { this._isAutoWidth = false; this.addStyle('width', this.contentPadding * 2 + this.$oyValueCtn.box.x + this.$hscrollbar.innerWidth + this.$keyName.getBBox().width + 10 + 'px'); this.updateBodyPosition(); } }; RankChart.prototype.createContent = function () { _BChart.default.prototype.createContent.call(this); this._createOxLabel(); this._createPosList(); }; RankChart.prototype.computeData = _VerticalChart.default.prototype.computeData; RankChart.prototype.computeMinMax = function () { var min = Infinity, max = -Infinity; this.positions.forEach(function (position) { position.ranks.forEach(function (rank) { min = Math.min(min, rank); max = Math.max(max, rank); }); }); this.computedData.min = min; this.computedData.max = max + 1; }; RankChart.prototype._createOxLabel = function () { this.$keyName.firstChild.data = this.valueName; this.$oxLabelCtn.clearChild(); this.$oxLabels = this.positions.map(function (position) { return _({ tag: 'text', class: 'vc-ox-label', child: { text: position.name } }); }); this.$oxLabelCtn.addChild(this.$oxLabels); this.$valueName.firstChild.data = this.valueName || ''; }; RankChart.prototype._updateOxLabelPosition = function () { this.$oxLabelCtn.box.y = 20; }; RankChart.prototype._updateScrollerPosition = function () { this.computedData.oxOverFlow = this.computedData.oxScrollWidth > this.computedData.oxLength; this.$hscrollbar.outterWidth = this.computedData.oxLength; this.$hscrollbar.innerWidth = this.computedData.oxScrollWidth; this.$hscrollbar.width = Math.max(0, this.computedData.oxLength); // this.$hscrollbar.scrollLeft = Math.max(0, Math.min(this.$hscrollbar.scrollLeft, this.computedData.oxScrollWidth - this.computedData.oxLength)); this.$hscrollbar.scrollLeft = 0; if (this.computedData.oxOverFlow) { this.$scrollArrow.removeStyle('display'); this.$scrollArrow.box.y = this.computedData.oyLength / 2; this.$scrollArrow.width = this.computedData.oxLength - 20; this._updateScrollArrowBtb(); } else { this.$scrollArrow.addStyle('display', 'none'); } this.$axis.oyDivision = this.computedData.oySegmentLength; this.$axis.updateOyDivision(); }; RankChart.prototype._updateOyDivision = function (value) { this.$axis.oyDivision = this.computedData.oySegmentLength; this.$axis.oyPadding = this.computedData.paddingAxisBottom; this.$axis.updateOyDivision(); }; RankChart.prototype.mapOYValue = function (val) { return this.computedData.paddingAxisBottom + (0, _helper.map)(val, this.computedData.oy.minValue, this.computedData.oy.maxValue, 0, this.computedData.oyLength); }; RankChart.prototype._createRank = function (rank, value) { var res = _({ tag: 'g', class: 'rank-chart-group', child: [{ tag: 'circle', class: 'rank-chart-plot', attr: { cx: this.plotRadius, cy: 0, r: this.plotRadius }, style: { fill: this.colors[rank] } }, { tag: 'text', class: 'rank-chart-plot-text', attr: { x: this.plotRadius, y: 5, 'text-anchor': 'middle' }, props: { innerHTML: rank + 1 + '' } }] }); res.attr('title', this.numberToString(value)); return res; }; RankChart.prototype.numberToString = function (num) { return num.toString(); }; RankChart.prototype._createPosition = function (position) { var res = _({ tag: _GContainer.default.tag }); res.$ranks = position.ranks.map(function (value, rank) { return this._createRank(rank, value); }.bind(this)); res.$rect = _({ tag: 'rect', class: 'vc-rank-position-list-rect', attr: { x: '0', y: '0' } }); res.addChild(res.$rect).addChild(res.$ranks); return res; }; RankChart.prototype._createPosList = function () { this.$positions = this.positions.map(this._createPosition.bind(this)); this.$rankListCtn.clearChild().addChild(this.$positions); }; RankChart.prototype._updatePosListPosition = function () { var contentLength = this.$positions.reduce(function (contentLength, pe, positionIndex) { var position = this.positions[positionIndex]; contentLength = contentLength + 20; var maxDY = pe.$ranks.reduce(function (maxDY, meme, j) { var value = position.ranks[j]; var y = -this.mapOYValue(value); meme.attr('transform', (0, _template.translate)(contentLength, y)); meme._tr_y = y; return Math.max(maxDY, -y); }.bind(this), 0); var valueElements = pe.$ranks.slice(); valueElements.sort(function (a, b) { return a._tr_y - b._tr_y; }); var ninf = -1000000; var messure = valueElements.reduce(function (ac, e) { var y = e._tr_y; var colIndex = 0; while (ac[colIndex].minY > y) ++colIndex; ac[colIndex].minY = y + 20; ac[colIndex].child.push(e); ac[colIndex].maxWidth = Math.max(ac[colIndex].maxWidth, e.getBBox().width); return ac; }, Array(200).fill(null).map(function () { return { minY: ninf, child: [], maxWidth: ninf }; })); messure.reduce(function (left, col) { if (col.child.length == 0) return; col.child.forEach(function (vale) { vale.attr('transform', (0, _template.translate)(left, vale._tr_y)); }); return left + col.maxWidth + 9; }, 10); pe.$rect.addStyle('display', 'none'); var innerWidth = pe.getBBox().width; pe.$rect.removeStyle('display'); pe.$rect.attr({ width: innerWidth + 20, y: -maxDY - (this.plotRadius + 10), height: maxDY + this.plotRadius + 10 }); var columeWidth = Math.max(pe.getBBox().width + 20, this.$oxLabels[positionIndex].getBBox().width + 10); this.$oxLabels[positionIndex].attr('x', contentLength + columeWidth / 2); pe.box.x = contentLength + columeWidth / 2 - (innerWidth + 20) / 2; contentLength += columeWidth; return contentLength; }.bind(this), 9); this.computedData.oxScrollWidth = contentLength; }; _VCore.default.install(RankChart); var _default = RankChart; exports.default = _default;