(match: HitTestMatch | null, event: PointerEvent)
| 1077 | }; |
| 1078 | |
| 1079 | const buildPayload = (match: HitTestMatch | null, event: PointerEvent): ChartGPUEventPayload => { |
| 1080 | if (!match) { |
| 1081 | return { seriesIndex: null, dataIndex: null, value: null, seriesName: null, event }; |
| 1082 | } |
| 1083 | |
| 1084 | const seriesIndex = match.kind === 'cartesian' ? match.match.seriesIndex : match.seriesIndex; |
| 1085 | const dataIndex = match.kind === 'cartesian' ? match.match.dataIndex : match.dataIndex; |
| 1086 | |
| 1087 | const series = resolvedOptions.series[seriesIndex]; |
| 1088 | const seriesNameRaw = series?.name ?? null; |
| 1089 | const seriesName = seriesNameRaw && seriesNameRaw.trim().length > 0 ? seriesNameRaw : null; |
| 1090 | |
| 1091 | if (match.kind === 'pie') { |
| 1092 | // Pie series are non-cartesian; expose slice value in y so consumers can read a numeric. |
| 1093 | return { |
| 1094 | seriesIndex, |
| 1095 | dataIndex, |
| 1096 | value: [0, match.sliceValue], |
| 1097 | seriesName, |
| 1098 | event, |
| 1099 | }; |
| 1100 | } |
| 1101 | |
| 1102 | if (match.kind === 'candlestick') { |
| 1103 | const timestamp = getOHLCTimestamp(match.point); |
| 1104 | const close = getOHLCClose(match.point); |
| 1105 | return { |
| 1106 | seriesIndex, |
| 1107 | dataIndex, |
| 1108 | value: [timestamp, close], |
| 1109 | seriesName, |
| 1110 | event, |
| 1111 | }; |
| 1112 | } |
| 1113 | |
| 1114 | const { x, y } = getPointXY(match.match.point); |
| 1115 | return { |
| 1116 | seriesIndex, |
| 1117 | dataIndex, |
| 1118 | value: [x, y], |
| 1119 | seriesName, |
| 1120 | event, |
| 1121 | }; |
| 1122 | }; |
| 1123 | |
| 1124 | const emit = ( |
| 1125 | eventName: ChartGPUEventName, |
no test coverage detected