antvis/G6

内置的 behavior 会移除用户自定义state #6154

abc3660170 posted onGitHub

Describe the bug / 问题描述

图形配置一个内置的behavior:click-select, 同时给节点增加一个自定义state: important,当点击这个节点再点击画布空白区域,节点会移除掉我增加的 important state。 当我按住SHIFT多选且第一个选中节点是未配置important state的节点,第二个节点是配置important state的节点时,important 的状态就不会丢失。

https://stackblitz.com/edit/react-vqdqdc-svjpyr?file=index.js

Steps to Reproduce the Bug or Issue / 重现步骤

No response

G6 Version / G6 版本

🆕 5.x

Operating System / 操作系统

Windows

Browser / 浏览器

Chrome

Additional context / 补充说明

No response


我也遇到了设置了selected 就是默认黑色的stroke 修改不了,配置了 stroke: 'red',就是红色,但是在https://g6.antv.antgroup.com/zh/examples/interaction/zoomCanvasFixItem/#fixItem 中有一个默认的和节点色域相同的selected状态色,在5.x找不到如何配置

    node: {
      state: {
        selected: {
          stroke: 'red',
          lineWidth: 3,
        },
      },
      style: (item) => {
        return {
          fill: item.cov_status ? '#3ad186' : '#f24f4f',
        }
      },
    },
posted by Pancake-Q 9 months ago

我也遇到了设置了selected 就是默认黑色的stroke 修改不了,配置了 stroke: 'red',就是红色,但是在https://g6.antv.antgroup.com/zh/examples/interaction/zoomCanvasFixItem/#fixItem 中有一个默认的和节点色域相同的selected状态色,在5.x找不到如何配置

    node: {
      state: {
        selected: {
          stroke: 'red',
          lineWidth: 3,
        },
      },
      style: (item) => {
        return {
          fill: item.cov_status ? '#3ad186' : '#f24f4f',
        }
      },
    },

我这边更重要的诉求是我自定义的状态被系统移除了,虽然你说的状态色没继承也确实是一个问题。

posted by abc3660170 9 months ago

@Pancake-Q 没太理解你的意思,设置 node.state.selected.strokered 是可以正常生效的

posted by Aarebecca 9 months ago

@Aarebecca https://g6.antv.antgroup.com/examples/interaction/select/#click v4.8.21选中的颜色是会继承 https://g6-next.antv.antgroup.com/examples/behavior/select/#click v5.0 颜色没有继承 我理解的继承是seleted状态颜色 和节点颜色为同一个色域

posted by Pancake-Q 9 months ago

@Aarebecca https://g6.antv.antgroup.com/examples/interaction/select/#click v4.8.21选中的颜色是会继承 https://g6-next.antv.antgroup.com/examples/behavior/select/#click v5.0 颜色没有继承 我理解的继承是seleted状态颜色 和节点颜色为同一个色域

5.0 目前是需要手动指定的,暂不支持样式继承

posted by Aarebecca 9 months ago

Fund this Issue

$0.00
Funded

Pull requests