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

分类图例 受控模式, 请问哪个属性是value? #1540

Open
vaynevayne opened this issue Apr 11, 2023 · 1 comment
Open

分类图例 受控模式, 请问哪个属性是value? #1540

vaynevayne opened this issue Apr 11, 2023 · 1 comment

Comments

@vaynevayne
Copy link

vaynevayne commented Apr 11, 2023

BizCharts Version: 4.x
Platform: chrome
Mini Showcase(like screenshots):
forck and create a demo: https://bizcharts.net/product/BizCharts4/demo/306

  const [uncheckedLegend, setUncheckedLegend] = useState<string[]>([])

  <Legend
              name="country"
              filter={(country) => {
                return !uncheckedLegend.includes(country)
              }}
          
              onChange={(e: any) => {
                console.log('e.item', e.item) // unchecked -> true/false 切换,✅

                const unchecked = e.item.unchecked
// 总是true ❌, 我怀疑是onChange之后, bizcharts内部修改了e.item, 进一步推测 filter 不是受控模式的value,或者这个Legend压根不支持受控模式
                console.log('unchecked', unchecked) 
                console.log('value', e.item.value)

                if (unchecked) {
                  setUncheckedLegend((prev) => [...prev, e.item.value])
                } else {
                  setUncheckedLegend((prev) => prev.filter((str) => str !== e.item.value))
                }
              }}
            />
@vaynevayne vaynevayne changed the title 分类 Legend 的受控模式, 哪个属性是value? 分类图例 受控模式, 请问哪个属性是value? Apr 11, 2023
@vaynevayne
Copy link
Author

原始需求: 切换xField或者yField时,保留zField,
解决办法: LineChart 换成 就行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant