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

fix(types): axis for composition #4851

Merged
merged 2 commits into from
Mar 29, 2023
Merged

fix(types): axis for composition #4851

merged 2 commits into from
Mar 29, 2023

Conversation

pearmini
Copy link
Member

@pearmini pearmini commented Mar 29, 2023

  • 增加一个复合图表更新数据的单侧保证正确性。
  • 修复和 composition 相关的 types。

image

import { Chart } from '@antv/g2';

const chart = new Chart({ theme: 'classic', container: 'container' });

const view = chart
  .facetRect()
  .data([
    { name: 'CPU', percent: 27, color: 'rgba(90, 132, 226, 1)' },
    { name: '内存', percent: 81, color: 'rgba(250, 57, 57, 1)' },
    { name: '硬盘', percent: 68, color: 'rgba(253, 192, 45, 1)' },
  ])
  .encode('x', 'name')
  .axis(false)
  .legend(false)
  .view()
  .attr('frame', false)
  .coordinate({ type: 'radial', innerRadius: 0.7, outerRadius: 0.95 });

view
  .interval()
  .encode('y', 100)
  .encode('size', 52)
  .scale('y', { zero: true })
  .axis(false)
  .style('fill', 'rgba(232, 232, 232, 1)')
  .animate(false);

view
  .interval()
  .encode('y', 'percent')
  .encode('color', 'color')
  .encode('size', 80)
  .scale('color', { type: 'identity' })
  .tooltip({ name: '已使用', channel: 'y' })
  .axis(false)
  .style('radius', 26)
  .style('shadowColor', 'color')
  .style('shadowBlur', 10)
  .style('shadowOffsetX', -1)
  .style('shadowOffsetY', -1)
  .animate('enter', { type: 'waveIn', duration: 1000 });

view
  .text()
  .encode('text', (d) => `${d.name} ${d.percent}%`)
  .style('textAlign', 'center')
  .style('textBaseline', 'middle')
  .style('fontSize', 15)
  .style('color', 'rgba(74, 74, 74, 1)')
  .style('x', '50%')
  .style('y', '50%');

chart.render();

@Aarebecca
Copy link
Contributor

为啥把圆心的文本隐藏掉 大小就不一致了呢
image

@pearmini
Copy link
Member Author

为啥把圆心的文本隐藏掉 大小就不一致了呢 image

这里应该不需要 `interval.encode('x', 'name'):

view
  .interval()
  .encode('x', 'name') // 不需要这一行

@Aarebecca Aarebecca merged commit 0615ca8 into v5 Mar 29, 2023
@Aarebecca Aarebecca deleted the fix/rerender-facet branch March 29, 2023 10:49
@pearmini pearmini mentioned this pull request Apr 23, 2023
hustcc pushed a commit that referenced this pull request May 16, 2023
* fix(types): axis for composition

* docs(site): update apple-activity
hustcc pushed a commit that referenced this pull request May 16, 2023
* fix(types): axis for composition

* docs(site): update apple-activity
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants