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
add distanceX and distanceY to tooltip #250
Conversation
When you guys get the chance can you take a look at this and #251? The only thing I am still debating about is distanceX, right now a positive number will send the tooltip left while a negative number will send the tooltip right. Not sure if that is intuitive, so might be best to switch it. |
@senluchen2015 i haven't looked at the code or demo, so take with a grain of salt -- but i vote for distanceX positive values moving right / negative values moving left like a standard number line. |
Code looks good to me, but I'd agree with Molly that positive values should move the tooltip right (and vice versa). Also, I'm not able to reposition the tooltip in the jsfiddle example, but I might be doing something wrong. |
Flipped the direction so that positive number means towards right on distanceX. Positive distanceY is still going up. |
ff28586
to
b6b3417
Compare
@@ -38,6 +40,8 @@ | |||
var plotTop = this.options.chart.plotTop; | |||
var plotHeight = this.options.chart.plotHeight; | |||
var distance = this.options.tooltip.distance; | |||
var distanceX = this.options.tooltip.distanceX ? this.options.tooltip.distanceX : distance; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wouldn't this break if distanceX is explicitly set to 0?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this will fix
var distanceX = this.options.tooltip.distanceX !== undefined ? this.options.tooltip.distanceX : distance;
var distanceY = this.options.tooltip.distanceY !== undefined ? this.options.tooltip.distanceY : distance;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd change the check to !=null
(which'll catch both null and undefined)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could also use !=undefined
(could be more implicit?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*as long as we never overwrite undefined (same goes for null though)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@parikhshiv,
At one time, you could overwrite undefined
, but it hasn't been possible since ES5. Besides, the build process (uglify) replaces undefined
with void 0
.
Updated tooltip distance to take object or number
|
Demo:
http://jsfiddle.net/ucstdgsa/