fix: bar chart issue with duplicate x-axis labels being incorrectly ignored (#10134)

Co-authored-by: liusurong.lsr <liusurong.lsr@alibaba-inc.com>
This commit is contained in:
llinvokerl 2024-10-31 21:25:47 +08:00 committed by GitHub
parent dad041c49f
commit 805c701767
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -33,7 +33,9 @@ class BarChartTool(BuiltinTool):
if axis:
axis = [label[:10] + "..." if len(label) > 10 else label for label in axis]
ax.set_xticklabels(axis, rotation=45, ha="right")
ax.bar(axis, data)
# ensure all labels, including duplicates, are correctly displayed
ax.bar(range(len(data)), data)
ax.set_xticks(range(len(data)))
else:
ax.bar(range(len(data)), data)