![]() 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/BChart.js ***/ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ChartResizeController = ChartResizeController; exports.ChartTitleController = ChartTitleController; exports.default = void 0; require("./style/base.css"); var _VCore = _interopRequireDefault(require("./VCore")); var _SvgCanvas = _interopRequireDefault(require("absol-svg/js/svg/SvgCanvas")); var _GContainer = _interopRequireDefault(require("absol-svg/js/svg/GContainer")); var _DomSignal = _interopRequireDefault(require("absol/src/HTML5/DomSignal")); var _ACore = _interopRequireDefault(require("absol-acomp/ACore")); var _ChartResizeBox = _interopRequireDefault(require("./ChartResizeBox")); var _EventEmitter = require("absol/src/HTML5/EventEmitter"); var _OOP = _interopRequireDefault(require("absol/src/HTML5/OOP")); var _utils = require("absol-acomp/js/utils"); var _SelectColorSchemeMenu = require("absol-acomp/js/colorpicker/SelectColorSchemeMenu"); var _KeyNote = _interopRequireDefault(require("./KeyNote")); var _Tooltip = _interopRequireDefault(require("absol-acomp/js/Tooltip")); var _noop = _interopRequireDefault(require("absol/src/Code/noop")); var _Object = require("absol/src/DataStructure/Object"); var _ = _VCore.default._; var $ = _VCore.default.$; /** * * @param chartElt * @constructor */ function ChartResizeController(chartElt) { this.chartElt = chartElt; this.ev_click = this.ev_click.bind(this); this.ev_clickOut = this.ev_clickOut.bind(this); this.chartElt.on('click', this.ev_click); } ChartResizeController.prototype.ev_click = function (event) { if (!this.chartElt.resizable) return; this.prepare(); if (this.share.$resizebox.isAttached(this.chartElt)) return; this.share.$resizebox.attachTo(this.chartElt); document.addEventListener('click', this.ev_clickOut); }; ChartResizeController.prototype.ev_clickOut = function (event) { if ((0, _EventEmitter.hitElement)(this.chartElt, event)) return; if (this.share.$resizebox.isAfterMoving()) return; if (this.share.$resizebox.isAttached(this.chartElt)) this.share.$resizebox.detach(); document.removeEventListener('click', this.ev_clickOut); }; ChartResizeController.prototype.revokeResource = function () { document.removeEventListener('click', this.ev_clickOut); }; ChartResizeController.prototype.share = { /** * @type {ChartResizeBox} */ $resizebox: null }; ChartResizeController.prototype.prepare = function () { if (this.share.$resizebox) return; this.share.$resizebox = _ACore.default._({ tag: _ChartResizeBox.default.tag }); }; /** * * @param {BChart} elt * @constructor */ function ChartTitleController(elt) { this.elt = elt; Object.keys(this.constructor.prototype).filter(key => key.startsWith('ev_')).forEach(key => this[key] = this[key].bind(this)); this.elt.on('mouseover', this.ev_mouseEnter).on('mouseout', this.ev_mouseOut); this.titleElt = null; this.contentElt = _ACore.default._({ tag: 'div', style: { font: '14px Arial' } }).on('mouseover', this.ev_mouseEnter).on('mouseout', this.ev_mouseOut); this.closeTO = -1; this.sessonToken = null; } ChartTitleController.prototype.revokeResource = function () { this.elt.off('mouseover', this.ev_mouseEnter).off('mouseout', this.ev_mouseOut); this.contentElt.off('mouseover', this.ev_mouseEnter).off('mouseout', this.ev_mouseOut); (0, _utils.revokeResource)(this.contentElt); delete this.elt; delete this.contentElt; this.revokeResource = (0, _noop.default)(); }; ChartTitleController.prototype.ev_mouseEnter = function (event) { if ((0, _EventEmitter.hitElement)(this.contentElt, event)) { clearTimeout(this.closeTO); return; } var hasTileElt = this.findTitleElt(event.target); if (hasTileElt) { clearTimeout(this.closeTO); if (hasTileElt !== this.titleElt) { this.titleElt = hasTileElt; this.sessonToken = _Tooltip.default.show(this.titleElt, this.makeTooltipContent(this.titleElt.attr('title'))); } } else { if (this.titleElt) { clearTimeout(this.closeTO); this.closeTO = setTimeout(() => { this.titleElt = null; _Tooltip.default.close(this.sessonToken); }, 500); } } }; ChartTitleController.prototype.ev_mouseOut = function (event) { if (this.titleElt && (event.target === this.titleElt || event.target === this.contentElt || event.target.isDescendantOf && !event.target.isDescendantOf(this.titleElt) && !event.target.isDescendantOf(this.contentElt))) { clearTimeout(this.closeTO); this.closeTO = setTimeout(() => { this.titleElt = null; _Tooltip.default.close(this.sessonToken); }, 500); } }; ChartTitleController.prototype.makeTooltipContent = function (text) { this.contentElt.clearChild(); return _ACore.default._({ elt: this.contentElt, child: text.split('\n').reduce((ac, cr) => { ac.push({ text: cr }, 'br'); return ac; }, []) }); }; ChartTitleController.prototype.findTitleElt = function (elt) { while (elt && elt !== this.elt) { if (elt.attr && elt.attr('title')) return elt; elt = elt.parentElement; } return null; }; /*** * @extends SvgCanvas * @constructor */ function BChart() { this.resizable = false; this.ready = false; this.contentPadding = 5; this.title = ''; this.domSignal = new _DomSignal.default($('sattachhook.vc-dom-signal', this)); this.domSignal.on({ updateContent: this.updateContent.bind(this) }); /** * @type {GContainer} */ this.$body = $('.vc-body', this); /** * @type {GContainer} */ this.$noteCtn = $('.vc-note-ctn', this); this.domSignal.emit('updateContent'); this.$title = $('.vc-title', this); this.computedData = { /*** * @type {Array<{color: Color, type: ("stroke"|"rect"), text:string}>} */ notes: [] }; this.resizeCtrl = new ChartResizeController(this); this.titleCtrl = new ChartTitleController(this); if (!this.numberToText) { _OOP.default.drillProperty(this, this, 'numberToText', 'numberToString'); } (0, _Object.observePropertyChanges)(this, this.dataKeys, () => { if (this.domSignal) this.domSignal.emit('updateContent'); }); /** * @name colorScheme * @type {null|number} * @memberof BChart# */ } BChart.tag = 'BChart'.toLowerCase(); BChart.render = function (data, o, dom) { var res = _({ tag: 'svgcanvas', class: 'vc-chart', child: [{ tag: 'gcontainer', class: 'vc-body' }, { tag: 'text', class: 'vc-title', child: { text: '' } }, { tag: 'gcontainer', class: 'vc-note-ctn' }, 'sattachhook.vc-dom-signal'] }); 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; }; BChart.prototype.dataKeys = ['title']; BChart.prototype.revokeResource = function () { (0, _Object.unobservePropertyChanges)(this, this.dataKeys); (0, _utils.revokeResource)(this.resizeCtrl); (0, _utils.revokeResource)(this.titleCtrl); while (this.lastChild) { (0, _utils.revokeResource)(this.lastChild); this.lastChild.remove(); } this.revokeResource = _noop.default; this.computedData = null; }; BChart.prototype.normalizeData = function () {}; BChart.prototype.computeData = function () { this.computedData.notes = this.computeNotes(); }; BChart.prototype._createNote = function () { var thisC = this; this.$noteCtn.clearChild(); this.$notes = this.computedData.notes.map((note, idx) => { var noteElt = _({ tag: _KeyNote.default, props: { color: note.color, text: note.text, noteType: note.type }, attr: { 'data-idx': idx }, on: { mouseenter: event => { if (this.eventHandler['mouseEnterNote']) { this.eventHandler['mouseEnterNote'](idx, event); } }, mouseleave: event => { if (this.eventHandler['mouseLeaveNote']) { this.eventHandler['mouseLeaveNote'](idx, event); } } } }); thisC.$noteCtn.addChild(noteElt); return noteElt; }); }; BChart.prototype._createTitle = function () { this.$title.firstChild.data = this.title || ''; }; BChart.prototype.createContent = function () { this.ready = true; this._createTitle(); this._createNote(); }; BChart.prototype._updateNotesPosition = function () { var noteBoundWidth = this.$notes.reduce(function (ac, noteElt) { var box = noteElt.getBBox(); return Math.max(ac, box.width); }, 0); var noteCtnMaxWidth = Math.max(this.box.width - this.contentPadding * 2, noteBoundWidth + 1); var x = 0; var y = 0; var pieceElt; for (var i = 0; i < this.$notes.length; ++i) { pieceElt = this.$notes[i]; if (x + noteBoundWidth > noteCtnMaxWidth) { x = 0; y += 20; } pieceElt.box.setPosition(x, y); x += noteBoundWidth + 15; } var noteCtnBound = this.$noteCtn.getBBox(); this.$noteCtn.box.setPosition(this.box.width / 2 - noteCtnBound.width / 2, this.box.height - this.contentPadding - noteCtnBound.height); }; BChart.prototype._updateTitlePosition = function () { this.$title.attr({ x: this.box.width / 2, y: 18 }); }; BChart.prototype.updateBodyPosition = function () { var titleHeight = this.$title.getBBox().height; var top = this.contentPadding; if (titleHeight > 0) top += titleHeight + 10; this.$body.box.setPosition(this.contentPadding, top); this.$body.box.setSize(this.box.width - this.contentPadding * 2, this.$noteCtn.box.y - top - 10); }; BChart.prototype.updateContentPosition = function () { this._updateTitlePosition(); this._updateNotesPosition(); this.updateBodyPosition(); }; /*** * * @returns {{color: Color, text: string, type: ("stroke"|"rect")}[]} */ BChart.prototype.computeNotes = function () { return []; }; BChart.prototype.updateContent = function () { if (!this.isDescendantOf(document.body)) { this.domSignal.emit('updateContent'); return; } this.normalizeData(); this.computeData(); this.createContent(); this.updateContentPosition(); }; BChart.prototype.updateSize = function () { _SvgCanvas.default.prototype.updateSize.call(this); if (!this.ready) return; this.updateContentPosition(); }; BChart.property = {}; BChart.property.canvasWidth = { get: function () { return this.box.width; }, set: function (value) { this.addStyle('width', value + 'px'); this.updateSize(); } }; BChart.property.canvasHeight = { get: function () { return this.box.height; }, set: function (value) { this.addStyle('height', value + 'px'); this.updateSize(); } }; BChart.property.showInlineValue = { set: function (value) { if (value) { this.addClass('vc-show-inline-value'); } else { this.removeClass('vc-show-inline-value'); } }, get: function () { return this.containsClass('vc-show-inline-value'); } }; BChart.property.colorScheme = { set: function (value) { this.attr('data-color-scheme', value + ''); if (this.isDescendantOf(document.body)) { this.domSignal.emit("updateContent"); } }, get: function () { var res = this.attr('data-color-scheme'); if (res) res = parseInt(res, 10); if (!(0, _utils.isNaturalNumber)(res)) res = null; return res; } }; BChart.eventHandler = {}; _VCore.default.install(BChart); var _default = BChart; exports.default = _default;