Skip to content

Commit b110c0a

Browse files
committed
Fix legend alignment issue in Chrome, many thanks @Spacarar, see dc-js#1852, dc-js#1855, dc-js#1856
1 parent cb0027c commit b110c0a

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

spec/legend-spec.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ describe('dc.legend', () => {
5353
expect(chart.selectAll('g.dc-legend g.dc-legend-item text').size()).toBe(3);
5454
});
5555

56-
// The following test has started failing on Chrome Headless 96.0.4664.110
57-
xit('should position the legend labels', () => {
56+
it('should position the legend labels', () => {
5857
expect(legendLabel(0).attr('x')).toBeWithinDelta(15, 2);
5958
expect(legendLabel(0).attr('y')).toBeWithinDelta(11.75, 2);
6059
expect(legendLabel(1).attr('x')).toBeWithinDelta(15, 2);

src/charts/legend.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -289,9 +289,8 @@ export class Legend {
289289
.text(self._legendText)
290290
.attr('x', self._itemHeight + LABEL_GAP)
291291
.attr('y', function () {
292-
return (
293-
self._itemHeight / 2 + (this.clientHeight ? this.clientHeight : 13) / 2 - 2
294-
);
292+
const clientHeight = this.getBoundingClientRect().height || 13;
293+
return self._itemHeight / 2 + clientHeight / 2 - 2;
295294
});
296295
}
297296

0 commit comments

Comments
 (0)