Skip to content

Custom function for shape not working with negative values. #3919

Discussion options

You must be logged in to vote

I think i got it working, this is the check I had to add to the renderShape function:

const renderShape = (
  props: any,
  activeBar: any | undefined,
  layout: string
) => {
  const { fillOpacity, payload, value } = props
  let { x, width, y, height } = props

  if (layout === 'horizontal' && height < 0) {
    y += height
    height = Math.abs(height) // height must be a positive number
  } else if (layout === 'vertical' && width < 0) {
    x += width
    width = Math.abs(width) // width must be a positive number
  }

  return (
    <rect
      x={x}
      y={y}
      width={width}
      height={height}
      opacity={
        activeBar
          ? deepEqual(activeBar, { ...payload, value 

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@ckifer
Comment options

@severinlandolt
Comment options

Comment options

You must be logged in to vote
1 reply
@severinlandolt
Comment options

Comment options

You must be logged in to vote
1 reply
@ckifer
Comment options

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
3 participants