How to use the datalib.extend function in datalib

To help you get started, we’ve selected a few datalib 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 vega / lyra / src / js / model / primitives / marks / Scene.js View on Github external
Scene.defaultProperties = function(props) {
  // Note that scene has no "properties" property
  return dl.extend({
    // Containers for child marks
    scales: [],
    legends: [],
    axes: [],
    marks: [],
    // type will be removed later on, but is used to generate an appropriate name
    type: 'scene',
    // Scene has no Vega properties object, but we mock it for now to avoid
    // distrupting the export functionality
    properties: {
      update: {}
    },
    // Scene-specific visual properties
    width: 610,
    height: 610,
    padding: 'auto',
github vega / lyra / src / js / model / primitives / marks / Group.js View on Github external
Group.defaultProperties = function(props) {
  return dl.extend({
    type: 'group',
    // name: 'group' + '_' + counter.type('group'); // Assign name in the reducer
    // _id: assign ID in the reducer
    properties: Mark.mergeProperties(Mark.defaultProperties(), {
      update: {
        x: {value: 0},
        y: {value: 0},
        width: {signal: ns('vis_width')},
        height: {signal: ns('vis_height')},
        fill: {value: 'transparent'}
      }
    }),
    // Containers for child marks
    scales: [],
    legends: [],
    axes: [],
github vega / lyra / src / js / model / primitives / marks / Area.js View on Github external
Area.defaultProperties = function(props) {
  return dl.extend({
    type: 'area',
    // name: 'area' + '_' + counter.type('area'); // Assign name in the reducer
    // _id: assign ID in the reducer
    properties: Mark.mergeProperties(Mark.defaultProperties(), {
      update: {
        x2: {value: 0},
        y2: {value: 0},
        xc: {value: 60, _disabled: true},
        yc: {value: 60, _disabled: true},
        tension: {value: 13},
        interpolate: {value: 'monotone'},
        fill: {value: '#55498D'},
        stroke: {value: '#55498D'},
        orient: {value: 'vertical'},
        width: {value: 30, _disabled: true},
        height: {value: 30, _disabled: true}
github vega / lyra / src / js / model / primitives / marks / Line.js View on Github external
Line.defaultProperties = function(props) {
  var defaults = {
    type: 'line',
    // name: 'line' + '_' + counter.type('line'); // Assign name in the reducer
    // _id: assign ID in the reducer
    properties: Mark.mergeProperties(Mark.defaultProperties(), {
      update: {
        stroke: {value: '#000000'},
        strokeWidth: {value: 3}
      }
    })
  };
  // Mark gives us two defaults we do not want
  delete defaults.properties.update.fill;
  delete defaults.properties.update.fillOpacity;
  return dl.extend(defaults, props);
};
github vega / vega / src / parse / properties.js View on Github external
}

  if (hasPath(mark, vars)) code += "\n  d += (item.touch(), 1);";
  code += "\n  if (trans) trans.interpolate(item, o);";
  code += "\n  return d > 0;";

  try {
    /* jshint evil:true */
    var encoder = Function('item', 'group', 'trans', 'db',
      'signals', 'predicates', code);

    encoder.tpl  = Tuple;
    encoder.exprs = exprs;
    encoder.util = dl;
    encoder.d3   = d3; // For color spaces
    dl.extend(encoder, dl.template.context);
    return {
      encode:  encoder,
      signals: dl.keys(deps.signals),
      scales:  dl.keys(deps.scales),
      data:    dl.keys(deps.data),
      fields:  dl.keys(deps.fields),
      nested:  deps.nested,
      reflow:  deps.reflow
    };
  } catch (e) {
    log.error(e);
    log.log(code);
  }
}
github vega / lyra / src / js / actions / guideActions.js View on Github external
function addGuide(guideProps) {
  var props = dl.extend({
    _id: guideProps._id || counter.global(),
  }, guideProps);

  return {
    id: props._id,
    type: ADD_GUIDE,
    props: props
  };
}
github vega / lyra / src / js / ctrl / manipulators.js View on Github external
function hoverCell(t, f, parent) {
  var rule = [{
    test: sg.CELL + '.key === ' + (parent ? 'parent.key' : 'datum.key')
  }];

  dl.extend(rule[0], t);
  rule.push(f);
  return {rule: rule};
}
github vega / vega / src / parse / modify.js View on Github external
input.mod.forEach(function(x) {
        if (x[fieldName] === datum[fieldName]) {
          dl.extend(x, datum);
          ++up;
        }
      });
github vega / vega / src / core / Model.js View on Github external
prototype.config = function(cfg) {
  if (!arguments.length) return this._config;
  this._config = Object.create(config);
  for (var name in cfg) {
    var x = cfg[name], y = this._config[name];
    if (dl.isObject(x) && dl.isObject(y)) {
      dl.extend(y, x);
    } else {
      this._config[name] = x;
    }
  }

  return this;
};
github vega / vega / src / core / Model.js View on Github external
prototype.config = function(cfg) {
  if (!arguments.length) return this._config;
  this._config = Object.create(config);
  for (var name in cfg) {
    var x = cfg[name], y = this._config[name];
    if (dl.isObject(x) && dl.isObject(y)) {
      dl.extend(y, x);
    } else {
      this._config[name] = x;
    }
  }

  return this;
};

datalib

JavaScript utilites for loading, summarizing and working with data.

BSD-3-Clause
Latest version published 4 years ago

Package Health Score

45 / 100
Full package analysis

Popular datalib functions