条形图中的标签?

Label in BarChart?

是否可以将标签设置到条形图中?

像这个例子: 我在官方页面上找不到示例:Official example page

//编辑

后来我遇到了其他问题,但我可以通过切换到 Nivo Charts 来解决它们。 Nivo Charts

您可以将 LabelList 组件与自定义渲染一起使用,这里是文档的 link:

https://recharts.org/en-US/api/LabelList

您也可以使用位置 属性 将其置于栏内居中,这里是自定义 LabelList 的示例: https://recharts.org/en-US/examples/BarChartWithMinHeight

您可以使用标签 options 以这种方式执行此操作:

options: {
    scales: {
      xAxes: [
        {
          ticks: {
            autoSkip: false,
            maxRotation: 90,
            minRotation: 90,
            padding: -110
          }
        }
      ]
    }
  }

结果是:

This 是一个 codesandbox 示例。