Skip to content

Commit 3690cca

Browse files
authored
fix(tooltip): fix spec naming (#412)
set name to spec name then spec id closes #411
1 parent 81bac09 commit 3690cca

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/chart_types/xy_chart/tooltip/tooltip.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ describe('Tooltip formatting', () => {
9595
expect(tooltipValue.color).toBe('blue');
9696
expect(tooltipValue.value).toBe('10');
9797
});
98+
it('should set name as spec name when provided', () => {
99+
const name = 'test - spec';
100+
const tooltipValue = formatTooltip(indexedBandedGeometry, { ...SPEC_1, name }, false, false, YAXIS_SPEC);
101+
expect(tooltipValue.name).toBe(name);
102+
});
103+
it('should set name as spec id when name is not provided', () => {
104+
const tooltipValue = formatTooltip(indexedBandedGeometry, SPEC_1, false, false, YAXIS_SPEC);
105+
expect(tooltipValue.name).toBe(SPEC_1.id);
106+
});
98107
test('format banded tooltip - upper', () => {
99108
const tooltipValue = formatTooltip(indexedBandedGeometry, bandedSpec, false, false, YAXIS_SPEC);
100109
expect(tooltipValue.name).toBe('bar_1 - upper');

src/chart_types/xy_chart/tooltip/tooltip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export function formatTooltip(
5555
if (seriesKey.length > 0) {
5656
displayName = seriesKey.join(' - ');
5757
} else {
58-
displayName = name || `${spec.id}`;
58+
displayName = spec.name || `${spec.id}`;
5959
}
6060

6161
if (isBandedSpec(spec.y0Accessors) && (isAreaSeriesSpec(spec) || isBarSeriesSpec(spec))) {

0 commit comments

Comments
 (0)