-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix NaN positions for shapes when dragging them. #7470
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
Open
my-tien
wants to merge
5
commits into
plotly:master
Choose a base branch
from
my-tien:fix-edit-shapes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
abe1cc6
Fix NaN positions for shapes when dragging them.
my-tien 9cd5262
- Remove r2c call. Unnecessary, since category references seem to hav…
my-tien 2f2c4a0
Fix formatting for category string
my-tien 13e3cc1
WIP draw_newshape_test
my-tien c996699
Use .charAt(0) === 'x'/'y' to test for xref/yref pointing to an axis.
my-tien File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1426,6 +1426,43 @@ describe('Activate and edit editable shapes', function() { | |
|
||
.then(done, done.fail); | ||
}); | ||
|
||
it('should be possible to drag shapes referencing non-categorical axes', function(done) { | ||
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. If you change npm run test-jasmine draw_newshape |
||
Plotly.newPlot(gd, { | ||
data: [ | ||
{ | ||
x: ["2015-02-01", "2015-02-02", "2015-02-03"], | ||
y: [14, 17, 8], | ||
mode: "line", | ||
}, | ||
], | ||
layout: { | ||
archmoj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
xaxis: { title: { text: "Date" }, type: "date" }, | ||
dragmode: "drawline", | ||
shapes: [ | ||
{ | ||
type: "rect", | ||
xref: "x", | ||
yref: "paper", | ||
x0: "2015-02-02", | ||
y0: 0, | ||
x1: "2015-02-08", | ||
y1: 1, | ||
opacity: 0.2, | ||
editable: true, | ||
}, | ||
], | ||
}, | ||
}) | ||
.then(function() { drag([[257.64, 370], [250, 300]]); }) // move lower left corner up and left | ||
.then(function () { | ||
var shapes = gd._fullLayout.shapes; | ||
var obj = shapes[0]._input; | ||
print(obj); | ||
assertPos(obj.path, 'M250,300H1019V100H257.64Z'); | ||
archmoj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}) | ||
.then(done, done.fail); | ||
}); | ||
}); | ||
}); | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Thanks @my-tien for the fix.
Two questions:
path
?plotly.js/test/jasmine/tests/draw_newshape_test.js
Line 1433 in 79559af
Uh 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.
I'll have a look at path and adding a test. However, my fix is not yet correct. Among other things, afterEdit can be a shape with xref and yref paper apparently even if the ref was something different before. I'll have to see, how I can correctly translate the shift variables to paper as well. I will probably push some changes later today.
UPDATE: This is a separate bug. As mentioned further below, I'll open an issue for it later.
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.
For the path case the change is not necessary, because the shift properties are ignored if path is used instead of x0, x1, y0, y1.
Regarding the test, I added one with a test case that previously failed and now works. However, I am not sure how to test this locally because for some reason on my machine several Jasmine tests always fail. Could you please look at it on your end and make the necessary adjustments?