diff --git a/__tests__/integration/snapshots/tooltip/aapl-area-missing-data-transpose/step0.html b/__tests__/integration/snapshots/tooltip/aapl-area-missing-data-transpose/step0.html new file mode 100644 index 0000000000..13717a0c0e --- /dev/null +++ b/__tests__/integration/snapshots/tooltip/aapl-area-missing-data-transpose/step0.html @@ -0,0 +1,46 @@ +
+
+ Thu Sep 27 2007 08:00:00 GMT+0800 (中国标准时间) +
+ +
; diff --git a/__tests__/plots/tooltip/aapl-area-missing-data-transpose.ts b/__tests__/plots/tooltip/aapl-area-missing-data-transpose.ts new file mode 100644 index 0000000000..3d8d43e65f --- /dev/null +++ b/__tests__/plots/tooltip/aapl-area-missing-data-transpose.ts @@ -0,0 +1,42 @@ +import { G2Spec } from '../../../src'; +import { seriesTooltipSteps } from './utils'; + +export function aaplAreaMissingDataTranspose(): G2Spec { + return { + width: 800, + type: 'area', + coordinate: { transform: [{ type: 'transpose' }] }, + data: { + type: 'fetch', + value: 'data/aapl.csv', + transform: [ + { + type: 'map', + callback: (d) => ({ + ...d, + close: d.date.getUTCMonth() <= 3 ? NaN : d.close, + }), + }, + ], + }, + encode: { + x: 'date', + y: 'close', + }, + scale: { + x: { type: 'time' }, + }, + style: { + connect: true, + connectFill: 'grey', + connectFillOpacity: 0.15, + }, + tooltip: { + // title: '', + }, + }; +} + +aaplAreaMissingDataTranspose.maxError = 125; + +aaplAreaMissingDataTranspose.steps = seriesTooltipSteps([100, 88]); diff --git a/__tests__/plots/tooltip/index.ts b/__tests__/plots/tooltip/index.ts index d4d382fc25..0baf98854f 100644 --- a/__tests__/plots/tooltip/index.ts +++ b/__tests__/plots/tooltip/index.ts @@ -56,3 +56,4 @@ export { scoreByItemAreaRadar } from './score-by-item-area-radar'; export { profitIntervalLegendFilterOrdinal } from './profit-interval-legend-filter-ordinal'; export { aaplLineSliderFilter } from './appl-line-slider-filter'; export { aaplLineAreaBasicSample } from './aapl-line-area-basic-sample'; +export { aaplAreaMissingDataTranspose } from './aapl-area-missing-data-transpose'; diff --git a/src/interaction/tooltip.ts b/src/interaction/tooltip.ts index 260fee7052..e62299f348 100644 --- a/src/interaction/tooltip.ts +++ b/src/interaction/tooltip.ts @@ -388,7 +388,7 @@ export function seriesTooltip( selectedSeriesElements.push(element); const d = seriesData(element, index); const { x, y } = d; - const p = coordinate.map([x + offsetX, y]); + const p = coordinate.map([(x || 0) + offsetX, y || 0]); selectedSeriesData.push([d, p] as const); } }