(value: AxisValue, axisInfo: CollectedAxisInfo)
| 257 | } |
| 258 | |
| 259 | function buildPayloadsBySeries(value: AxisValue, axisInfo: CollectedAxisInfo) { |
| 260 | const axis = axisInfo.axis; |
| 261 | const dim = axis.dim; |
| 262 | let snapToValue = value; |
| 263 | const payloadBatch: BatchItem[] = []; |
| 264 | let minDist = Number.MAX_VALUE; |
| 265 | let minDiff = -1; |
| 266 | |
| 267 | each(axisInfo.seriesModels, function (series, idx) { |
| 268 | const dataDim = series.getData().mapDimensionsAll(dim); |
| 269 | let seriesNestestValue; |
| 270 | let dataIndices; |
| 271 | |
| 272 | if (series.getAxisTooltipData) { |
| 273 | const result = series.getAxisTooltipData(dataDim, value, axis); |
| 274 | dataIndices = result.dataIndices; |
| 275 | seriesNestestValue = result.nestestValue; |
| 276 | } |
| 277 | else { |
| 278 | dataIndices = series.indicesOfNearest( |
| 279 | dim, |
| 280 | dataDim[0], |
| 281 | value as number, |
| 282 | // Add a threshold to avoid find the wrong dataIndex |
| 283 | // when data length is not same. |
| 284 | // false, |
| 285 | axis.type === 'category' ? 0.5 : null |
| 286 | ); |
| 287 | if (!dataIndices.length) { |
| 288 | return; |
| 289 | } |
| 290 | seriesNestestValue = series.getData().get(dataDim[0], dataIndices[0]); |
| 291 | } |
| 292 | |
| 293 | if (!isNullableNumberFinite(seriesNestestValue)) { |
| 294 | return; |
| 295 | } |
| 296 | |
| 297 | const diff = value as number - seriesNestestValue; |
| 298 | const dist = Math.abs(diff); |
| 299 | // Consider category case |
| 300 | if (dist <= minDist) { |
| 301 | if (dist < minDist || (diff >= 0 && minDiff < 0)) { |
| 302 | minDist = dist; |
| 303 | minDiff = diff; |
| 304 | snapToValue = seriesNestestValue; |
| 305 | payloadBatch.length = 0; |
| 306 | } |
| 307 | each(dataIndices, function (dataIndex) { |
| 308 | payloadBatch.push({ |
| 309 | seriesIndex: series.seriesIndex, |
| 310 | dataIndexInside: dataIndex, |
| 311 | dataIndex: series.getData().getRawIndex(dataIndex) |
| 312 | }); |
| 313 | }); |
| 314 | } |
| 315 | }); |
| 316 |
no test coverage detected
searching dependent graphs…