antvis / antvis/G2

在使用spaceLayer的情况下 给layer加上text()后会导致tooltip展示不出,是什么问题

Open
#6,026 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
12.6k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Description

### 问题描述

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

const data = [
{ item: '事例一', count: 40 },
{ item: '事例二', count: 21 }
];

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

layer
.interval()
.data(data)
.coordinate({ type: 'theta', outerRadius: 0.8, innerRadius: 0.5 })
.transform({ type: 'stackY' })
.encode('y', 'count')
.encode('color', 'item')
.legend('color', { position: 'bottom', itemMarker: 'circle', layout: { justifyContent: 'center' } })
.tooltip((data) => ({
name: data.item,
value: data.count,
}));

layer
.text()
.style('text', '主机')
// Relative position
.style('x', '50%')
.style('y', '50%')
.style('dy', -25)
.style('fontSize', 34)
.style('fill', '#8c8c8c')
.style('textAlign', 'center')

chart.render();

### 重现链接

_No response_

### 重现步骤

_No response_

### 预期行为

_No response_

### 平台

- 操作系统: [macOS, Windows, Linux, React Native ...]
- 网页浏览器: [Google Chrome, Safari, Firefox]

### 屏幕截图或视频(可选)

_No response_

### 补充说明(可选)

_No response_

Contributor guide

Open the contributing guide

Research direction

Reproduce the provided G2 example with `spaceLayer()`, the interval tooltip, and the added `text()` layer, then compare tooltip behavior with and without the text layer. Trace the rendering and tooltip interaction entry points involved in those layers; done means the tooltip displays correctly while the centered text remains visible.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.