Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexplainable tooltip offset in XY-Chart when orientation of YAxis is set to left. #137

Closed
jhofstede opened this issue Sep 24, 2018 · 2 comments · Fixed by #140
Closed
Assignees
Labels

Comments

@jhofstede
Copy link

It might be a bug, but I've been wrapping my head around this for a couple of hours now. Once I put the Y-Axis on the left side, the tooltip is no longer in sync with the position of the mouse.

image

It seems to be caused by the orientation-prop of the YAxis.

    <YAxis label="GPTW RPM" orientation='left' numTicks={8}/>

Full

  <XYChart
      margin= {{top: 10, left: 60, right: 10, bottom: 40 }}
      width={props.parentWidth}
      height={props.height}
      showYGrid
      showXGrid
      xScale={{ type: 'time' }}
      yScale={{ type: 'linear' }}
      renderTooltip={({ event, datum, data, color }) => {
       const monthNames = ["January", "February", "March", "April", "May", "June",
        "July", "August", "September", "October", "November", "December"
       ];
       const month = monthNames[datum.x.getMonth()];
       return (
         <div>
           <strong style={{ color }}>{datum.label}</strong>
           <div><strong>Month: </strong>{month} {datum.x.getYear() + 1900}</div>
         </div>
       );
      }}
      snapTooltipToDataX
    >
    <HorizontalReferenceLine
      reference={1}
      stroke='#000000'
      strokeWidth={1}
      strokeDasharray='3 3'
      dashType='dotted'
      strokeLinecap='butt'
      label="House average"
      labelProps={{ width: 100, verticalAnchor: 'middle', dx: 5, dy: -10}}
    />

    <XAxis label="Time" />
    <YAxis label="GPTW RPM" orientation='left' numTicks={8}/>
     <CrossHair showHorizontalLine={false} fullHeight stroke="pink" />
  </XYChart>

Any help is appreciated!

@williaster
Copy link
Owner

hey @jhofstede thanks for checking out @data-ui. We recently discovered this bug as well when orientation="left". It should be a pretty straightforward fix, I think the computation just doesn't take into account the left margin properly.

I'll try to get to it in the next day or so 👍

@williaster williaster added the bug label Sep 24, 2018
@williaster williaster self-assigned this Sep 24, 2018
@jhofstede
Copy link
Author

@williaster many thanks for your work on @data-ui and your quick reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants