antvis / G2

📊 The concise and progressive visualization grammar.
https://g2.antv.antgroup.com
MIT License
12.1k stars 1.59k forks source link

折线图悬停提示不正确 #6342

Open Calmio-Y opened 3 months ago

Calmio-Y commented 3 months ago

问题描述

import { Chart } from '@antv/g2';

const data = [ { month: 'Jan', city: 'Tokyo', temperature: 7 }, { month: 'Jan', city: 'London', temperature: 3.9 }, // { month: 'Feb', city: 'Tokyo', temperature: null }, { month: 'Feb', city: 'London', temperature: 4.2 }, { month: 'Mar', city: 'Tokyo', temperature: 9.5 }, { month: 'Mar', city: 'London', temperature: 5.7 }, { month: 'Apr', city: 'Tokyo', temperature: 14.5 }, { month: 'Apr', city: 'London', temperature: 8.5 }, { month: 'May', city: 'Tokyo', temperature: 18.4 }, { month: 'May', city: 'London', temperature: 11.9 }, { month: 'Jun', city: 'Tokyo', temperature: 21.5 }, { month: 'Jun', city: 'London', temperature: 15.2 }, { month: 'Jul', city: 'Tokyo', temperature: 25.2 }, { month: 'Jul', city: 'London', temperature: 17 }, { month: 'Aug', city: 'Tokyo', temperature: 26.5 }, { month: 'Aug', city: 'London', temperature: 16.6 }, { month: 'Sep', city: 'Tokyo', temperature: 23.3 }, { month: 'Sep', city: 'London', temperature: 14.2 }, { month: 'Oct', city: 'Tokyo', temperature: 18.3 }, { month: 'Oct', city: 'London', temperature: 10.3 }, { month: 'Nov', city: 'Tokyo', temperature: 13.9 }, { month: 'Nov', city: 'London', temperature: 6.6 }, { month: 'Dec', city: 'Tokyo', temperature: 9.6 }, { month: 'Dec', city: 'London', temperature: 4.8 }, ];

const chart = new Chart({ container: 'container', autoFit: true, });

chart .data(data) .encode('x', 'month') .encode('y', 'temperature') .encode('color', 'city') // .scale('x', { // range: [0, 1], // }) // .scale('y', { // nice: true, // }) // .axis('y', { labelFormatter: (d) => d + '°C' });

chart.line().encode('shape', 'smooth');

chart.point().encode('shape', 'point').tooltip(false);

chart.render();

重现链接

No response

重现步骤

1:复制代码到demo 2:悬停提示

预期行为

No response

平台

屏幕截图或视频(可选)

企业微信截图_17199758034159

补充说明(可选)

No response

pearmini commented 3 months ago

看上去应该是一个 bug

Calmio-Y commented 2 months ago

@pearmini 双y轴的刻度线怎么设置对齐

Calmio-Y commented 2 months ago

@pearmini 双y轴的刻度线对齐有没有好方法