Skip to content
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

add attributes xshift, yshift to annotations #1590

Merged
merged 1 commit into from
Apr 12, 2017
Merged

Conversation

alexcjohnson
Copy link
Collaborator

Adds two new attributes to annotations, xshift and yshift.

Originally I thought I'd accomplish this by just allowing standoff to be a 2-vector, but I decided against this for a few reasons:

  • matches the rest of our attributes in annotations better, like ax and ay
  • it should have an effect even when there's no arrow
  • related to ^^, I felt like this one, particularly for the use cases I expect like pointing a new annotation at an existing one or at a colorbar or something, would be more natural if it moved both ends of the arrow (and the text box) so it works fairly differently from standoff
  • didn't want to invite nestedProperty results in modal Plotly.restyle #1580 again

@etpinard etpinard added this to the v1.26.0 milestone Apr 12, 2017
@@ -524,21 +532,17 @@ function drawOne(gd, index) {

update[annbase + '.x'] = xa ?
xa.p2r(xa.r2p(options.x) + dx) :
((headX + dx - gs.l) / gs.w);
(options.x + (dx / gs.w));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice simplification 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

motivated by the fact that the old way would have needed to explicitly account for shift - notice though in the showarrow: false case I did need to just include shift, due to the auto-anchor business...

@@ -1127,7 +1132,7 @@ describe('annotation effects', function() {
}

makePlot([
{x: 50, y: 50, text: 'hi', width: 50, ax: 0, ay: -40},
{x: 50, y: 50, text: 'hi', width: 50, ax: 0, ay: -40, xshift: -50, yshift: 50},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is editable: true tested with xshift / yshift? It's a little hard to tell from the diff.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, all the other tests above this in describe('annotation effects', to which I added xshift: 5, yshift: 5, are editable and failed before I fixed dragging with shifts.

[0.97, 2.03], [0.97, 2.03],
['2000-10-01 08:23:18.0583', '2001-06-05 19:20:23.301'], [-0.245, 4.245],
[0.9, 2.1], [0.86, 2.14]
[0.91, 2.09], [0.91, 2.09],
Copy link
Contributor

@etpinard etpinard Apr 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so these values changed because the annotations-autorange mock changed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so these values changed because the annotations-autorange mock changed?

correct. I guess that's a hazard of reusing mocks for both images and jasmine tests...

@etpinard
Copy link
Contributor

All right. Nicely done 💃

@alexcjohnson alexcjohnson merged commit fbcc03a into master Apr 12, 2017
@alexcjohnson alexcjohnson deleted the note-shift branch April 12, 2017 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants