Skip to content

feat(bar chart): make barGapInGroup percentage based on actual barWidth#3950

Merged
xuefei1313 merged 2 commits intoVisActor:feat(bar-chart)-make-barGapInGroup-percentage-based-on-actual-barWidth-#3950from
FoundDream:feat/modify-bar-gap-in-group-percentage
May 14, 2025
Merged

feat(bar chart): make barGapInGroup percentage based on actual barWidth#3950
xuefei1313 merged 2 commits intoVisActor:feat(bar-chart)-make-barGapInGroup-percentage-based-on-actual-barWidth-#3950from
FoundDream:feat/modify-bar-gap-in-group-percentage

Conversation

@FoundDream
Copy link

@FoundDream FoundDream commented May 9, 2025

🤔 This is a ...

  • [✅] New feature
  • Bug fix
  • TypeScript definition update
  • Bundle size optimization
  • Performance optimization
  • Enhancement feature
  • Refactoring
  • Update dependency
  • Code style optimization
  • Test Case
  • Branch merge
  • Release
  • [✅] Site / documentation update
  • Demo update
  • Workflow
  • Other (about what?)

🔗 Related issue link

closed #3660

🔗 Related PR link

🐞 Bugserver case id

💡 Background and solution

Background

在 VChart 的柱状图(Bar Chart)组件中,barGapInGroup 属性用于控制同一组内柱子之间的间距。这个属性支持绝对像素值和百分比值(如 '50%')两种形式。在之前的实现中,当使用百分比值时,是基于 bandWidth(分配空间)计算的,而非基于柱子的实际宽度。
这带来了一个问题: barMaxWidth barMinWidth barWidth会导致barWidth≠bandWidth,柱子间距并不会随着实际柱宽的变化而等比例调整,导致视觉效果不一致。

solution

修改 _getPosition 方法中计算 gap 的逻辑,将百分比基准从 bandWidth 改为实际的 barWidth

修改前的效果:
before

修改后的效果:
after

📝 Changelog

会影响同一组内柱子之间的间距

Language Changelog
🇺🇸 English
🇨🇳 Chinese

☑️ Self-Check before Merge

⚠️ Please check all items below before requesting a reviewing. ⚠️

  • [✅] Doc is updated/provided or not needed
  • [✅] Demo is updated/provided or not needed
  • [✅] TypeScript definition is updated/provided or not needed
  • [✅] Changelog is provided or not needed

🚀 Summary

copilot:summary

🔍 Walkthrough

copilot:walkthrough

@xuefei1313 xuefei1313 changed the base branch from develop to feat(bar-chart)-make-barGapInGroup-percentage-based-on-actual-barWidth-#3950 May 14, 2025 08:04
@xuefei1313 xuefei1313 merged commit 4544730 into VisActor:feat(bar-chart)-make-barGapInGroup-percentage-based-on-actual-barWidth-#3950 May 14, 2025
7 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Supports configuring bar spacing to always be a percentage of bar width

3 participants