Skip to content

Commit

Permalink
fix(tooltip): fix spec naming (#412)
Browse files Browse the repository at this point in the history
set name to spec name then spec id

closes #411
  • Loading branch information
nickofthyme authored Oct 9, 2019
1 parent 81bac09 commit 3690cca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/chart_types/xy_chart/tooltip/tooltip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ describe('Tooltip formatting', () => {
expect(tooltipValue.color).toBe('blue');
expect(tooltipValue.value).toBe('10');
});
it('should set name as spec name when provided', () => {
const name = 'test - spec';
const tooltipValue = formatTooltip(indexedBandedGeometry, { ...SPEC_1, name }, false, false, YAXIS_SPEC);
expect(tooltipValue.name).toBe(name);
});
it('should set name as spec id when name is not provided', () => {
const tooltipValue = formatTooltip(indexedBandedGeometry, SPEC_1, false, false, YAXIS_SPEC);
expect(tooltipValue.name).toBe(SPEC_1.id);
});
test('format banded tooltip - upper', () => {
const tooltipValue = formatTooltip(indexedBandedGeometry, bandedSpec, false, false, YAXIS_SPEC);
expect(tooltipValue.name).toBe('bar_1 - upper');
Expand Down
2 changes: 1 addition & 1 deletion src/chart_types/xy_chart/tooltip/tooltip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function formatTooltip(
if (seriesKey.length > 0) {
displayName = seriesKey.join(' - ');
} else {
displayName = name || `${spec.id}`;
displayName = spec.name || `${spec.id}`;
}

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

0 comments on commit 3690cca

Please sign in to comment.