How to use the d3-interpolate.interpolateTransformSvg function in d3-interpolate

To help you get started, we’ve selected a few d3-interpolate 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 sghall / react-d3-transitions / examples / barChartExample / src / components / AxisTick.js View on Github external
isEntering({xScale0, xScale1, tick: {data}, duration}, {tick}) {
    let beg = `translate(${xScale0(data)},0)`;
    let end = `translate(${xScale1(data)},0)`;

    let interp0 = interpolateTransformSvg(beg, end);
    let interp1 = interpolateNumber(1e-6, 1);

    this.transition = timer(elapsed => {
      let t = elapsed < duration ? (elapsed / duration): 1;
      tick.setAttribute('transform', interp0(t));
      tick.setAttribute('opacity', interp1(t));

      if (t === 1) {
        this.transition.stop();
      }
    });
  }
github sghall / resonance / docs / site / src / routes / examples / stackedArea / components / ManagedTicks.js View on Github external
onAppear({ prevXScale, currXScale, node: { data }, duration }) {
    const beg = `translate(${prevXScale(data)},0)`;
    const end = `translate(${currXScale(data)},0)`;

    const interp0 = interpolateTransformSvg(beg, end);
    const interp1 = interpolateNumber(1e-6, 1);

    this.transition = timer((elapsed) => {
      const t = elapsed < duration ? (elapsed / duration) : 1;

      this.tick.setAttribute('transform', interp0(t));
      this.tick.setAttribute('opacity', interp1(t));

      if (t === 1) {
        this.transition.stop();
      }
    });
  }
github sghall / react-d3-transitions / examples / barChartExample / src / components / AxisTick.js View on Github external
isUpating({xScale0, xScale1, tick: {data}, duration}, {tick}) {
    let beg = `translate(${xScale0(data)},0)`;
    let end = `translate(${xScale1(data)},0)`;

    let interp0 = interpolateTransformSvg(beg, end);
    let interp1 = interpolateNumber(tick.getAttribute('opacity'), 1);

    this.transition = timer(elapsed => {
      let t = elapsed < duration ? (elapsed / duration): 1;

      tick.setAttribute('transform', interp0(t));
      tick.setAttribute('opacity', interp1(t));

      if (t === 1) {
        this.transition.stop();
      }
    });
  }
github sghall / resonance / docs / site / src / routes / examples / stackedArea / components / ManagedBars.js View on Github external
onAppear({ yScale, node: { xVal, yVal }, duration }) {
    this.rect.setAttribute('width', xVal);
    this.rect.setAttribute('height', yScale.bandwidth());
    this.text.setAttribute('x', xVal - 3);

    const interp0 = interpolateTransformSvg('translate(0,500)', `translate(0,${yVal})`);
    const interp1 = interpolateNumber(1e-6, 1);

    this.transition = timer((elapsed) => {
      const t = elapsed < duration ? (elapsed / duration) : 1;
      this.node.setAttribute('transform', interp0(t));
      this.node.setAttribute('opacity', interp1(t));
      if (t === 1) {
        this.transition.stop();
      }
    });
  }
github sghall / resonance / docs / src / pages / demos / node-group / Example2.js View on Github external
interpolation={(begValue, endValue, attr) => {
              if (attr === 'transform') {
                return interpolateTransformSvg(begValue, endValue)
              }
            
              return interpolate(begValue, endValue)
            }}
github sghall / react-d3-transitions / examples / barChartExample / src / components / Bar.js View on Github external
isUpating({yScale, node: {xVal, yVal}, duration}, next, {node, rect, text}) {

    let interp0 = interpolateTransformSvg(`translate(0,${yVal})`, `translate(0,${next.node.yVal})`);

    let begVals = {w: xVal, h: yScale.bandwidth(), x: xVal - 3};
    let endVals = {w: next.node.xVal, h: next.yScale.bandwidth(), x: next.node.xVal - 3};
    let interp1 = interpolateObject(begVals, endVals);

    node.setAttribute('opacity', 1);

    this.transition = timer(elapsed => {
      let t = elapsed < duration ? (elapsed / duration): 1;
      node.setAttribute('transform', interp0(t));

      let {w, h, x} = interp1(t);
      rect.setAttribute('width', w);
      rect.setAttribute('height', h);
      text.setAttribute('x', x);
      if (t === 1) {
github sghall / resonance / docs / site / src / routes / examples / barCharts / statesByAge / example / components / Bar.js View on Github external
isEntering({ yScale, node: { xVal, yVal }, duration }, { node, rect, text }) {
    rect.setAttribute('width', xVal);
    rect.setAttribute('height', yScale.bandwidth());
    text.setAttribute('x', xVal - 3);

    const interp0 = interpolateTransformSvg('translate(0,500)', `translate(0,${yVal})`);
    const interp1 = interpolateNumber(1e-6, 1);

    this.transition = timer((elapsed) => {
      const t = elapsed < duration ? (elapsed / duration) : 1;
      node.setAttribute('transform', interp0(t));
      node.setAttribute('opacity', interp1(t));
      if (t === 1) {
        this.transition.stop();
      }
    });
  }
github sghall / react-d3-transitions / examples / stackedChartExample / src / components / XAxisTick.js View on Github external
isExiting({xScale0, xScale1, tick: {udid, data}, removeTick, duration}, {tick}) {

    let beg = `translate(${xScale0(data)},0)`;
    let end = `translate(${xScale1(data)},0)`;

    let interp0 = interpolateTransformSvg(beg, end);
    let interp1 = interpolateNumber(tick.getAttribute('opacity'), 1e-6);

    this.transition = timer(elapsed => {
      let t = elapsed < duration ? (elapsed / duration): 1;
      tick.setAttribute('transform', interp0(t));
      tick.setAttribute('opacity', interp1(t));
      if (t === 1) {
        this.transition.stop();
        removeTick(udid);
      }
    });
  }
github sghall / resonance / docs / site / src / routes / examples / barCharts / statesByAge / example / components / Bar.js View on Github external
isExiting({ node: { yVal, udid }, removeNode, duration }, { node }) {
    const interp0 = interpolateTransformSvg(`translate(0,${yVal})`, 'translate(0,500)');
    const interp1 = interpolateNumber(1, 1e-6);

    this.transition = timer((elapsed) => {
      const t = elapsed < duration ? (elapsed / duration) : 1;
      node.setAttribute('transform', interp0(t));
      node.setAttribute('opacity', interp1(t));
      if (t === 1) {
        this.transition.stop();
        removeNode(udid);
      }
    });
  }
github sghall / react-d3-transitions / examples / stackedChartExample / src / components / XAxisTick.js View on Github external
isEntering({xScale0, xScale1, tick: {data}, duration}, {tick}) {

    let beg = `translate(${xScale0(data)},0)`;
    let end = `translate(${xScale1(data)},0)`;

    let interp0 = interpolateTransformSvg(beg, end);
    let interp1 = interpolateNumber(1e-6, 1);

    this.transition = timer(elapsed => {
      let t = elapsed < duration ? (elapsed / duration): 1;
      tick.setAttribute('transform', interp0(t));
      tick.setAttribute('opacity', interp1(t));
      if (t === 1) {
        this.transition.stop();
      }
    });
  }