antvis/G6

Legend插件如何更改节点文字的样式? #4677

charle004 posted onGitHub

问题描述

根据官网Legend插件的第一个示例实例,然后结合文档,目测 nodeStateStyles 下的 activeByLegend 只能配置节点相关的样式,而节点文字的配置似乎不可以,我尝试过不行,有什么其他解决方法吗? 在过滤图的节点时,节点文字却不能过滤,不太友好

重现链接

https://g6.antv.antgroup.com/zh/examples/tool/legend/#legend

重现步骤

根据官网Legend插件的第一个示例实例,然后结合文档,目测 nodeStateStyles 下的 activeByLegend 只能配置节点相关的样式

预期行为

我希望Legend插件可以配置节点同时配置节点文字的样式

平台

  • 操作系统: [Windows]
  • 网页浏览器: [Google Chrome]
  • G6 版本: [4.3.11]

屏幕截图或视频(可选)

No response

补充说明(可选)

No response


Snipaste_2023-06-25_23-54-55

posted by charle004 almost 2 years ago

nodeStateStyles 可以配置子图形的状态样式

看这里的子图形状态样式 https://g6.antv.antgroup.com/manual/advanced/state-new

posted by Yanyan-Wang almost 2 years ago

nodeStateStyles 可以配置子图形的状态样式

看这里的子图形状态样式 https://g6.antv.antgroup.com/manual/advanced/state-new

意思是 文字是节点的子元素吗? 我按下述配置试过了 不生效的

` nodeStateStyles: { activeByLegend: { lineWidth: 10, strokeOpacity: 0.5, }, inactiveByLegend: { opacity: 0.1,

                //下述配置是不生效的
                labelCfg: {
                    style:{
                        opacity: 0.1
                    }
                }

            }
        },`
posted by charle004 almost 2 years ago

` nodeStateStyles: { activeByLegend: { lineWidth: 10, strokeOpacity: 0.5, }, inactiveByLegend: { opacity: 0.1,

                //下述配置是不生效的
                labelCfg: {
                    style:{
                        opacity: 0.1
                    }
                }

            }
        }

`

posted by charle004 almost 2 years ago

看下文档,在状态样式配置中,key 是子图形的 name,如果是内置节点,文本图形的 name 是 text-shape,所以可以写成

inactiveByLegend: { 'text-shape': { opacity: 0.1 } }

posted by Yanyan-Wang almost 2 years ago

This issue has been closed because it has been outdate for a long time. Please open a new issue if you still need help.

这个 issue 已经被关闭,因为 它已经过期很久了。 如果你仍然需要帮助,请创建一个新的 issue。

posted by github-actions[bot] 10 months ago

Fund this Issue

$0.00
Funded

Pull requests