antvis/G2

【V5】Legend Marker 自定义 string 的时候不生效 #5316

BinghuiXie posted onGitHub

<!-- Thank you for reporting an issue. 1. It's RECOMMENDED to submit PR for typo or tiny bug fix. 2. If this's a FEATURE request, please provide: details, pseudo codes if necessary. 3. If this's a BUG, please provide: course repetition, error log and configuration. Fill in as much of the template below as you're able. 4. It will be nice to use to provide a CodePen Link which can reproduce the issue, we provide a CodePen template g2-github-issue. 感谢您向我们反馈问题。 1. 提交问题前,请先阅读 README 中的贡献帮助文档。 2. 我们推荐如果是小问题(错别字修改,小的 bug fix)直接提交 PR。 3. 如果是一个新需求,请提供:详细需求描述,最好是有伪代码实现。 4. 如果是一个 BUG,请提供:复现步骤,错误日志以及相关配置,并尽量填写下面的模板中的条目。 5. 如果可以,请提供尽可能精简的 CodePen 链接,可使用 CodePen 模板 https://codepen.io/leungwensen/pen/WXJgox,方便我们排查问题。 6. 扩展阅读:如何向开源项目提交无法解答的问题 -->

  • G2 Version:
  • Platform:
  • Mini Showcase(like screenshots):
  • CodePen Link:

<!-- Enter your issue details below this comment. -->

如图所示 image 配置 itemMarker 为字符串的时候图例 marker 不生效。

根据官方文档,itemMarker 只支持 DisplayObject 或者对应的函数,但是默认值又给了一个 circle image 如果没有一些内置的 marker,通过 DisplayObject 或者函数的形式实现一个不同样式的 marker 是否成本太高? image 官方 demo 有一个是设置了 string 类型的 itemMarker,也没有展示出来

PS: 看了下代码,问题应该在 legendCategory.ts 这个文件里面 20230716203509_rec_

这里在拷贝的时候,style 的优先级是最高的,会覆盖 legendStyle 的同名属性,而由于自己配置的 itemMarker 会被解构在 style 里面;而在前一步给 legendStyle 推断 marker shape(inferItemMarker) 的时候,会生成同名的 legendMarker 函数。 因此 legendStyle 里面的会被覆盖

image

在实际绘制的时候,会直接 document.createElement('point'),所以不会生效


Fund this Issue

$0.00
Funded

Pull requests