antvis / antvis/G2Plot

🐛 [BUG] 分组柱形图配置了 meta values 后,图形向左偏移

Open
#2,931 0 comments 0 reactions 0 assignees View on GitHub
Bug
Dominant language
TypeScript
Stars
2.7k
Forks
591
PR merge metrics
No merged PRs in 30d

Description

### 🐛 Bug description [Please make everyone to understand it]

> Please provide a link by forking these links [G2Plot](https://codesandbox.io/s/g2plot-issue-template-gzfdq?file=/index.ts) or GitHub repo, a minimal reproduction.

* _Required_ **Link to minimal reproduction**:

### 📷 Step to reproduce

代码:
```typescript
import { GroupedColumn } from '@antv/g2plot';

const data = [
{
name: 'base',
bucket: '-4',
count: 1,
},
{
name: 'base',
bucket: '-1',
count: 1,
},
{
name: 'feature',
bucket: '0',
count: 4,
},
{
name: 'base',
bucket: '0',
count: 1,
},
]

const columnPlot = new GroupedColumn(document.getElementById('container'), {
title: {
visible: true,
text: '分组柱状图',
},
forceFit: true,
data,
xField: 'bucket',
yField: 'count',
yAxis: {
min: 0,
},
label: {
visible: true,
},
groupField: 'name',
meta: {
bucket: { values: ['-4', '-2', '-1', '0', '1', '2', '3'] },
},
color: ['#1ca9e6', '#f88c24'],
})

columnPlot.render()
```

渲染结果:
![image](https://user-images.githubusercontent.com/11092123/138069078-3d367d49-218a-41cb-b00d-c72f7a544aaa.png)

### 🏞 Expected result

### 🚑 Any additional [like screenshots]

* **G2Plot Version**:
* 官网
* **Platform**:
* macOS Edge 94

Contributor guide

Open the contributing guide

Research direction

Start with the supplied TypeScript reproduction using GroupedColumn and the bucket meta.values configuration. Compare the rendered grouped bars with and without the configured values, then trace the chart behavior responsible for category positioning. Done means the grouped columns no longer shift left when the meta values include categories not present in the data.

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
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.