Skip to content

Commit 9cd5262

Browse files
committed
- Remove r2c call. Unnecessary, since category references seem to have been converted to numerical before this point already.
- Don't use plotinfo to retrieve the axis, somehow it doesn't always contain the correct axis information. Use `axis_ids.getFromId` instead. - Fix formatting
1 parent abe1cc6 commit 9cd5262

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/components/shapes/draw_newshape/newshapes.js

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
var axis_ids = require('../../../plots/cartesian/axis_ids');
4+
35
var dragHelpers = require('../../dragelement/helpers');
46
var drawMode = dragHelpers.drawMode;
57
var openMode = dragHelpers.openMode;
@@ -67,7 +69,6 @@ function newShapes(outlines, dragOptions) {
6769
clearOutline(gd);
6870

6971
var editHelpers = dragOptions.editHelpers;
70-
var plotinfo = dragOptions.plotinfo;
7172
var modifyItem = (editHelpers || {}).modifyItem;
7273

7374
var allShapes = [];
@@ -85,17 +86,19 @@ function newShapes(outlines, dragOptions) {
8586
case 'line':
8687
case 'rect':
8788
case 'circle':
88-
if (beforeEdit.xref.includes("x") && plotinfo.xaxis.type.includes("category")) {
89-
plotinfo.xaxis.r2c(afterEdit.x0)
90-
modifyItem('x0', plotinfo.xaxis.r2c(afterEdit.x0) - (beforeEdit.x0shift || 0));
91-
modifyItem('x1', plotinfo.xaxis.r2c(afterEdit.x1) - (beforeEdit.x1shift || 0));
89+
90+
var xaxis = axis_ids.getFromId(gd, beforeEdit.xref);
91+
if (beforeEdit.xref.includes('x') && xaxis.type.includes("category")) {
92+
modifyItem('x0', afterEdit.x0 - (beforeEdit.x0shift || 0));
93+
modifyItem('x1', afterEdit.x1 - (beforeEdit.x1shift || 0));
9294
} else {
9395
modifyItem('x0', afterEdit.x0);
9496
modifyItem('x1', afterEdit.x1);
9597
}
96-
if (beforeEdit.yref.includes("y") && plotinfo.yaxis.type.includes("category")) {
97-
modifyItem('y0', plotinfo.xaxis.r2c(afterEdit.y0) - (beforeEdit.y0shift || 0));
98-
modifyItem('y1', plotinfo.xaxis.r2c(afterEdit.y1) - (beforeEdit.y1shift || 0));
98+
var yaxis = axis_ids.getFromId(gd, beforeEdit.yref);
99+
if (beforeEdit.yref.includes('y') && yaxis.type.includes("category")) {
100+
modifyItem('y0', afterEdit.y0 - (beforeEdit.y0shift || 0));
101+
modifyItem('y1', afterEdit.y1 - (beforeEdit.y1shift || 0));
99102
} else {
100103
modifyItem('y0', afterEdit.y0);
101104
modifyItem('y1', afterEdit.y1);

0 commit comments

Comments
 (0)