Advertisement
Guest User

Untitled

a guest
Feb 16th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const bars = barOf.map((bar, barI) => bar.reduce((prev, curr, i) => {
  2.     barReduce = bar.length
  3.     const previousHeights = prev.reduce((fprev, fcurr) => fprev + fcurr.props.height, 0)
  4.     const minHeight = height - scaleY(curr.count) > 10 ? height - scaleY(curr.count) : 10
  5.     newY = i > 0
  6.       ? bottom - minHeight - previousHeights
  7.       : bottom - minHeight
  8.     const keyword = keywords.find(v => v.word === curr.word)
  9.     newX = barOf.length === 0 && x || barI > 0 ? x + 11 : x - 11
  10.     return [
  11.       ...prev,
  12.       (
  13.         <rect
  14.           key={i}
  15.           onMouseMove={(e) =>
  16.             handleTooltipMove(e, { ...curr, keyword: { ...keyword, summary: extendedSummary[barI] } })}
  17.           onMouseOut={(e) => handleTooltipOut(e)}
  18.           fill={keyword.color} x={newX}
  19.           y={newY} height={minHeight} width={width} />
  20.       )
  21.     ]
  22.   }, []
  23.   ).concat(!!barReduce
  24.     ?
  25.       React.cloneElement(
  26.         icons[barI],
  27.         {
  28.           width: 20,
  29.           height: 20,
  30.           x: newX,
  31.           y: newY - 25
  32.         }
  33.       )
  34.     : []
  35.   ))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement