Skip to content

Commit

Permalink
Fix legend alignment issue in Chrome, many thanks @Spacarar, see dc-j…
Browse files Browse the repository at this point in the history
  • Loading branch information
kum-deepak committed Feb 14, 2022
1 parent cb0027c commit b110c0a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 1 addition & 2 deletions spec/legend-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ describe('dc.legend', () => {
expect(chart.selectAll('g.dc-legend g.dc-legend-item text').size()).toBe(3);
});

// The following test has started failing on Chrome Headless 96.0.4664.110
xit('should position the legend labels', () => {
it('should position the legend labels', () => {
expect(legendLabel(0).attr('x')).toBeWithinDelta(15, 2);
expect(legendLabel(0).attr('y')).toBeWithinDelta(11.75, 2);
expect(legendLabel(1).attr('x')).toBeWithinDelta(15, 2);
Expand Down
5 changes: 2 additions & 3 deletions src/charts/legend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,8 @@ export class Legend {
.text(self._legendText)
.attr('x', self._itemHeight + LABEL_GAP)
.attr('y', function () {
return (
self._itemHeight / 2 + (this.clientHeight ? this.clientHeight : 13) / 2 - 2
);
const clientHeight = this.getBoundingClientRect().height || 13;
return self._itemHeight / 2 + clientHeight / 2 - 2;
});
}

Expand Down

0 comments on commit b110c0a

Please sign in to comment.