0

I'm using recharts and trying to use the position property of the label object in the Bar component to set the label at the top-inner position but I couldn't find the correct approach for it.

code:

    <ResponsiveContainer width="100%" height="100%">
    <BarChart
      data={data}
    >
      <XAxis
        type={"category"}
        hide={false}
        tickLine={false}
        axisLine={false}
        dataKey={"age"}
      />
      <YAxis hide={true} dataKey={""} axisLine={false} tickLine={false} type={"number"} />
      <Bar
        dataKey="age"
        background={{ fill: "theme.darkblue" }}
        label={{ position: "top" }}
      >
        {data.bar.map((d: IData, index: number) => (
          <Cell
            key={index}
            fill={"green"}
          />
        ))}
      </Bar>
    </BarChart>
  </ResponsiveContainer>

current: top label desirable: inner top label

Ar26
  • 949
  • 1
  • 12
  • 29

0 Answers0