Explorar el Código

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

Co-authored-by: liusurong.lsr <liusurong.lsr@alibaba-inc.com>
llinvokerl hace 5 meses
padre
commit
805c701767
Se han modificado 1 ficheros con 3 adiciones y 1 borrados
  1. 3 1
      api/core/tools/provider/builtin/chart/tools/bar.py

+ 3 - 1
api/core/tools/provider/builtin/chart/tools/bar.py

@@ -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)