-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Hoverformat bug with showTickLabels #267
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
Changes from 6 commits
cdeb3fe
3cd0487
34c6fef
d8e09ee
bc329a9
d16ec29
9b5663a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,29 +29,27 @@ module.exports = function handleTickDefaults(containerIn, containerOut, coerce, | |
delete containerOut.tickcolor; | ||
} | ||
|
||
var showAttrDflt = getShowAttrDflt(containerIn); | ||
|
||
var tickPrefix = coerce('tickprefix'); | ||
if(tickPrefix) coerce('showtickprefix', showAttrDflt); | ||
|
||
var tickSuffix = coerce('ticksuffix'); | ||
if(tickSuffix) coerce('showticksuffix', showAttrDflt); | ||
|
||
var showTickLabels = coerce('showticklabels'); | ||
if(showTickLabels) { | ||
Lib.coerceFont(coerce, 'tickfont', options.font || {}); | ||
coerce('tickangle'); | ||
|
||
var showAttrDflt = getShowAttrDflt(containerIn); | ||
|
||
if(axType !== 'category') { | ||
var tickFormat = coerce('tickformat'); | ||
if(!options.noHover) coerce('hoverformat'); | ||
|
||
if(!tickFormat && axType !== 'date') { | ||
coerce('showexponent', showAttrDflt); | ||
coerce('exponentformat'); | ||
} | ||
var tickFormat = coerce('tickformat'); | ||
if(!tickFormat && axType !== 'date') { | ||
coerce('showexponent', showAttrDflt); | ||
coerce('exponentformat'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the exponent format affect hover labels? Or does it only affect the tick labels? If the latter, we should bring it back into the |
||
} | ||
|
||
var tickPrefix = coerce('tickprefix'); | ||
if(tickPrefix) coerce('showtickprefix', showAttrDflt); | ||
|
||
var tickSuffix = coerce('ticksuffix'); | ||
if(tickSuffix) coerce('showticksuffix', showAttrDflt); | ||
} | ||
|
||
if(axType !== 'category' && !options.noHover) coerce('hoverformat'); | ||
}; | ||
|
||
/* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ var Lib = require('@src/lib'); | |
|
||
var createGraphDiv = require('../assets/create_graph_div'); | ||
var destroyGraphDiv = require('../assets/destroy_graph_div'); | ||
var mouseEvent = require('../assets/mouse_event'); | ||
|
||
describe('hover info', function() { | ||
'use strict'; | ||
|
@@ -242,4 +243,42 @@ describe('hover info', function() { | |
expect(d3.selectAll('g.hovertext').select('text').selectAll('tspan').size()).toEqual(2); | ||
}); | ||
}); | ||
|
||
describe('hoverformat', function() { | ||
|
||
var data = [{ | ||
x: [1, 2, 3], | ||
y: [0.12345, 0.23456, 0.34567] | ||
}], | ||
layout = { | ||
yaxis: { showticklabels: true, hoverformat: ',.2r' }, | ||
width: 600, | ||
height: 400 | ||
}; | ||
|
||
beforeEach(function() { | ||
this. gd = createGraphDiv(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Haha. Look at that. A jasmine There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😸 I'm ok with |
||
}); | ||
|
||
it('should display the correct format when ticklabels true', function() { | ||
Plotly.plot(this.gd, data, layout); | ||
mouseEvent('mousemove', 310, 220); | ||
|
||
var hovers = d3.selectAll('g.hovertext'); | ||
|
||
expect(hovers.size()).toEqual(1); | ||
expect(hovers.select('text')[0][0].textContent).toEqual('0.23'); | ||
}); | ||
|
||
it('should display the correct format when ticklabels false', function() { | ||
layout.yaxis.showticklabels = false; | ||
Plotly.plot(this.gd, data, layout); | ||
mouseEvent('mousemove', 310, 220); | ||
|
||
var hovers = d3.selectAll('g.hovertext'); | ||
|
||
expect(hovers.size()).toEqual(1); | ||
expect(hovers.select('text')[0][0].textContent).toEqual('0.23'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dope tests. |
||
}); | ||
}); | ||
}); |
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.
why is this block not wrapped inside
axType !== 'category'
?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.
Whoa good catch. When I pulled out
coerce('hoverformat')
I completely goofed on that. I'll add it into theif
condition right now.