How to use the d3-scale.linear function in d3-scale

To help you get started, we’ve selected a few d3-scale 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 wavesjs / waves-ui / es6 / core / view.js View on Github external
_createTimeContext() {
    const pixelsPerSecond = this.pixelsPerSecond;
    const width = this.width;
    const xScale = d3Scale.linear()
      .domain([0, 1])
      .range([0, pixelsPerSecond]);

    this.timeContext = new ViewTimeContext();
    // all child context inherits the max duration allowed in container per default
    this.timeContext.duration = width / pixelsPerSecond;
    this.timeContext.xScale = xScale;
  }
github FormidableLabs / victory-core / test / client / spec / scale.spec.js View on Github external
it("uses data to distinguish between time and linear scales", () => {
      const props = {scale: {x: d3Scale.linear()}};
      const scaleType = Scale.getScaleType(props, "x");
      expect(Scale.getScaleFromProps).calledWith(props, "x").and.returned(props.scale.x);
      expect(Scale.getScaleTypeFromData).calledWith(props, "x").and.returned("linear");
      expect(scaleType).to.equal("linear");
    });
github bgrsquared / d3-v4-playground / app / GUI / withReactMotion / motionComponent.js View on Github external
getStyles(fakeData) {
    const { springParamsStd } = this.props.app;
    const { width } = this.state;

    const xScale = linear()
      .domain([0, 100])
      .range([0.1 * width, 0.9 * width]);
    const yScale = linear()
      .domain([0, 100])
      .range([0.9 * width, 0.1 * width]);

    const configs = {};
    fakeData.map((d, i) => {
      configs['point' + i] = {
        x: spring(xScale(d.x), springParamsStd),
        y: spring(yScale(d.y), springParamsStd),
        r: spring(50 * Math.random(), springParamsStd),
      };
    });
    return configs;
  }
github bgrsquared / d3-v4-playground / app / GUI / withReactMotion / motionComponent.js View on Github external
getStyles(fakeData) {
    const { springParamsStd } = this.props.app;
    const { width } = this.state;

    const xScale = linear()
      .domain([0, 100])
      .range([0.1 * width, 0.9 * width]);
    const yScale = linear()
      .domain([0, 100])
      .range([0.9 * width, 0.1 * width]);

    const configs = {};
    fakeData.map((d, i) => {
      configs['point' + i] = {
        x: spring(xScale(d.x), springParamsStd),
        y: spring(yScale(d.y), springParamsStd),
        r: spring(50 * Math.random(), springParamsStd),
      };
    });
    return configs;
  }