8000 Multiple scatter plot fixes by etpinard · Pull Request #956 · plotly/plotly.js · GitHub
[go: up one dir, main page]

Skip to content

Multiple scatter plot fixes #956

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 6 commits into from
Sep 21, 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
test: add cases for point translation on range relayout
  • Loading branch information
etpinard committed Sep 20, 2016
commit d81076581234316af9645ed536a28381fd8e6e0d
53 changes: 53 additions & 0 deletions test/jasmine/tests/cartesian_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,59 @@ describe('relayout', function() {
done();
});
});

});

describe('axis ranges', function() {
var gd;

beforeEach(function() {
gd = createGraphDiv();
});

afterEach(destroyGraphDiv);

it('should translate points and text element', function(done) {
var mockData = [{
x: [1],
y: [1],
text: ['A'],
mode: 'markers+text'
}];

function assertPointTranslate(pointT, textT) {
var TOLERANCE = 10;

var gd3 = d3.select(gd),
points = gd3.selectAll('g.scatter.trace path.point'),
texts = gd3.selectAll('g.scatter.trace text');

expect(points.size()).toEqual(1);
expect(texts.size()).toEqual(1);

expect(points.attr('x')).toBe(null);
expect(points.attr('y')).toBe(null);
expect(texts.attr('transform')).toBe(null);

var translate = Lib.getTranslate(points);
expect(Math.abs(translate.x - pointT[0])).toBeLessThan(TOLERANCE);
expect(Math.abs(translate.y - pointT[1])).toBeLessThan(TOLERANCE);

expect(Math.abs(texts.attr('x') - textT[0])).toBeLessThan(TOLERANCE);
expect(Math.abs(texts.attr('y') - textT[1])).toBeLessThan(TOLERANCE);
}

Plotly.plot(gd, mockData).then(function() {
assertPointTranslate([270, 135], [270, 135]);

return Plotly.relayout(gd, 'xaxis.range', [2, 3]);
})
.then(function() {
assertPointTranslate([0, 540], [-540, 135]);
})
.then(done);
});

});

});
0