How to use the base/utils.clone function in base

To help you get started, we’ve selected a few base examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vizabi / vizabi / src / base / datastorage.js View on Github external
      const values = items.map(d => utils.clone(d, attr)); // pick attrs
      uniq = utils.unique(values, n => JSON.stringify(n));
github vizabi / vizabi / src / models / color.js View on Github external
getDefaultPalette() {
    const conceptpropsColor = this.getConceptprops().color;
    let palette;

    this.discreteDefaultPalette = false;

    if (conceptpropsColor && conceptpropsColor.palette) {
      //specific color palette from hook concept properties
      palette = utils.clone(conceptpropsColor.palette);
    } else if (defaultPalettes[this.which]) {
      //color palette for this.which exists in palette defaults
      palette = utils.clone(defaultPalettes[this.which]);
    } else if (this.use === "constant") {
      //an explicit hex color constant #abc or #adcdef is provided
      if (/^#([0-9a-f]{3}|[0-9a-f]{6})$/.test(this.which)) {
        palette = { "_default": this.which };
      } else {
        palette = utils.clone(defaultPalettes["_default"]);
      }
    } else {
      palette = utils.clone(defaultPalettes[this.isDiscrete() ? "_discrete" : "_continuous"]);
      this.discreteDefaultPalette = true;
    }

    return palette;
  },
github vizabi / vizabi / src / models / color.js View on Github external
let palette;

    this.discreteDefaultPalette = false;

    if (conceptpropsColor && conceptpropsColor.palette) {
      //specific color palette from hook concept properties
      palette = utils.clone(conceptpropsColor.palette);
    } else if (defaultPalettes[this.which]) {
      //color palette for this.which exists in palette defaults
      palette = utils.clone(defaultPalettes[this.which]);
    } else if (this.use === "constant") {
      //an explicit hex color constant #abc or #adcdef is provided
      if (/^#([0-9a-f]{3}|[0-9a-f]{6})$/.test(this.which)) {
        palette = { "_default": this.which };
      } else {
        palette = utils.clone(defaultPalettes["_default"]);
      }
    } else {
      palette = utils.clone(defaultPalettes[this.isDiscrete() ? "_discrete" : "_continuous"]);
      this.discreteDefaultPalette = true;
    }

    return palette;
  },
github vizabi / vizabi / src / readers / graph / graph.js View on Github external
function parse(res) {

        var data = res;
        //rename geo.category to geo.cat
        var where = query.where;
        if (where['geo.category']) {
          where['geo.cat'] = utils.clone(where['geo.category']);
          delete where['geo.category'];
        }

        //format values in the dataset and filters
        where = utils.mapRows([where], _this._parsers)[0];

        //make sure conditions don't contain invalid conditions
        var validConditions = [];
        utils.forEach(where, function (v, p) {
          for (var i = 0, s = data.length; i < s; i++) {
            if (data[i].hasOwnProperty(p)) {
              validConditions.push(p);
              return true;
            }
          }
        });
github vizabi / vizabi / src / components / zoombuttonlist / zoombuttonlist.js View on Github external
_addButtons(button_list, button_expand) {
    const _this = this;
    this._components_config = [];
    const details_btns = [];
    if (!button_list.length) return;
    //add a component for each button
    for (let i = 0; i < button_list.length; i++) {

      const btn = button_list[i];
      const btn_config = this._available_buttons[btn];

      //add template data
      const d = (btn_config) ? btn : "_default";
      const details_btn = utils.clone(this._available_buttons[d]);

      details_btn.id = btn;
      details_btn.icon = iconset[details_btn.icon];
      details_btns.push(details_btn);
    }

    const t = this.getTranslationFunction(true);

    this.element.selectAll("button").data(details_btns)
      .enter().append("button")
      .attr("class", d => {
        let cls = "vzb-buttonlist-btn";
        if (button_expand.length > 0) {
          if (button_expand.indexOf(d.id) > -1) {
            cls += " vzb-dialog-side-btn";
          }
github vizabi / vizabi / src / tools / bubblechart / bubblechart-component.js View on Github external
const skipCrownInnerFill = !d.trailStartTime || d.trailStartTime == _this.model.time.formatDate(_this.time);
          _this._setBubbleCrown(x, y, s, c, skipCrownInnerFill);
        }

        if (!entityOutOfView && !hoverTrail) {
          _this._axisProjections(d);
        }

          //set tooltip and show axis projections
        if (text && !entityOutOfView && !hoverTrail) {
          _this._setTooltip(text, x, y, s + 3, c);
        }

        const selectedData = utils.find(_this.model.marker.select, f => f[KEY] == d[KEY]);
        if (selectedData) {
          const clonedSelectedData = utils.clone(selectedData);
            //change opacity to OPACITY_HIGHLT = 1.0;
          clonedSelectedData.opacity = 1.0;
          _this._trails.run(["opacityHandler"], clonedSelectedData);
        }
      });
    } else {
github vizabi / vizabi / src / helpers / labels.js View on Github external
const select = _this.model.marker.select.map(d => {
      const p = utils.clone(d, KEYS);
      p[KEY] = utils.getKey(d, KEYS);
      return p;
    });
    this.entityLabels = this.labelsContainer.selectAll("." + _cssPrefix + "-entity")
github vizabi / vizabi / src / base / component.js View on Github external
    this._components_config = this.components.map(x => utils.clone(x));
github vizabi / vizabi / src / base / data.js View on Github external
var values = items.map(function(d) {
        return utils.clone(d, attr); //pick attrs
      });
      uniq = utils.unique(values, function(n) {
github vizabi / vizabi / src / readers / json / json.js View on Github external
data = data.map(function(row) {
          return utils.clone(row, query.select);
        });