How to use the @antv/scale.linear function in @antv/scale

To help you get started, we’ve selected a few @antv/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 antvis / G2 / test / unit / component / guide / html-spec.js View on Github external
});

  const canvas = new Canvas({
    containerId: 'c1',
    width: 500,
    height: 500,
    pixelRatio: 2
  });

  const group = canvas.addGroup();

  const xScale = Scale.cat({
    values: [ '一月', '二月', '三月', '四月', '五月' ]
  });

  const yScale = Scale.linear({
    min: 0,
    max: 1200
  });

  it('guide html, with defaul position(middle, middle)', function() {
    const html = new Html({
      xScales: {
        month: xScale
      },
      yScales: {
        temp: yScale
      },
      position: {
        month: 3,
        temp: 600
      },
github antvis / G2 / test / unit / geom / geom-spec.js View on Github external
describe('test geom line', function() {
  let data = [{ a: 4, b: 3, c: '1' }, { a: 2, b: 2, c: '2' }];
  const scaleA = Scale.linear({
    field: 'a',
    min: 0,
    max: 10
  });
  const scaleB = Scale.linear({
    field: 'b',
    min: 0,
    max: 5,
    nice: false
  });
  const group = canvas.addGroup();
  const geom = new Geom.Line({
    data,
    coord,
    container: group,
    scales: { a: scaleA, b: scaleB, c: scaleC, red: ScaleRed }
  });
  const shapeContainer = geom.get('shapeContainer');

  it('draw path', function() {
    expect(geom.get('type')).eql('line');
github antvis / G2 / test / unit / component / guide / arc-spec.js View on Github external
});

  const canvas = new Canvas({
    containerId: 'arc-spec',
    width: 500,
    height: 500,
    pixelRatio: 2
  });

  const group = canvas.addGroup();

  const xScale = Scale.cat({
    values: [ '一月', '二月', '三月', '四月', '五月' ]
  });

  const yScale = Scale.linear({
    min: 0,
    max: 1200
  });

  it('guide arc', function() {
    const arc = new Arc({
      xScales: {
        month: xScale
      },
      yScales: {
        temp: yScale
      },
      start: {
        month: 0,
        temp: 1200
      },
github antvis / G2 / test / unit / component / guide / line-spec.js View on Github external
});

  const canvas = new Canvas({
    containerId: 'c1',
    width: 500,
    height: 500,
    pixelRatio: 2
  });

  const group = canvas.addGroup();

  const xScale = Scale.cat({
    values: [ '一月', '二月', '三月', '四月', '五月' ]
  });

  const yScale = Scale.linear({
    min: 0,
    max: 1200
  });

  it('guide line without text', function() {
    const line = new Line({
      xScales: {
        month: xScale
      },
      yScales: {
        temp: yScale
      },
      start: {
        month: '一月',
        temp: 200
      },
github antvis / G2 / test / unit / component / guide / text-spec.js View on Github external
});

  const canvas = new Canvas({
    containerId: 'c1',
    width: 500,
    height: 500,
    pixelRatio: 2
  });

  const group = canvas.addGroup();

  const xScale = Scale.cat({
    values: [ '一月', '二月', '三月', '四月', '五月' ]
  });

  const yScale = Scale.linear({
    min: 0,
    max: 1200
  });

  it('guide text', function() {
    const text = new Text({
      xScales: {
        month: xScale
      },
      yScales: {
        temp: yScale
      },
      content: '(一月,200)',
      position: {
        month: '三月',
        temp: 'min'
github antvis / G2 / test / unit / geom / geom-spec.js View on Github external
describe('test geom line', function() {
  let data = [{ a: 4, b: 3, c: '1' }, { a: 2, b: 2, c: '2' }];
  const scaleA = Scale.linear({
    field: 'a',
    min: 0,
    max: 10
  });
  const scaleB = Scale.linear({
    field: 'b',
    min: 0,
    max: 5,
    nice: false
  });
  const group = canvas.addGroup();
  const geom = new Geom.Line({
    data,
    coord,
    container: group,
    scales: { a: scaleA, b: scaleB, c: scaleC, red: ScaleRed }
github antvis / G2 / test / unit / chart / controller / guide-spec.js View on Github external
describe('GuideController', function() {
  const canvas = new Canvas({
    containerId: 'guideTest',
    width: 200,
    height: 200
  });
  const frontContainer = canvas.addGroup();
  const backContainer = canvas.addGroup();

  const xScale = Scale.cat({
    range: [ 0.1, 0.9 ],
    values: [ 'a', 'b', 'c', 'd', 'e' ],
    ticks: [ 'a', 'b', 'c', 'd', 'e' ],
    field: 'x'
  });
  const yScale1 = Scale.linear({
    min: 100,
    max: 600,
    values: [ 250, 350, 150, 450, 550 ],
    ticks: [ 250, 350, 150, 450, 550 ],
    field: 'y1'
  });
  const yScale2 = Scale.linear({
    min: 0,
    max: 100,
    values: [ 0, 20, 40, 60, 80, 100 ],
    ticks: [ 0, 20, 40, 60, 80, 100 ],
    field: 'y2'
  });


  const xScales = {
github antvis / G6 / plugins / tool.mapper / index.js View on Github external
_scaleSelector(type, domain) {
    const params = {
      min: domain[0],
      max: domain[domain.length - 1]
    };
    switch (type) {
      case 'Category':
        return Scale.cat({
          values: domain
        });
      default:
        return Scale.linear(params);
    }
  }
  destroy() {

@antv/scale

Toolkit for mapping abstract data into visual representation.

MIT
Latest version published 6 months ago

Package Health Score

73 / 100
Full package analysis