Skip to content

get xAxis ticks at start of bars #2722

Answered by 201flaviosilva
Joyfred asked this question in Q&A
Discussion options

You must be logged in to vote

Hey,

I know this thread is already kinda dead, but I think I found the answer to your question:

<BarChart width={400} height={300} data={data}>
  <XAxis dataKey="name" tick={null} />
  <YAxis
    domain={[0, "dataMax + 10"]}
  />

  <Bar
    dataKey="value"
    fill="#8884d8"
    stroke="#000"
    strokeWidth={1}>
      <LabelList dataKey="name" position="top" /> {/* Use this to display the label at the top of the bar */}
    </Bar>
  </BarChart>

Here is a code running project example: https://bitbucket.org/201flaviosilva-labs/react-recharts-get-xaxis-ticks-at-start-of-bars-2722/

All code here:

import { Bar, BarChart, CartesianGrid, LabelList, Tooltip, XAxis, YAxis } from "recharts";

const 

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ckifer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants