Skip to content

Commit

Permalink
fix panning on text chart with invalid array values
Browse files Browse the repository at this point in the history
  • Loading branch information
etpinard committed Oct 4, 2017
1 parent 7f2604a commit 6a44a9a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/components/drawing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,9 @@ drawing.setTextPointsScale = function(selection, xScale, yScale) {
var transforms;
var el = d3.select(this);
var text = el.select('text');

if(!text.node()) return;

var x = parseFloat(text.attr('x') || 0);
var y = parseFloat(text.attr('y') || 0);

Expand Down
5 changes: 5 additions & 0 deletions test/jasmine/tests/drawing_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,11 @@ describe('Drawing', function() {
Drawing.setTextPointsScale(g, 4, 5);
expect(g.attr('transform')).toEqual('translate(8,9) scale(4,5) translate(-8,-9) translate(1, 2)');
});

it('should not break when <text> is not present', function() {
text.remove();
expect(function() { Drawing.setTextPointsScale(g, 4, 5); }).not.toThrow();
});
});

describe('bBox', function() {
Expand Down

0 comments on commit 6a44a9a

Please sign in to comment.