antvis/G2

【特性】label 数据标签支持富文本格式 #5133

hustcc posted onGitHub

image


chart
  .interval()
  .encode('x', 'x')
  .encode('y', 'y')
  .label({
    render: (text, datum) => { return 'hello world'; }  // 👈🏻
  })
posted by hustcc almost 2 years ago

可以和 tooltip.render 保持一致的返回值:string | HTMLElement

posted by pearmini almost 2 years ago

请教一下,quickBI 的这个效果是用 annotation 做的还是用自定义 label 做的 image

posted by stillsilly almost 2 years ago

我有个类似的需求,刚刚想用自定义 label 做,看了下 label 的源码,发现 label 的 content 可以传 group 或者 shape。 然后试了下,直接生成一个 group,加 2 个不同样式的 text shape,传给 content,可以实现这个效果。 (写在这里,以供后来有类似问题的人参考,https://codesandbox.io/s/laughing-ramanujan-mwv7vr

还是有点好奇,quickBI是用啥做的

posted by stillsilly almost 2 years ago

可以看看 dom 结构,只有两种方案,不是 html label 就是和你一样的方案。

posted by hustcc almost 2 years ago

好的 谢谢

posted by stillsilly almost 2 years ago

Fund this Issue

$0.00
Funded

Pull requests