-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Negate axis offset and then turn it into a string #2339
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 all commits
4f75015
fa832aa
ae02676
bac33ab
fde97d7
93c5a88
16b01f0
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 |
---|---|---|
|
@@ -82,10 +82,13 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { | |
var hasTernary = fullLayout._has('ternary'); | ||
var hasMapbox = fullLayout._has('mapbox'); | ||
var hasPolar = fullLayout._has('polar'); | ||
var allAxesFixed = areAllAxesFixed(fullLayout); | ||
|
||
var groups = []; | ||
|
||
function addGroup(newGroup) { | ||
if(!newGroup.length) return; | ||
|
||
var out = []; | ||
|
||
for(var i = 0; i < newGroup.length; i++) { | ||
|
@@ -100,55 +103,71 @@ function getButtonGroups(gd, buttonsToRemove, buttonsToAdd) { | |
// buttons common to all plot types | ||
addGroup(['toImage', 'sendDataToCloud']); | ||
|
||
// graphs with more than one plot types get 'union buttons' | ||
// which reset the view or toggle hover labels across all subplots. | ||
if((hasCartesian || hasGL2D || hasPie || hasTernary) + hasGeo + hasGL3D > 1) { | ||
addGroup(['resetViews', 'toggleHover']); | ||
return appendButtonsToGroups(groups, buttonsToAdd); | ||
} | ||
var zoomGroup = []; | ||
var hoverGroup = []; | ||
var resetGroup = []; | ||
var dragModeGroup = []; | ||
|
||
if(hasGL3D) { | ||
addGroup(['zoom3d', 'pan3d', 'orbitRotation', 'tableRotation']); | ||
addGroup(['resetCameraDefault3d', 'resetCameraLastSave3d']); | ||
addGroup(['hoverClosest3d']); | ||
if((hasCartesian || hasGL2D || hasPie || hasTernary) + hasGeo + hasGL3D + hasMapbox + hasPolar > 1) { | ||
// graphs with more than one plot types get 'union buttons' | ||
// which reset the view or toggle hover labels across all subplots. | ||
hoverGroup = ['toggleHover']; | ||
resetGroup = ['resetViews']; | ||
} | ||
else if(hasGeo) { | ||
zoomGroup = ['zoomInGeo', 'zoomOutGeo']; | ||
hoverGroup = ['hoverClosestGeo']; | ||
resetGroup = ['resetGeo']; | ||
} | ||
else if(hasGL3D) { | ||
hoverGroup = ['hoverClosest3d']; | ||
resetGroup = ['resetCameraDefault3d', 'resetCameraLastSave3d']; | ||
} | ||
else if(hasMapbox) { | ||
hoverGroup = ['toggleHover']; | ||
resetGroup = ['resetViewMapbox']; | ||
} | ||
else if(hasGL2D) { | ||
hoverGroup = ['hoverClosestGl2d']; | ||
} | ||
else if(hasPie) { | ||
hoverGroup = ['hoverClosestPie']; | ||
} | ||
else { // hasPolar, hasTernary | ||
// always show at least one hover icon. | ||
hoverGroup = ['toggleHover']; | ||
} | ||
// if we have cartesian, allow switching between closest and compare | ||
// regardless of what other types are on the plot, since they'll all | ||
// just treat any truthy hovermode as 'closest' | ||
if(hasCartesian) { | ||
hoverGroup = ['toggleSpikelines', 'hoverClosestCartesian', 'hoverCompareCartesian']; | ||
} | ||
|
||
var allAxesFixed = areAllAxesFixed(fullLayout), | ||
dragModeGroup = []; | ||
if((hasCartesian || hasGL2D) && !allAxesFixed) { | ||
zoomGroup = ['zoomIn2d', 'zoomOut2d', 'autoScale2d']; | ||
if(resetGroup[0] !== 'resetViews') resetGroup = ['resetScale2d']; | ||
} | ||
|
||
if(((hasCartesian || hasGL2D) && !allAxesFixed) || hasTernary) { | ||
if(hasGL3D) { | ||
dragModeGroup = ['zoom3d', 'pan3d', 'orbitRotation', 'tableRotation']; | ||
} | ||
else if(((hasCartesian || hasGL2D) && !allAxesFixed) || hasTernary) { | ||
dragModeGroup = ['zoom2d', 'pan2d']; | ||
} | ||
if(hasMapbox || hasGeo) { | ||
else if(hasMapbox || hasGeo) { | ||
dragModeGroup = ['pan2d']; | ||
} | ||
if(hasPolar) { | ||
else if(hasPolar) { | ||
dragModeGroup = ['zoom2d']; | ||
} | ||
if(isSelectable(fullData)) { | ||
dragModeGroup.push('select2d'); | ||
dragModeGroup.push('lasso2d'); | ||
} | ||
if(dragModeGroup.length) addGroup(dragModeGroup); | ||
|
||
if((hasCartesian || hasGL2D) && !allAxesFixed && !hasTernary) { | ||
addGroup(['zoomIn2d', 'zoomOut2d', 'autoScale2d', 'resetScale2d']); | ||
dragModeGroup.push('select2d', 'lasso2d'); | ||
} | ||
|
||
if(hasCartesian && hasPie) { | ||
addGroup(['toggleHover']); | ||
} else if(hasGL2D) { | ||
addGroup(['hoverClosestGl2d']); | ||
} else if(hasCartesian) { | ||
addGroup(['toggleSpikelines', 'hoverClosestCartesian', 'hoverCompareCartesian']); | ||
} else if(hasPie) { | ||
addGroup(['hoverClosestPie']); | ||
} else if(hasMapbox) { | ||
addGroup(['resetViewMapbox', 'toggleHover']); | ||
} else if(hasGeo) { | ||
addGroup(['zoomInGeo', 'zoomOutGeo', 'resetGeo']); | ||
addGroup(['hoverClosestGeo']); | ||
} | ||
addGroup(dragModeGroup); | ||
addGroup(zoomGroup.concat(resetGroup)); | ||
addGroup(hoverGroup); | ||
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. Nice cleanup. Looking good! |
||
|
||
return appendButtonsToGroups(groups, buttonsToAdd); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -328,12 +328,12 @@ proto.adjustLayout = function(ternaryLayout, graphSize) { | |
_this.layers.bgrid.attr('transform', bTransform); | ||
|
||
var aTransform = 'translate(' + (x0 + w / 2) + ',' + y0 + | ||
')rotate(30)translate(0,-' + aaxis._offset + ')'; | ||
')rotate(30)translate(0,' + -aaxis._offset + ')'; | ||
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. When that is, a double Looks like |
||
_this.layers.aaxis.attr('transform', aTransform); | ||
_this.layers.agrid.attr('transform', aTransform); | ||
|
||
var cTransform = 'translate(' + (x0 + w / 2) + ',' + y0 + | ||
')rotate(-30)translate(0,-' + caxis._offset + ')'; | ||
')rotate(-30)translate(0,' + -caxis._offset + ')'; | ||
_this.layers.caxis.attr('transform', cTransform); | ||
_this.layers.cgrid.attr('transform', cTransform); | ||
|
||
|
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.
The second part of #2338 - fixes hover labels for geo and ternary on the
plot_types
mockUh oh!
There was an error while loading. Please reload this page.
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.
Looks good. Not sure what's the best to 🔒 this down?
Maybe just checking that
hovermode: 'x'
behaves the same ashovermode: 'closest'
in a cartesian + geo (or ternary or polar) graph would suffice.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.
good call -> 16b01f0