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__SimpleLineChart.js
/*** module: node_modules/absol-vchart/src/SimpleLineChart.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 _Turtle = _interopRequireDefault(require("absol-svg/js/controller/Turtle"));

var _template = require("./template");

var _ToolTip = require("./ToolTip");




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 SimpleLineChart() {
  _BChart.default.apply(this, arguments);

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

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

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

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

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

SimpleLineChart.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);
  }
};

SimpleLineChart.prototype._createPoints = function () {
  this.$bgRects.forEach(elt => elt.remove());
  this.$bgRects = this.values.map((u, i) => {
    return (0, _VCore._)({
      tag: 'rect',
      class: ['vc-simple-background'],
      style: {
        fill: i % 2 ? 'rgba(132, 132, 132, 0.07)' : 'rgba(132, 132, 132, 0.2)'
      },
      on: {
        mouseenter: event => {
          this.eventHandler.mouseEnterNote(i, event);
        },
        mouseleave: event => {
          this.eventHandler.mouseLeaveNote(i, event);
        }
      }
    });
  });
  this.$body.addChild(this.$bgRects);
  this.$ox = this.$ox || (0, _VCore._)({
    tag: 'path',
    class: ['vc-simple-ox', 'vchart-axis']
  });
  this.$oxArrow = this.$oxArrow || (0, _VCore._)({
    tag: 'path',
    class: ['vchart-axis'],
    attr: {
      d: 'm0 -5v10l6.8 -5z'
    }
  });
  this.$body.addChild(this.$ox);
  this.$body.addChild(this.$oxArrow);
  this.$points.forEach(e => e.remove());
  this.$texts.forEach(e => e.remove());
  this.$points = this.values.map((value, i) => {
    return (0, _VCore._)({
      tag: 'circle',
      attr: {
        cx: 0,
        cy: 0,
        r: 8
      },
      style: {
        stroke: 'white',
        strokeWidth: 2,
        fill: this.fillColors[i],
        pointerEvents: 'none'
      }
    });
  });
  this.$line = (0, _VCore._)({
    tag: 'path',
    style: {
      strokeWidth: 2,
      stroke: 'rgb(100, 100, 150)',
      fill: 'none',
      pointerEvents: 'none'
    }
  });
  this.$body.addChild(this.$line);
  this.$body.addChild(this.$points);
};

SimpleLineChart.prototype._updatePointPosition = function () {
  var width = this.$body.box.width;
  var height = this.$body.box.height;
  if (height === 0) return;
  var aHeight = height - 10;
  var aWidth = width - 25;
  var colWidth = aWidth / this.$points.length;
  var x0 = 10;
  var maxValue = this._maxValue ? this._maxValue : 1;
  this.$ox.attr('d', new _Turtle.default().moveTo(0, height).hLineBy(width).getPath());
  this.$oxArrow.attr('transform', (0, _template.translate)(width - 3, height));
  this.$bgRects.forEach((elt, i) => {
    elt.attr({
      width: colWidth,
      height: height,
      x: x0 + i * colWidth,
      y: 0
    });
  });
  var linePath = this.values.reduce((ac, value, i) => {
    var colHeight = (0, _helper.map)(this.values[i], 0, maxValue, 0, aHeight);

    if (i) {
      ac.lineTo(x0 + (i + 0.5) * colWidth, height - colHeight);
    } else {
      ac.moveTo(x0 + (i + 0.5) * colWidth, height - colHeight);
    }

    return ac;
  }, new _Turtle.default()).getPath();
  this.$line.attr('d', linePath);
  this.$points.forEach((colElt, i) => {
    var colHeight = (0, _helper.map)(this.values[i], 0, maxValue, 0, aHeight);
    colElt.attr({
      cy: height - colHeight,
      cx: x0 + (i + 0.5) * colWidth
    });
  }); // this.$texts.forEach((textElt, i) => {
  //     var colHeight = 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
  //     });
  // });
};

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

  this._createPoints();
};

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

  this._updatePointPosition();
};

SimpleLineChart.eventHandler = {};

SimpleLineChart.eventHandler.mouseEnterNote = function (idx, event) {
  var bound = this.$points[idx].getBoundingClientRect();
  this.tooltipToken = (0, _ToolTip.showTooltip)(this.keys[idx] + ': ' + this.texts[idx], bound.right, bound.top);
};

SimpleLineChart.eventHandler.mouseLeaveNote = function (idx, event) {
  var token = this.tooltipToken;
  if (!token) return;
  setTimeout(() => {
    (0, _ToolTip.closeTooltip)(token);
  }, 1000);
};

_VCore.default.install(SimpleLineChart);

var _default = SimpleLineChart;
exports.default = _default;

VaKeR 2022