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

5.0新增api对应4.0的getXY #6620

Open
sanye-huang opened this issue Feb 28, 2025 · 5 comments
Open

5.0新增api对应4.0的getXY #6620

sanye-huang opened this issue Feb 28, 2025 · 5 comments
Labels
feature 💡 A new feature request or an enhancement proposal

Comments

@sanye-huang
Copy link

主要用于给某一些x的特定位置(比如max、min)添加标注。目前设置text要么是data要么是x y的百分比像素,无法做到对应的功能。

@github-actions github-actions bot added the waiting for maintainer Triage or intervention needed from a maintainer label Feb 28, 2025
@antvis antvis deleted a comment from petercat-assistant bot Feb 28, 2025
@interstellarmt
Copy link
Contributor

感觉需要的是text标记的data语法糖(max,min),getXY方法的优先级可能不高?

@interstellarmt interstellarmt added need improvement Lack of information or incorrect format and removed waiting for maintainer Triage or intervention needed from a maintainer labels Mar 3, 2025
@github-actions github-actions bot added the waiting for author Further information is requested from the author label Mar 3, 2025
Copy link

github-actions bot commented Mar 3, 2025

📝 To help us better understand and address your issue, please provide more information, or use the standard format, otherwise we will not process this issue.

Reference document:


📝 为了帮助我们更好地理解和解决你的问题,请提供更多信息,或者使用规范的格式,否则我们不会处理这个 issue。

参考文档:

@sanye-huang
Copy link
Author

需要感觉的是文本标记的数据语法糖(max,min),getXY方法的优先级可能不高?

优先级都不是很高,getxy和min、max我觉得对一些灵活场景都非常有必要

@github-actions github-actions bot added waiting for maintainer Triage or intervention needed from a maintainer and removed waiting for author Further information is requested from the author labels Mar 3, 2025
@interstellarmt
Copy link
Contributor

如果是上面说的这种场景,给某一些x的特定位置(比如max、min)添加标注,其实内置的transform已经支持

type Selector =
  | 'min'
  | 'max'
  | 'first'
  | 'last'
  | 'mean'
  | 'median'
  | ((I: number[], V: number[]) => number[]);

以下是示例

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

const chart = new Chart({
  container: 'container',
  autoFit: true,
});

chart
  .data({
    type: 'fetch',
    value:
      'https://gw.alipayobjects.com/os/antvdemo/assets/data/blockchain.json',
    transform: [
      {
        type: 'fold',
        fields: ['blockchain', 'nlp'],
        key: 'type',
        value: 'value',
      },
    ],
  })
  .axis('x', { labelAutoHide: 'greedy' });

chart
  .line()
  .encode('x', (d) => new Date(d.date))
  .encode('y', 'value')
  .encode('color', 'type');

chart
  .text()
  .encode('x', (d) => new Date(d.date))
  .encode('y', 'value')
  .transform({ type: 'select', channel: 'y', selector: 'max' })
  .style({
    text: `2017-12-17, 受比特币影响,blockchain 搜索热度达到峰值:100`,
    wordWrap: true,
    wordWrapWidth: 164,
    dx: -174,
    dy: 30,
    fill: '#2C3542',
    fillOpacity: 0.65,
    fontSize: 10,
    background: true,
    backgroundRadius: 2,
    connector: true,
    startMarker: true,
    startMarkerFill: '#2C3542',
    startMarkerFillOpacity: 0.65,
  })
  .tooltip(false);

chart.render();

@interstellarmt interstellarmt removed the need improvement Lack of information or incorrect format label Mar 5, 2025
@sanye-huang
Copy link
Author

假设我希望画一个图形,如下

Image

可能是一个点到另外一个点的箭头,可能是三个点的三角形关系,在4里面只需要获取各个点的xy,然后render一个自定义shape就可以

@interstellarmt interstellarmt added feature 💡 A new feature request or an enhancement proposal and removed waiting for maintainer Triage or intervention needed from a maintainer labels Mar 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 💡 A new feature request or an enhancement proposal
Projects
None yet
Development

No branches or pull requests

2 participants