Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 46e5a0c

Browse filesBrowse files
committed
image: fix coordinate, reverse yaxis by default
1 parent 6d071d6 commit 46e5a0c
Copy full SHA for 46e5a0c

File tree

9 files changed

+14
-9
lines changed
Filter options

9 files changed

+14
-9
lines changed

‎src/plots/cartesian/layout_defaults.js

Copy file name to clipboardExpand all lines: src/plots/cartesian/layout_defaults.js
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,11 @@ module.exports = function supplyLayoutDefaults(layoutIn, layoutOut, fullData) {
8787
if(!traceIs(trace, 'carpet') || (trace.type === 'carpet' && !trace._cheater)) {
8888
if(xaName) xaMustDisplay[xaName] = true;
8989
}
90+
91+
if(trace.type === 'image') {
92+
if(yaName) yaMustForward[yaName] = false;
93+
if(yaName) yaMayBackward[yaName] = true;
94+
}
9095
}
9196

9297
// Two things trigger axis visibility:

‎src/traces/image/calc.js

Copy file name to clipboardExpand all lines: src/traces/image/calc.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module.exports = function calc(gd, trace) {
2222
var w = trace.z[0].length;
2323

2424
trace._extremes[xa._id] = Axes.findExtremes(xa, [x0, x0 + w * trace.dx]);
25-
trace._extremes[ya._id] = Axes.findExtremes(ya, [y0, y0 - h * trace.dy]);
25+
trace._extremes[ya._id] = Axes.findExtremes(ya, [y0, y0 + h * trace.dy]);
2626

2727
var cd0 = {
2828
x0: x0,

‎src/traces/image/hover.js

Copy file name to clipboardExpand all lines: src/traces/image/hover.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ module.exports = function hoverPoints(pointData, xval, yval) {
1919
var ya = pointData.ya;
2020

2121
if(Fx.inbox(xval - cd0.x0, xval - (cd0.x0 + cd0.w * trace.dx), 0) > 0 ||
22-
Fx.inbox(yval - cd0.y0, yval - (cd0.y0 - cd0.h * trace.dy), 0) > 0) {
22+
Fx.inbox(yval - cd0.y0, yval - (cd0.y0 + cd0.h * trace.dy), 0) > 0) {
2323
return;
2424
}
2525

2626
// Find nearest pixel's index and pixel center
2727
var nx = Math.floor((xval - cd0.x0) / trace.dx);
2828
var ny = Math.floor(Math.abs(yval - cd0.y0) / trace.dy);
2929

30-
var py = ya.c2p(cd0.y0 - (ny + 0.5) * trace.dy);
30+
var py = ya.c2p(cd0.y0 + (ny + 0.5) * trace.dy);
3131
return [Lib.extendFlat(pointData, {
3232
index: [ny, nx],
3333
x0: xa.c2p(cd0.x0 + nx * trace.dx),

‎src/traces/image/plot.js

Copy file name to clipboardExpand all lines: src/traces/image/plot.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ module.exports = function(gd, plotinfo, cdimage, imageLayer) {
3131
var left = xa.c2p(x0);
3232
var right = xa.c2p(x0 + w * dx);
3333
var top = ya.c2p(y0);
34-
var bottom = ya.c2p(y0 - h * dy);
34+
var bottom = ya.c2p(y0 + h * dy);
3535

3636
var temp;
3737
if(right < left) {
@@ -69,7 +69,7 @@ module.exports = function(gd, plotinfo, cdimage, imageLayer) {
6969
canvas.height = imageHeight;
7070
var context = canvas.getContext('2d');
7171
var ipx = function(i) {return Lib.constrain(Math.round(xa.c2p(x0 + i * dx) - left), 0, imageWidth);};
72-
var jpx = function(j) {return Lib.constrain(Math.round(ya.c2p(y0 - j * dy) - top), 0, imageHeight);};
72+
var jpx = function(j) {return Lib.constrain(Math.round(ya.c2p(y0 + j * dy) - top), 0, imageHeight);};
7373
// TODO: for performance, when image size is reduced, only loop over pixels of interest
7474
for(var i = 0; i < cd0.w; i++) {
7575
for(var j = 0; j < cd0.h; j++) {
-1.58 KB
Loading

‎test/image/baselines/image_cat.png

Copy file name to clipboard
-277 Bytes
Loading

‎test/image/mocks/image_adventurer.json

Copy file name to clipboardExpand all lines: test/image/mocks/image_adventurer.json
+1-1Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

‎test/image/mocks/image_axis_reverse.json

Copy file name to clipboardExpand all lines: test/image/mocks/image_axis_reverse.json
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
"width": 600, "height": 600,
1414
"margin": {"t": 35, "l": 35, "b": 35, "r": 35},
1515
"xaxis2": {"autorange": "reversed"},
16-
"yaxis3": {"autorange": "reversed"},
17-
"yaxis4": {"autorange": "reversed"},
16+
"yaxis3": {"autorange": true},
17+
"yaxis4": {"autorange": true},
1818
"xaxis4": {"autorange": "reversed"}
1919
}
2020
}

‎test/image/mocks/image_cat.json

Copy file name to clipboardExpand all lines: test/image/mocks/image_cat.json
+1-1Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.