How to use the d3-dispatch.dispatch.apply function in d3-dispatch

To help you get started, we’ve selected a few d3-dispatch 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 vijithassar / d3-history / src / history.js View on Github external
history = function(_) {
    var proxy,
        dispatcher,
        events,
        url_handler;
    // bare object to act as an API proxy to the internal dispatcher
    proxy = Object.create(null);
    // create a dispatcher using the input as a list of event names
    events = Array.prototype.slice.call(arguments);
    dispatcher = dispatch.apply(this, events);
    // default url handler; note that the order of the arguments to d3.history
    // is inverted compared to the HTML5 history API in order to parallel
    // d3.dispatch
    url_handler = function(data, title, url) {
        if (window && window.history) {
            window.history.pushState(data, title, url);
        }
    };
    // get or set the url processing function, useful for tapping in to insert
    // custom functionality
    proxy.url = function(new_url_handler) {
        if (new_url_handler && typeof new_url_handler !== 'function') {
            console.error('optional argument to the .url() method of d3.history object must be a function');
        }
        if (typeof new_url_handler === 'function') {
            url_handler = new_url_handler;
github twitter / d3kit / src / chartlet.js View on Github external
function Chartlet(enter, update, exit, customEvents) {
  update = update || NOOP;
  exit = exit || NOOP;
  customEvents = customEvents || [];
  const _propertyCache = {};
  const _dispatch = dispatch.apply(this, ['enterDone', 'updateDone', 'exitDone'].concat(customEvents));

  // getter and setter of chartlet properties

  function property(name, value) {
    // if functioning as a setter, set property in cache
    if (arguments.length > 1) {
      _propertyCache[name] = functor(value);
      return this;
    }

    // functioning as a getter, return property accessor
    return functor(_propertyCache[name]);
  }

  function getPropertyValue(name, d, i) {
    return property(name)(d, i);
github ParasolJS / parasol-es / src / state / sideEffects.js View on Github external
const sideEffects = (config, ps, flags) =>
  dispatch.apply(this, Object.keys(config));
// .on('brush', data => {
github BigFatDog / parcoords-es / dist / parcoords.esm.js View on Github external
if (userConfig && userConfig.dimensionTitles) {
    console.warn('dimensionTitles passed in userConfig is deprecated. Add title to dimension object.');
    entries(userConfig.dimensionTitles).forEach(function (d) {
      if (config.dimensions[d.key]) {
        config.dimensions[d.key].title = config.dimensions[d.key].title ? config.dimensions[d.key].title : d.value;
      } else {
        config.dimensions[d.key] = {
          title: d.value
        };
      }
    });
  }

  var eventTypes = ['render', 'resize', 'highlight', 'mark', 'brush', 'brushend', 'brushstart', 'axesreorder'].concat(keys(config));

  var events = dispatch.apply(_this$4, eventTypes),
      flags = {
    brushable: false,
    reorderable: false,
    axes: false,
    interactive: false,
    debug: false
  },
      xscale = scalePoint(),
      dragging = {},
      axis = axisLeft().ticks(5),
      ctx = {},
      canvas = {};

  var brush = {
    modes: {
      None: {
github BigFatDog / parcoords-es / src / state / sideEffects.js View on Github external
const sideEffects = (
  config,
  ctx,
  pc,
  xscale,
  axis,
  flags,
  brushedQueue,
  markedQueue,
  foregroundQueue
) =>
  dispatch
    .apply(this, Object.keys(config))
    .on('composite', d => {
      ctx.foreground.globalCompositeOperation = d.value;
      ctx.brushed.globalCompositeOperation = d.value;
    })
    .on('alpha', d => {
      ctx.foreground.globalAlpha = d.value;
      ctx.brushed.globalAlpha = d.value;
    })
    .on('brushedColor', d => {
      ctx.brushed.strokeStyle = d.value;
    })
    .on('width', d => pc.resize())
    .on('height', d => pc.resize())
    .on('margin', d => pc.resize())
    .on('rate', d => {
github twitter / d3kit / src / Skeleton2.js View on Github external
setupDispatcher(eventNames) {
    this.eventNames = Skeleton.DEFAULT_EVENTS.concat(eventNames);
    this.dispatcher = dispatch.apply(this, this.eventNames);
  }
github BigFatDog / parcoords-es / src / state / sideEffects.js View on Github external
const sideEffects = (
  config,
  ctx,
  pc,
  xscale,
  flags,
  brushedQueue,
  foregroundQueue
) =>
  dispatch
    .apply(this, keys(config))
    .on('composite', d => {
      ctx.foreground.globalCompositeOperation = d.value;
      ctx.brushed.globalCompositeOperation = d.value;
    })
    .on('alpha', d => {
      ctx.foreground.globalAlpha = d.value;
      ctx.brushed.globalAlpha = d.value;
    })
    .on('brushedColor', d => {
      ctx.brushed.strokeStyle = d.value;
    })
    .on('width', d => pc.resize())
    .on('height', d => pc.resize())
    .on('margin', d => pc.resize())
    .on('rate', d => {
github twitter / d3kit / dist / d3kit-es.js View on Github external
value: function setupDispatcher() {
      var customEventNames = arguments.length <= 0 || arguments[0] === undefined ? [] : arguments[0];

      this._customEventNames = customEventNames;
      this._eventNames = AbstractChart.DEFAULT_EVENTS.concat(customEventNames);
      this.dispatcher = dispatch.apply(this, this._eventNames);
      return this;
    }
  }, {
github BigFatDog / parcoords-es / src / state / index.js View on Github external
};
      }
    });
  }

  const eventTypes = [
    'render',
    'resize',
    'highlight',
    'brush',
    'brushend',
    'brushstart',
    'axesreorder',
  ].concat(keys(config));

  const events = dispatch.apply(this, eventTypes),
    flags = {
      brushable: false,
      reorderable: false,
      axes: false,
      interactive: false,
      debug: false,
    },
    xscale = scalePoint(),
    dragging = {},
    axis = axisLeft().ticks(5),
    ctx = {},
    canvas = {};

  const brush = {
    modes: {
      None: {

d3-dispatch

Register named callbacks and call them with arguments.

ISC
Latest version published 3 years ago

Package Health Score

71 / 100
Full package analysis