VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/libs/absol-full/dist/js/mdls__absol-vchart__src__SimpleColumnChart.js
/*** module: node_modules/absol-vchart/src/SimpleColumnChart.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"));




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 BChart
 * @constructor
 */
function SimpleColumnChart() {
  _BChart.default.apply(this, arguments);

  this.keys = [];
  this.values = [];
  this.texts = [];
  this.fillColors = [];
  this.$columns = [];
  this.$texts = [];
}

_OOP.default.mixClass(SimpleColumnChart, _BChart.default);

SimpleColumnChart.tag = 'SimpleColumnChart'.toLowerCase();

SimpleColumnChart.render = function () {
  return _BChart.default.render.apply(this, arguments).addClass('vc-simple-column-chart');
};

SimpleColumnChart.prototype.computeNotes = function () {
  return this.keys.map((key, i) => {
    return {
      color: this.fillColors[i],
      text: key,
      type: 'rect',
      idx: i
    };
  });
};

SimpleColumnChart.prototype.normalizeData = function () {
  var colorScheme = this.colorScheme;
  var blockColors = (0, _utils.isNaturalNumber)(colorScheme) ? (0, _SelectColorSchemeMenu.generatorColorScheme)(colorScheme, this.values.length) : (0, _helper.generateBackgroundColors)(this.values.length);
  this.fillColors = this.fillColors || [];

  while (this.fillColors.length < this.values.length) {
    this.fillColors.push(blockColors[this.fillColors.length]);
  }

  this._maxValue = Math.max.apply(Math, _toConsumableArray(this.values));

  if (!this.texts || this.values.length !== this.texts.length) {// this.texts = this.values.map(value=> this.nu);
  }
};

SimpleColumnChart.prototype._createColumns = function () {
  this.$columns.forEach(e => e.remove());
  this.$texts.forEach(e => e.remove());
  this.$columns = this.values.map((value, i) => {
    return (0, _VCore._)({
      tag: 'rect',
      attr: {
        x: 0,
        y: 0
      },
      style: {
        fill: this.fillColors[i]
      }
    });
  });
  this.$body.addChild(this.$columns);
  this.$texts = this.texts.map((key, i) => {
    var color = this.fillColors[i];
    color = typeof color === "string" ? _Color.default.parse(color) : color;
    color = color.getContrastYIQ();
    return (0, _VCore._)({
      tag: 'text',
      class: 'vc-value-text',
      attr: {
        x: 10,
        y: 10
      },
      style: {
        color: color + ''
      },
      child: {
        text: key
      }
    });
  });
  this.$body.addChild(this.$texts);
};

SimpleColumnChart.prototype._updateRowPosition = function () {
  var width = this.$body.box.width;
  var height = this.$body.box.height;
  if (height === 0) return;
  var colWidth = Math.min(150, width / this.$columns.length);
  var x0 = (width - colWidth * this.$columns.length) / 2;
  var maxValue = this._maxValue ? this._maxValue : 1;
  this.$columns.forEach((colElt, i) => {
    var colHeight = (0, _helper.map)(this.values[i], 0, maxValue, 0, height);
    colElt.attr({
      width: colWidth,
      y: height - colHeight,
      height: colHeight,
      x: x0 + i * colWidth
    });
  });
  this.$texts.forEach((textElt, i) => {
    var colHeight = (0, _helper.map)(this.values[i], 0, maxValue, 0, height);
    var y = height - colHeight;

    if (colHeight > 20) {
      y += 14;
      textElt.removeStyle('fill');
    } else {
      y -= 5;
      textElt.addStyle('fill', 'black');
    }

    textElt.attr({
      y: y,
      x: x0 + (i + 0.5) * colWidth
    });
  });
};

SimpleColumnChart.prototype.createContent = function () {
  _BChart.default.prototype.createContent.call(this);

  this._createColumns();
};

SimpleColumnChart.prototype.updateBodyPosition = function () {
  _BChart.default.prototype.updateBodyPosition.call(this);

  this._updateRowPosition();
};

_VCore.default.install(SimpleColumnChart);

var _default = SimpleColumnChart;
exports.default = _default;

VaKeR 2022