Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const bars = barOf.map((bar, barI) => bar.reduce((prev, curr, i) => {
- barReduce = bar.length
- const previousHeights = prev.reduce((fprev, fcurr) => fprev + fcurr.props.height, 0)
- const minHeight = height - scaleY(curr.count) > 10 ? height - scaleY(curr.count) : 10
- newY = i > 0
- ? bottom - minHeight - previousHeights
- : bottom - minHeight
- const keyword = keywords.find(v => v.word === curr.word)
- newX = barOf.length === 0 && x || barI > 0 ? x + 11 : x - 11
- return [
- ...prev,
- (
- <rect
- key={i}
- onMouseMove={(e) =>
- handleTooltipMove(e, { ...curr, keyword: { ...keyword, summary: extendedSummary[barI] } })}
- onMouseOut={(e) => handleTooltipOut(e)}
- fill={keyword.color} x={newX}
- y={newY} height={minHeight} width={width} />
- )
- ]
- }, []
- ).concat(!!barReduce
- ?
- React.cloneElement(
- icons[barI],
- {
- width: 20,
- height: 20,
- x: newX,
- y: newY - 25
- }
- )
- : []
- ))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement