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

🐛[BUG]双轴图隐藏slider失败 #2510

Closed
joshchiucn opened this issue Apr 19, 2024 · 1 comment
Closed

🐛[BUG]双轴图隐藏slider失败 #2510

joshchiucn opened this issue Apr 19, 2024 · 1 comment

Comments

@joshchiucn
Copy link

🐛 bug 描述 [详细地描述 bug,让大家都能理解]

当给双轴图设置slider后, 如果删除slider属性,slider仍然会展示,必须显式设置slider=false才能隐藏。 1.x 版本/ 2.x版本都有该问题。

📷 复现步骤 [清晰描述复现步骤,让别人也能看到问题]

第一步, 设置config如下

const config = {
  data: [],
  // ...其他属性
  slider: { start: 0, end: 0 },
}

第二步, 删除config中slider属性,然后发现双轴图slider仍然展示;

🏞 期望结果 [描述你原本期望看到的结果]

当去掉slider属性后自动隐藏slider,而不是显式传false

💻 复现代码 [提供可复现的代码,仓库,或线上示例]

import React, { useState, useEffect } from 'react';
import ReactDOM from 'react-dom';
import { DualAxes } from '@ant-design/plots';

const DemoDualAxes = () => {
  const [sliderConfig, setSliderConfig] = useState({
    slider: {
      start: 0,
      end: 1,
    },
  })
  const data = [
    {
      time: '2019-03',
      value: 350,
      count: 800,
    },
    {
      time: '2019-04',
      value: 900,
      count: 600,
    },
    {
      time: '2019-05',
      value: 300,
      count: 400,
    },
    {
      time: '2019-06',
      value: 450,
      count: 380,
    },
    {
      time: '2019-07',
      value: 470,
      count: 220,
    },
  ];
  const config = {
    data: [data, data],
    xField: 'time',
    yField: ['value', 'count'],
    ...sliderConfig,
    geometryOptions: [
      {
        geometry: 'column',
      },
      {
        geometry: 'line',
        lineStyle: {
          lineWidth: 2,
        },
      },
    ],
  };
  const onHideSlider = () => {
    setSliderConfig({})
  };
  return <>
    <button onClick={onHideSlider}>隐藏slider</button>
    <DualAxes {...config} />
  </>;
};

ReactDOM.render(<DemoDualAxes />, document.getElementById('container'));

© 版本信息

  • ant-design-charts 版本: 1.4.2
  • 浏览器环境 Chrome@latest
  • 开发环境 Mac

🚑 其他信息 [如截图等其他信息可以贴在这里]

@lxfu1
Copy link
Member

lxfu1 commented Apr 19, 2024

试一下设置为false

@lxfu1 lxfu1 closed this as completed May 21, 2024
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

2 participants