![]() 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/SimplerBarChart.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _VCore = _interopRequireWildcard(require("./VCore")); var _BChart = _interopRequireDefault(require("./BChart")); var _OOP = _interopRequireDefault(require("absol/src/HTML5/OOP")); var _utils = require("absol-acomp/js/utils"); var _SelectColorSchemeMenu = require("absol-acomp/js/colorpicker/SelectColorSchemeMenu"); var _helper = require("./helper"); var _Color = _interopRequireDefault(require("absol/src/Color/Color")); var _SimpleColumnChart = _interopRequireDefault(require("./SimpleColumnChart")); /** * @extends BChart * @constructor */ function SimpleBarChart() { _BChart.default.apply(this, arguments); this.keys = []; this.values = []; this.texts = []; this.fillColors = []; this.$rows = []; this.$texts = []; } _OOP.default.mixClass(SimpleBarChart, _BChart.default); SimpleBarChart.tag = 'SimpleBarChart'.toLowerCase(); SimpleBarChart.render = function () { return _BChart.default.render.apply(this, arguments).addClass('vc-simple-bar-chart'); }; SimpleBarChart.prototype.computeNotes = _SimpleColumnChart.default.prototype.computeNotes; SimpleBarChart.prototype.normalizeData = _SimpleColumnChart.default.prototype.normalizeData; SimpleBarChart.prototype._createRows = function () { this.$rows.forEach(e => e.remove()); this.$texts.forEach(e => e.remove()); this.$rows = this.values.map((value, i) => { return (0, _VCore._)({ tag: 'rect', attr: { x: 0, y: 0 }, style: { fill: this.fillColors[i] } }); }); this.$body.addChild(this.$rows); this.$texts = this.texts.map((key, i) => { var color = this.fillColors[i]; color = typeof color === "string" ? _Color.default.parse(color) : color; color = color.getContrastYIQ().toString('hex6'); var res = (0, _VCore._)({ tag: 'text', class: 'vc-value-text', attr: { x: 10, y: 10 }, style: { color: color }, child: { text: key } }); return res; }); this.$body.addChild(this.$texts); }; SimpleBarChart.prototype._updateRowPosition = function () { var width = this.$body.box.width; var height = this.$body.box.height; if (width === 0) return; var rowHeight = Math.min(150, height / this.$rows.length); var y0 = (height - rowHeight * this.$rows.length) / 2; var maxValue = this._maxValue ? this._maxValue : 1; this.$rows.forEach((colElt, i) => { var rowWidth = (0, _helper.map)(this.values[i], 0, maxValue, 0, width); colElt.attr({ width: rowWidth, x: 0, height: rowHeight, y: y0 + i * rowHeight }); }); this.$texts.forEach((textElt, i) => { var rowWidth = (0, _helper.map)(this.values[i], 0, maxValue, 0, width); var box = textElt.getBBox(); var y = y0 + (i + 0.5) * rowHeight + box.height / 2; var x = rowWidth; if (rowWidth > box.width + 10) { textElt.removeStyle('fill'); x -= 5; textElt.addStyle('text-anchor', 'end'); } else { x += 5; textElt.addStyle('text-anchor', 'start'); textElt.addStyle('fill', 'black'); } textElt.attr({ x: x, y: y }); }); }; SimpleBarChart.prototype.createContent = function () { _BChart.default.prototype.createContent.call(this); this._createRows(); }; SimpleBarChart.prototype.updateBodyPosition = function () { _BChart.default.prototype.updateBodyPosition.call(this); this._updateRowPosition(); }; _VCore.default.install(SimpleBarChart); var _default = SimpleBarChart; exports.default = _default;