How to use d3-interpolate-path - 9 common examples

To help you get started, we’ve selected a few d3-interpolate-path 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 d2bjs / d2b / src / scripts / svg / line.js View on Github external
const tweenD = function (d, setupTooltip = false) {
        const maxX = max(d.values, dd => dd.x);
        const minX = min(d.values, dd => dd.x);
        return interpolatePath(
          this.getAttribute('d'),
          getPath.call(this, d, $$.x, $$.y, setupTooltip),
          function (a) { return a.x == maxX || a.x == minX; }
        );
      };
github pbeshai / d3-line-chunked / src / lineChunked.js View on Github external
path.attrTween('d', function dTween() {
        const previous = select(this).attr('d');
        const current = line(lineData);
        return interpolatePath(previous, current);
      });
    } else {
github d2bjs / d2b / src / scripts / svg / area.js View on Github external
const tweenD = function (d, setupTooltip = false) {
        const maxX = max(d.values, dd => dd.x);
        const minX = min(d.values, dd => dd.x);
        return interpolatePath(
          this.getAttribute('d'),
          getPath.call(this, d, $$.x, $$.y, setupTooltip),
          function (a) { return a.x == maxX || a.x == minX; }
        );
      };
github ethantran / react-native-examples / src / components / AnimatedSvgD3InterpolatePath.js View on Github external
function createInterpolator(props) {
    return d3.interpolatePath(props.d1, props.d2);
}
github wcandillon / can-it-be-done-in-react-native / feedback-animation / components / Mouth.tsx View on Github external
import { Dimensions } from "react-native";
import { Svg } from "expo";
import Animated from "react-native-reanimated";

import { interpolatePath } from "d3-interpolate-path";

const { Path } = Svg;
const { Value } = Animated;
const { call } = Animated;

const aspectRatio = 84 / 365;
const width = Dimensions.get("window").width / 5 - 32;
const height = width * aspectRatio;
const terrible = "M3,83.75 C62.8333333,29.25 122.666667,2 182.5,2 C242.333333,2 302.166667,29.25 362,83.75";
const great = "M3 3.75C62.833 55.917 122.667 82 182.5 82S302.167 55.917 362 3.75";
const interpolator = interpolatePath(terrible, great);

interface MouthProps {
  happiness: typeof Value
}

export default class Mouth extends React.PureComponent {
  path = React.createRef
github microsoft / tsiclient / src / UXClient / Components / LinePlot / LinePlot.ts View on Github external
.attrTween('d', function (d) {
                        var previous = d3.select(this).attr('d');
                        var current = aggLine(d);
                        return interpolatePath(previous, current);
                    });
github wcandillon / can-it-be-done-in-react-native / season1 / headspace-meditation / components / Progress.js View on Github external
generatePath(),
  generatePath(),
  generatePath(),
  generatePath(),
  generatePath(),
];

type ProgressProps = {};
type ProgressState = {
  d: string,
};

export default class Progress extends React.Component {
  interval;

  interpolator = interpolatePath(paths[0], paths[1]);

  lastIndex = 1;

  progress = 0;

  state = {
    d: paths[0],
  };

  componentDidMount() {
    this.interval = setInterval(this.animate, 100);
  }

  componentWillUnmount() {
    clearInterval(this.interval);
  }
github tohjustin / coincharts / src / components / Chart / Graph.js View on Github external
const previousAreaGraph = area(previousScaledData);
    const previousLineGraph = line(previousScaledData);
    const areaGraph = area(scaledData);
    const lineGraph = line(scaledData);

    graph.selectAll("path").remove();

    graph
      .append("path")
      .attr("class", "area")
      .attr("d", previousAreaGraph)
      .style("fill", previousColor.fill)
      .transition()
      .duration(transitionDuration)
      .ease(TRANSITION.ease)
      .attrTween("d", interpolatePath.bind(null, previousAreaGraph, areaGraph))
      .style("fill", color.fill);

    graph
      .append("path")
      .attr("class", "line")
      .attr("d", previousLineGraph)
      .style("stroke", previousColor.stroke)
      .transition()
      .duration(transitionDuration)
      .ease(TRANSITION.ease)
      .attrTween("d", interpolatePath.bind(null, previousLineGraph, lineGraph))
      .style("stroke", color.stroke);
  }
github tohjustin / coincharts / src / components / Chart / Graph.js View on Github external
.style("fill", previousColor.fill)
      .transition()
      .duration(transitionDuration)
      .ease(TRANSITION.ease)
      .attrTween("d", interpolatePath.bind(null, previousAreaGraph, areaGraph))
      .style("fill", color.fill);

    graph
      .append("path")
      .attr("class", "line")
      .attr("d", previousLineGraph)
      .style("stroke", previousColor.stroke)
      .transition()
      .duration(transitionDuration)
      .ease(TRANSITION.ease)
      .attrTween("d", interpolatePath.bind(null, previousLineGraph, lineGraph))
      .style("stroke", color.stroke);
  }

d3-interpolate-path

Interpolates path `d` attribute smoothly when A and B have different number of points.

BSD-3-Clause
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis