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] Can not custom tooltip names in DualAxes chart #2829

Open
gicungdc123 opened this issue Jan 6, 2025 · 0 comments
Open

🐛[BUG] Can not custom tooltip names in DualAxes chart #2829

gicungdc123 opened this issue Jan 6, 2025 · 0 comments

Comments

@gicungdc123
Copy link

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

Unable to customize tooltip names in DualAxes chart component from ant-design-charts. Both array and function approaches in the tooltip configuration are not working as expected. While the value and color properties work correctly, the custom name property is not being applied to the tooltip display.

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

  1. Create a DualAxes chart with two line series
  2. Try to customize tooltip names using either:
    • Function approach: tooltip: () => ({name: "test", value: 123})
    • Array approach: tooltip: [{name: 'aaaa', color: "red"}]
  3. Render the chart
  4. Hover over data points

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

  • When hovering over the first line series, tooltip should show "test" as the name
  • When hovering over the second line series, tooltip should show "aaaa" as the name
image

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


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

const DemoDualAxes = () => {
  const data = [
    { year: '1991', value: 3, count: 10 },
    { year: '1992', value: 4, count: 4 },
    { year: '1993', value: 3.5, count: 5 },
    { year: '1994', value: 5, count: 5 },
    { year: '1995', value: 4.9, count: 4.9 },
    { year: '1996', value: 6, count: 35 },
    { year: '1997', value: 7, count: 7 },
    { year: '1998', value: 9, count: 1 },
    { year: '1999', value: 13, count: 20 },
  ];

  const config = {
    data,
    xField: 'year',
    legend: true,
    children: [
      {
        type: 'line',
        yField: 'value',
        style: {
          stroke: '#5B8FF9',
          lineWidth: 2,
        },
        tooltip:()=>({name:"test",value:123}),
        axis: {
          y: {
            title: 'value',
            style: { titleFill: '#5B8FF9' },
          },
        },
      },
      {
        type: 'line',
        yField: 'count',
        style: {
          stroke: '#5AD8A6',
          lineWidth: 2,
        },
        tooltip:[{name:'aaaa',color:"red"}],
        axis: {
          y: {
            position: 'right',
            title: 'count',
            style: { titleFill: '#5AD8A6' }
          },
        },
      },
    ],
  };
  return <DualAxes {...config} />;
};

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

© 版本信息

  • "@ant-design/charts": "^2.2.6"
  • 浏览器环境
  • 开发环境 [e.g. mac OS]

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

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