Skip to content

Commit

Permalink
Fix uncaught exception when a legend is hidden (T854736) (#11737)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-simionov committed Jan 28, 2020
1 parent b56479c commit 06d975e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion js/viz/components/legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ extend(legendPrototype, {
let titleY = titleBox.y + titleOptions.margin.top;
let titleX = 0;

if(titleOptions.verticalAlignment === BOTTOM) {
if(titleOptions.verticalAlignment === BOTTOM && that._markersGroup) {
titleY += that._markersGroup.getBBox().height;
}

Expand Down
14 changes: 14 additions & 0 deletions testing/tests/DevExpress.viz.core/legend.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2494,6 +2494,20 @@ QUnit.test('Shift simple title; itemTextPosition = \'bottom\'', function(assert)
assert.deepEqual(this.title.shift.lastCall.args, [2, 2], 'title must have moved');
});

// T854736
QUnit.test('Shift legend with title after erase. Title position - bottom', function(assert) {
this.options.title = { text: 'Simple title', verticalAlignment: 'bottom' };

this.titleLayout.width = 16;

const legend = this.createSimpleLegend();
legend.draw(200, 200);
legend.erase();
legend.shift(0, 0);
assert.deepEqual(this.title.shift.lastCall.args, [0, 2], 'title must have moved');
});


QUnit.test('Shift simple title; horizontalAlignment = \'right\' verticalAlignment = \'top\' title.horizontalAlignment = \'center\'; margins not zero', function(assert) {
this.options.title = {
text: 'Simple title',
Expand Down

0 comments on commit 06d975e

Please sign in to comment.