Skip to content

Scaling bars when using Cell.Width #3067

Answered by bzbetty
bzbetty asked this question in Q&A
Discussion options

You must be logged in to vote

used a useLayoutEffect() to calculate the bar widths based on the chart width

eg

const  [width, setWidth] = useState(40);
const chartRef = React.useRef<any>(null);
useLayoutEffect(() => {
  setWidth(chartRef.current.props.width / 10)
}, [chartRef.current.props.width])

   <Bar>

                    <Cell width={width/>                         
              </Bar>

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

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