antvis/G2
The issue has been closed
[v5] Tooltip title 展示不正常 #4561
visiky posted onGitHub
描述
encode('x', (d) => new Date(d.Date))
会出现 tooltip title 重复现象,设置为 encode('x', 'Date')
则展示正常
<img width="400" alt="image" src="https://user-images.githubusercontent.com/15646325/211258530-b42d6164-5031-43ed-a77e-c4a9eef28c6c.png">
import { Chart } from '@antv/g2';
const chart = new Chart({
container: 'container',
autoFit: true,
paddingLeft: 50,
});
chart.interaction({type:'tooltip'})
chart
.line()
.data({
type: 'fetch',
value: 'https://assets.antv.antgroup.com/g2/indices.json',
})
.transform({ type: 'normalizeY', basis: 'first', groupBy: 'color' })
// tooltip title 正常
// .encode('x', 'Date')
.encode('x', (d) => new Date(d.Date))
.encode('y', 'Close')
.encode('color', 'Symbol')
.scale('y', { type: 'log' })
.axis('y', { title: '↑ Change in price (%)' })
chart.render();