Skip to content

Nested <svg> removal #415

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

Merged
merged 7 commits into from
Apr 13, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Switch annotation svg -> g
  • Loading branch information
mdtusz committed Apr 8, 2016
commit ab0b6bfff56e64c25eaa01d997a9c8786f15856a
12 changes: 6 additions & 6 deletions src/components/annotations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ annotations.draw = function(gd, index, opt, value) {
.classed('annotation-text-g', true)
.attr('data-index', String(index));

var ann = anng.append('svg')
.call(Plotly.Drawing.setPosition, 0, 0);
var ann = anng.append('g')
.attr('transform', 'translate(0,0)');
Copy link
Contributor

Choose a reason for hiding this comment

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

is this necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep - the call to setPosition only sets x and y attributes - for <g>'s, we need to position using transform.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose we could add a drawing.setTranslate method though too. Thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh. I meant, 'transform', 'translate(0,0)' as no effects, right?

By the why, I like the idea of having a drawing.setTranslate method. No need to do that right now though.


var borderwidth = options.borderwidth,
borderpad = options.borderpad,
Expand Down Expand Up @@ -489,10 +489,10 @@ annotations.draw = function(gd, index, opt, value) {

annbg.call(Plotly.Drawing.setRect, borderwidth / 2, borderwidth / 2,
outerwidth-borderwidth, outerheight - borderwidth);
ann.call(Plotly.Drawing.setRect,
Math.round(annPosPx.x - outerwidth / 2),
Math.round(annPosPx.y - outerheight / 2),
outerwidth, outerheight);

var annX = Math.round(annPosPx.x - outerwidth / 2),
annY = Math.round(annPosPx.y - outerheight / 2);
ann.attr('transform', 'translate(' + annX + ', ' + annY + ')');

var annbase = 'annotations['+index+']';

Expand Down