Skip to content

Commit

Permalink
image: 🔪 scalenachor: null and improve style
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinerg committed Oct 28, 2019
1 parent 8184a8d commit 9d04eda
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 22 deletions.
8 changes: 6 additions & 2 deletions src/plots/cartesian/constraints.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var FROM_BL = require('../../constants/alignment').FROM_BL;
exports.handleConstraintDefaults = function(containerIn, containerOut, coerce, opts) {
var allAxisIds = opts.allAxisIds;
var layoutOut = opts.layoutOut;
var scaleanchorDflt = opts.scaleanchorDflt;
var constraintGroups = layoutOut._axisConstraintGroups;
var matchGroups = layoutOut._axisMatchGroups;
var axId = containerOut._id;
Expand Down Expand Up @@ -55,14 +56,17 @@ exports.handleConstraintDefaults = function(containerIn, containerOut, coerce, o
// 'matches' wins over 'scaleanchor' (for now)
var scaleanchor, scaleOpts;

if(!matches && (containerIn.scaleanchor || opts.scaleanchorDflt) && !(containerOut.fixedrange && constrain !== 'domain')) {
if(!matches &&
!(containerOut.fixedrange && constrain !== 'domain') &&
(containerIn.scaleanchor || scaleanchorDflt)
) {
scaleOpts = getConstraintOpts(constraintGroups, thisID, allAxisIds, layoutOut, constrain);
scaleanchor = Lib.coerce(containerIn, containerOut, {
scaleanchor: {
valType: 'enumerated',
values: scaleOpts.linkableAxes || []
}
}, 'scaleanchor', opts.scaleanchorDflt);
}, 'scaleanchor', scaleanchorDflt);
}

if(matches) {
Expand Down
6 changes: 4 additions & 2 deletions src/plots/cartesian/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,10 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
}
yaMustNotScaleanchor[yaName] = true;
} else if(trace.type === 'image') {
if(yaName) yaMayReverse[yaName] = true;
if(yaName) yaMayScaleanchor[yaName] = true;
if(yaName) {
yaMayReverse[yaName] = true;
yaMayScaleanchor[yaName] = true;
}
} else {
if(yaName) {
yaMustDisplay[yaName] = true;
Expand Down
Binary file modified test/image/baselines/image_axis_type.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/image_colormodel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/image_opacity.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/image/baselines/image_zmin_zmax.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions test/image/mocks/image_axis_type.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"width": 400, "height": 600, "title": {"text": "Image on categorical and log axes"},
"grid": {"rows": 2, "columns": 1, "pattern": "independent"},
"xaxis2": {"type": "log"},
"yaxis": {"scaleanchor": null},
"yaxis2": {"type": "log", "scaleanchor": null}
"yaxis2": {"type": "log"}
}
}
8 changes: 4 additions & 4 deletions test/image/mocks/image_colormodel.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
"data": [{
"type": "image",
"colormodel": "rgb",
"dy": 10,
"hoverinfo": "all",
"dy": 1,
"dx": 0.5,
"z": [[[255, 0, 0], [0, 255, 0], [0, 0, 255]]]
}, {
"type": "image",
"colormodel": "hsl",
"hoverinfo": "all",
"z": [
[[0, 33, 50], [0, 66, 50], [0, 100, 50]],
[[90, 33, 50], [90, 66, 50], [90, 100, 50]],
Expand All @@ -18,9 +20,7 @@
"yaxis": "y2"
}],
"layout": {
"grid": {"rows": 2, "columns": 1, "pattern": "independent"},
"yaxis": {"scaleanchor": null},
"yaxis2": {"scaleanchor": null},
"grid": {"rows": 1, "columns": 2, "pattern": "independent"},
"width": 600,
"height": 400
}
Expand Down
1 change: 0 additions & 1 deletion test/image/mocks/image_opacity.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"z": [[[255, 0, 0], [0, 255, 0], [0, 0, 255]]]
}],
"layout": {
"yaxis": {"scaleanchor": null},
"width": 400, "height": 400,
"title": {
"text": "image with opacity 0.1"
Expand Down
1 change: 0 additions & 1 deletion test/image/mocks/image_with_gaps.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"zmax": [1, 1, 1]
}],
"layout": {
"yaxis": {"scaleanchor": null},
"width": 400, "height": 400, "title": {"text": "Image with missing pixels"}
}
}
8 changes: 0 additions & 8 deletions test/image/mocks/image_zmin_zmax.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,6 @@
"layout": {
"width": 400,
"height": 800,
"yaxis": {"scaleanchor": null},
"yaxis2": {"scaleanchor": null},
"yaxis3": {"scaleanchor": null},
"yaxis4": {"scaleanchor": null},
"yaxis5": {"scaleanchor": null},
"yaxis6": {"scaleanchor": null},
"yaxis7": {"scaleanchor": null},
"yaxis8": {"scaleanchor": null},
"grid": {
"rows": 4,
"columns": 2,
Expand Down
4 changes: 2 additions & 2 deletions test/jasmine/tests/image_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,10 @@ describe('image hover:', function() {
zmax: [1, 1, 1],
text: [['A', 'B', 'C'], ['D', 'E', 'F']],
hovertemplate: '%{text}<extra></extra>'
}], layout: {width: 400, height: 400, yaxis: {scaleanchor: null}}};
}], layout: {width: 400, height: 400}};

Plotly.newPlot(gd, mockCopy)
.then(function() {_hover(140, 200);})
.then(function() {_hover(140, 180);})
.then(function() {
assertHoverLabelContent({
nums: 'E',
Expand Down

0 comments on commit 9d04eda

Please sign in to comment.