Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

饼图 getSnapRecords 取值问题 #67

Closed
simaQ opened this issue Mar 2, 2018 · 1 comment
Closed

饼图 getSnapRecords 取值问题 #67

simaQ opened this issue Mar 2, 2018 · 1 comment
Assignees
Labels

Comments

@simaQ
Copy link
Contributor

simaQ commented Mar 2, 2018

  • F2 Version: 3.1.0
  • Platform:
  • Mini Showcase(like screenshots):
  • CodePen Link:
const data = [
    { "uKey": "1",percent": 0.2771,const": "const" },
    { "uKey": "2", "percent": 0.18083, "const": "const" },
    { "uKey": "3", "percent": 0.14108, "const": "const" },
    { "uKey": "4", "percent": 0.13868, "const": "const" },
    { "uKey": "5", "percent": 0.05662, "const": "const" },
    { "uKey": "6", "percent": 0.05523, "const": "const" },
    { "uKey": "7", "percent": 0.03355, "const": "const" },
    { "uKey": "8", "percent": 0.03079, "const": "const" },
    { "uKey": "9", "percent": 0.02864, "const": "const" },
    { "uKey": "10", "percent": 0.01879, "const": "const" },
    { "uKey": "11", "percent": 0.03869, "const": "const" }
  ];

  const chart = new F2.Chart({
    id: 'mountNode',
    width: window.innerWidth,
    height: window.innerWidth * 0.64,
    pixelRatio: window.devicePixelRatio,
    padding: [ 50, 'auto' ]
  });

  chart.source(data);
  chart.legend(false);
  chart.coord('polar', {
    transposed: true,
    inner: 0.6
  });
  chart.axis(false);
  chart.interval().position('const*percent').color('percent', (v, i) => {
    return `rgba( 255 ,0 ,0 , ${((v[1] - v[0]) * 3).toFixed(3)} )`;
  }).adjust('stack');
  chart.render();

  document.querySelector('#mountNode').addEventListener('click', e => {
      let {left: x, top: y} = e.target.getBoundingClientRect();
      x = event.clientX - x;
      y = event.clientY - y;
      console.log(chart.getSnapRecords({x, y}, 'percent')[0]._origin);
  });
@simaQ simaQ self-assigned this Mar 2, 2018
@simaQ simaQ added the bug label Mar 2, 2018
@simaQ simaQ closed this as completed in 53fd40f Mar 3, 2018
@simaQ
Copy link
Contributor Author

simaQ commented Mar 3, 2018

@antv/f2@3.1.1-beta.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant