-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Make surface contour highlights on hover toggleable #459
Changes from all commits
39c8ece
173f13e
07f60e3
68bb949
78d8a49
d16199c
ab2b9e8
5f7293d
3042c13
07f318a
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 |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
|
||
|
||
'use strict'; | ||
|
||
var colorMix = require('tinycolor2').mix; | ||
|
||
var Lib = require('../../../lib'); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
|
||
'use strict'; | ||
|
||
var Color = require('../../components/color'); | ||
var colorscaleAttrs = require('../../components/colorscale/attributes'); | ||
var extendFlat = require('../../lib/extend').extendFlat; | ||
|
||
|
@@ -19,8 +20,12 @@ function makeContourProjAttr(axLetter) { | |
role: 'info', | ||
dflt: false, | ||
description: [ | ||
'Sets whether or not the dynamic contours are projected', | ||
'along the', axLetter, 'axis.' | ||
'Determines whether or not these contour lines are projected', | ||
'on the', axLetter, 'axis walls.', | ||
'If `highlight` is set to *true* (the default), the projected', | ||
'lines are shown on hover.', | ||
'If `show` is set to *true*, the projected lines are shown', | ||
'in permanence.' | ||
].join(' ') | ||
}; | ||
} | ||
|
@@ -32,8 +37,8 @@ function makeContourAttr(axLetter) { | |
role: 'info', | ||
dflt: false, | ||
description: [ | ||
'Sets whether or not dynamic contours are shown along the', | ||
axLetter, 'axis' | ||
'Determines whether or not contour lines about the', axLetter, | ||
'dimension are drawn.' | ||
].join(' ') | ||
}, | ||
project: { | ||
|
@@ -44,36 +49,49 @@ function makeContourAttr(axLetter) { | |
color: { | ||
valType: 'color', | ||
role: 'style', | ||
dflt: '#000' | ||
dflt: Color.defaultLine, | ||
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. This required updating on baseline image ⬇️. |
||
description: 'Sets the color of the contour lines.' | ||
}, | ||
usecolormap: { | ||
valType: 'boolean', | ||
role: 'info', | ||
dflt: false | ||
dflt: false, | ||
description: [ | ||
'An alternate to *color*.', | ||
'Determines whether or not the contour lines are colored using', | ||
'the trace *colorscale*.' | ||
].join(' ') | ||
}, | ||
width: { | ||
valType: 'number', | ||
role: 'style', | ||
min: 1, | ||
max: 16, | ||
dflt: 2 | ||
dflt: 2, | ||
description: 'Sets the width of the contour lines.' | ||
}, | ||
highlight: { | ||
valType: 'boolean', | ||
role: 'info', | ||
dflt: false | ||
dflt: true, | ||
description: [ | ||
'Determines whether or not contour lines about the', axLetter, | ||
'dimension are highlighted on hover.' | ||
].join(' ') | ||
}, | ||
highlightColor: { | ||
highlightcolor: { | ||
valType: 'color', | ||
role: 'style', | ||
dflt: '#000' | ||
dflt: Color.defaultLine, | ||
description: 'Sets the color of the highlighted contour lines.' | ||
}, | ||
highlightWidth: { | ||
highlightwidth: { | ||
valType: 'number', | ||
role: 'style', | ||
min: 1, | ||
max: 16, | ||
dflt: 2 | ||
dflt: 2, | ||
description: 'Sets the width of the highlighted contour lines.' | ||
} | ||
}; | ||
} | ||
|
@@ -102,6 +120,7 @@ module.exports = { | |
'used for setting a color scale independent of `z`.' | ||
].join(' ') | ||
}, | ||
|
||
cauto: colorscaleAttrs.zauto, | ||
cmin: colorscaleAttrs.zmin, | ||
cmax: colorscaleAttrs.zmax, | ||
|
@@ -110,6 +129,7 @@ module.exports = { | |
{dflt: false}), | ||
reversescale: colorscaleAttrs.reversescale, | ||
showscale: colorscaleAttrs.showscale, | ||
|
||
contours: { | ||
x: makeContourAttr('x'), | ||
y: makeContourAttr('y'), | ||
|
@@ -118,8 +138,15 @@ module.exports = { | |
hidesurface: { | ||
valType: 'boolean', | ||
role: 'info', | ||
dflt: false | ||
dflt: false, | ||
description: [ | ||
'Determines whether or not a surface is drawn.', | ||
'For example, set `hidesurface` to *false*', | ||
'`contours.x.show` to *true* and', | ||
'`contours.y.show` to *true* to draw a wire frame plot.' | ||
].join(' ') | ||
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. 💎 description--thanks for adding that! |
||
}, | ||
|
||
lighting: { | ||
ambient: { | ||
valType: 'number', | ||
|
@@ -163,7 +190,8 @@ module.exports = { | |
role: 'style', | ||
min: 0, | ||
max: 1, | ||
dflt: 1 | ||
dflt: 1, | ||
description: 'Sets the opacity of the surface.' | ||
}, | ||
|
||
_nestedModules: { // nested module coupling | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -689,5 +689,71 @@ describe('Test plot api', function() { | |
Plotly.plot(gd, data); | ||
expect(gd.data[0].marker.colorscale).toBe('YlOrRd'); | ||
}); | ||
|
||
it('should rename \'highlightColor\' to \'highlightcolor\')', function() { | ||
var data = [{ | ||
type: 'surface', | ||
contours: { | ||
x: { highlightColor: 'red' }, | ||
y: { highlightcolor: 'blue' } | ||
} | ||
}, { | ||
type: 'surface' | ||
}, { | ||
type: 'surface', | ||
contours: false | ||
}, { | ||
type: 'surface', | ||
contours: { | ||
stuff: {}, | ||
x: false, | ||
y: [] | ||
} | ||
}]; | ||
|
||
spyOn(Plots.subplotsRegistry.gl3d, 'plot'); | ||
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. |
||
|
||
Plotly.plot(gd, data); | ||
|
||
expect(Plots.subplotsRegistry.gl3d.plot).toHaveBeenCalled(); | ||
|
||
var contours = gd.data[0].contours; | ||
|
||
expect(contours.x.highlightColor).toBeUndefined(); | ||
expect(contours.x.highlightcolor).toEqual('red'); | ||
expect(contours.y.highlightcolor).toEqual('blue'); | ||
expect(contours.z).toBeUndefined(); | ||
|
||
expect(gd.data[1].contours).toBeUndefined(); | ||
expect(gd.data[2].contours).toBe(false); | ||
expect(gd.data[3].contours).toEqual({ stuff: {}, x: false, y: [] }); | ||
}); | ||
|
||
it('should rename \'highlightWidth\' to \'highlightwidth\')', function() { | ||
var data = [{ | ||
type: 'surface', | ||
contours: { | ||
z: { highlightwidth: 'red' }, | ||
y: { highlightWidth: 'blue' } | ||
} | ||
}, { | ||
type: 'surface' | ||
}]; | ||
|
||
spyOn(Plots.subplotsRegistry.gl3d, 'plot'); | ||
|
||
Plotly.plot(gd, data); | ||
|
||
expect(Plots.subplotsRegistry.gl3d.plot).toHaveBeenCalled(); | ||
|
||
var contours = gd.data[0].contours; | ||
|
||
expect(contours.x).toBeUndefined(); | ||
expect(contours.y.highlightwidth).toEqual('blue'); | ||
expect(contours.z.highlightWidth).toBeUndefined(); | ||
expect(contours.z.highlightwidth).toEqual('red'); | ||
|
||
expect(gd.data[1].contours).toBeUndefined(); | ||
}); | ||
}); | ||
}); |
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.
@cldougl (or someone else from the doc team) could you review ⬇️ ?
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.
Clear to me!