Skip to content
This repository has been archived by the owner on Jun 5, 2023. It is now read-only.

Commit

Permalink
fix: Position tooltip on the chart's line
Browse files Browse the repository at this point in the history
  • Loading branch information
diondiondion committed Aug 20, 2019
1 parent 63780e6 commit 6ae19be
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/charts/SimpleChart/ChartTooltips.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const ReadoutListItem = styled.li`

const Cursor = styled.span`
display: block;
height: 100%;
height: ${p => (p.yValue ? p.yValue * 100 : 100)}%;
width: 1px;
background-color: ${p => alpha(p.theme.shade, p.theme.lineStrength)};
`;
Expand Down Expand Up @@ -91,6 +91,8 @@ function ChartTooltips({

if (!data || !data.length) return null;

const maxValue = Math.max.apply(null, data);

return (
<ReadoutList>
{data.map((value, index) => {
Expand All @@ -105,6 +107,7 @@ function ChartTooltips({
<PopOver
isOpen={hoveredPoint === index}
placement="top"
distance={8}
content={readOut}
renderer={tooltipRenderer}
>
Expand All @@ -114,6 +117,7 @@ function ChartTooltips({
<Cursor
ref={popover.ref}
aria-hidden="true"
yValue={value / maxValue}
/>
</Fragment>
)}
Expand Down

0 comments on commit 6ae19be

Please sign in to comment.