How to use the @antv/scale.cat 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 / geom / label / polar-labels-spec.js View on Github external
point.z = 3;
  point._origin = { x: point.z, y: point.y, z: '4' };
  points.push(point);

  const points1 = [{
    x: 50,
    y: [ 10, 20 ],
    z: [ '1', '2' ],
    _origin: { x: 50, y: [ 10, 20 ], z: [ '1', '2' ] }
  }, {
    x: [ 60, 80 ],
    y: [ 50, 50 ],
    z: [ '3', '4' ],
    _origin: { x: [ 60, 80 ], y: [ 50, 50 ], z: [ '3', '4' ] }
  }];
  const labelScale1 = Scale.cat({
    field: 'z',
    values: [[ '1', '2' ], [ '3', '4' ]]
  });
  describe('one point one label', function() {
    let gLabels;
    it('init', function() {
      gLabels = canvas.addGroup(PolarLabels, {
        coord,
        labelCfg: {
          cfg: {
            offset: 10
          },
          scales: [ labelScale ]
        },
        geomType: 'point'
      });
github antvis / G2 / test / unit / component / guide / html-spec.js View on Github external
describe('Guide: 辅助 html', function() {
  const coord = new Coord.Rect({
    start: { x: 60, y: 460 },
    end: { x: 460, y: 60 }
  });

  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
      },
github antvis / G2 / test / unit / geom / geom-spec.js View on Github external
it('create area', function() {
    scaleA = Scale.cat({
      field: 'a',
      values: [ '1', '2', '3' ],
      range: [ 0.2, 0.8 ]
    });
    geom = new Geom.Area({
      data,
      coord,
      container: group,
      scales: { a: scaleA, b: scaleB, c: scaleC, red: ScaleRed, 10: ScaleTen }
    });
    shapeContainer = geom.get('shapeContainer');
    expect(geom.get('type')).equal('area');
    expect(geom.get('shapeType')).equal('area');
  });
github antvis / G2 / test / unit / component / guide / arc-spec.js View on Github external
start: { x: 60, y: 460 },
    end: { x: 460, y: 60 },
    startAngle: -9 / 8 * Math.PI,
    endAngle: 1 / 8 * Math.PI
  });

  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
      },
github antvis / G2 / test / unit / geom / geom-spec.js View on Github external
describe('test geom interval', function() {
  const data = [
      { a: '1', b: 2, c: '1' },
      { a: '2', b: 5, c: '1' },
      { a: '3', b: 4, c: '1' },

      { a: '1', b: 3, c: '2' },
      { a: '2', b: 1, c: '2' },
      { a: '3', b: 2, c: '2' }
  ];

  scaleA = Scale.cat({
    field: 'a',
    values: [ '1', '2', '3' ],
    range: [ 0.2, 0.8 ]
  });

  const group = canvas.addGroup();
  const geom = new Geom.Interval({
    data,
    coord,
    container: group,
    scales: { a: scaleA, b: scaleB, c: scaleC, red: ScaleRed, 10: ScaleTen }
  });
  const shapeContainer = geom.get('shapeContainer');
  it('draw interval', function() {
    expect(geom.get('type')).eql('interval');
    geom.position('a*b').color('c').adjust('dodge');
github antvis / G2 / test / unit / component / guide / region-spec.js View on Github external
describe('Guide: 辅助背景框', function() {
  const coord = new Coord.Rect({
    start: { x: 60, y: 460 },
    end: { x: 460, y: 60 }
  });

  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 region', function() {
    const region = new Region({
      xScales: {
        month: xScale
      },
      yScales: {
        temp: yScale
      },
github antvis / G2 / test / unit / geom / geom-spec.js View on Github external
});

let scaleA = Scale.linear({
  field: 'a',
  min: 0,
  max: 10
});

const scaleB = Scale.linear({
  field: 'b',
  min: 0,
  max: 5,
  nice: false
});

const scaleC = Scale.cat({
  field: 'c',
  values: [ '1', '2' ]
});

const ScaleRed = Scale.identity({
  field: 'red',
  value: 'red'
});

const ScaleTen = Scale.identity({
  field: '10',
  value: 10
});
const coord = new Coord.Rect({
  start: {
    x: 0,
github antvis / G2 / test / unit / geom / label / polar-labels-spec.js View on Github external
describe('polar labels', function() {
  const coord = new Coord.Polar({
    start: {
      x: 0,
      y: 100
    },
    end: {
      x: 100,
      y: 0
    }
  });

  const labelScale = Scale.cat({
    field: 'z',
    values: [ '1', '2', '3', '4' ]
  });
  const points = [
    { x: 50, y: 10, z: 0, _origin: { x: 50, y: 10, z: '1' } },
    { x: 100, y: 50, z: 1, _origin: { x: 100, y: 50, z: '2' } },
    { x: 10, y: 50, z: 2, _origin: { x: 10, y: 50, z: '3' } }
  ];

  const point = coord.convertPoint({
    x: 0.125,
    y: 0.8
  });
  point.z = 3;
  point._origin = { x: point.z, y: point.y, z: '4' };
  points.push(point);
github antvis / G2 / test / unit / geom / label / geom-labels-spec.js View on Github external
width: 500,
    height: 500
  });

  const coord = new Coord.Cartesian({
    start: {
      x: 0,
      y: 100
    },
    end: {
      x: 100,
      y: 0
    }
  });

  const labelScale = Scale.cat({
    field: 'z',
    values: [ '1', '2' ]
  });
  const points = [
    { x: 100, y: 10, z: 0, _origin: { x: 100, y: 10, z: '1' } },
    { x: 100, y: 20, z: 1, _origin: { x: 100, y: 20, z: '2' } }
  ];

  const labelScale1 = Scale.cat({
    field: 'z',
    values: [[ '1', '2' ], [ '3', '4' ]]
  });
  const points1 = [
    { x: 100, y: [ 10, 20 ], z: [ '1', '2' ], _origin: { x: 100, y: [ 10, 20 ], z: [ '1', '2' ] } },
    { x: 100, y: [ 30, 40 ], z: [ '3', '4' ], _origin: { x: 100, y: [ 30, 40 ], z: [ '3', '4' ] } }
  ];
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