(
axesInfo: Dictionary<CollectedAxisInfo>,
dispatchAction: ExtensionAPI['dispatchAction'],
api: ExtensionAPI
)
| 448 | } |
| 449 | |
| 450 | function dispatchHighDownActually( |
| 451 | axesInfo: Dictionary<CollectedAxisInfo>, |
| 452 | dispatchAction: ExtensionAPI['dispatchAction'], |
| 453 | api: ExtensionAPI |
| 454 | ) { |
| 455 | // FIXME |
| 456 | // highlight status modification should be a stage of main process? |
| 457 | // (Consider conflict (e.g., legend and axisPointer) and setOption) |
| 458 | |
| 459 | const zr = api.getZr(); |
| 460 | const highDownKey = 'axisPointerLastHighlights' as const; |
| 461 | const lastHighlights = inner(zr)[highDownKey] || {}; |
| 462 | const newHighlights: Dictionary<BatchItem> = inner(zr)[highDownKey] = {}; |
| 463 | |
| 464 | // Update highlight/downplay status according to axisPointer model. |
| 465 | // Build hash map and remove duplicate incidentally. |
| 466 | each(axesInfo, function (axisInfo, key) { |
| 467 | const option = axisInfo.axisPointerModel.option; |
| 468 | option.status === 'show' && axisInfo.triggerEmphasis && each(option.seriesDataIndices, function (batchItem) { |
| 469 | newHighlights[batchItem.seriesIndex + '|' + batchItem.dataIndex] = batchItem; |
| 470 | }); |
| 471 | }); |
| 472 | |
| 473 | // Diff. |
| 474 | const toHighlight: Pick<BatchItem, 'seriesIndex' | 'dataIndex'>[] = []; |
| 475 | const toDownplay: Pick<BatchItem, 'seriesIndex' | 'dataIndex'>[] = []; |
| 476 | function makeHighDownItem(batchItem: BatchItem) { |
| 477 | // `dataIndexInside` should be removed, since the last recorded `dataIndexInside` may have |
| 478 | // been changed if `dataZoomInside` changed the view. Only `dataIndex` will suffice. |
| 479 | return { |
| 480 | seriesIndex: batchItem.seriesIndex, |
| 481 | dataIndex: batchItem.dataIndex, |
| 482 | }; |
| 483 | } |
| 484 | each(lastHighlights, function (batchItem, key) { |
| 485 | !newHighlights[key] && toDownplay.push(makeHighDownItem(batchItem)); |
| 486 | }); |
| 487 | each(newHighlights, function (batchItem, key) { |
| 488 | !lastHighlights[key] && toHighlight.push(makeHighDownItem(batchItem)); |
| 489 | }); |
| 490 | |
| 491 | toDownplay.length && api.dispatchAction({ |
| 492 | type: 'downplay', |
| 493 | escapeConnect: true, |
| 494 | // Not blur others when highlight in axisPointer. |
| 495 | notBlur: true, |
| 496 | batch: toDownplay |
| 497 | } as DownplayPayload); |
| 498 | toHighlight.length && api.dispatchAction({ |
| 499 | type: 'highlight', |
| 500 | escapeConnect: true, |
| 501 | // Not blur others when highlight in axisPointer. |
| 502 | notBlur: true, |
| 503 | batch: toHighlight |
| 504 | } as HighlightPayload); |
| 505 | } |
| 506 | |
| 507 | function findInputAxisInfo( |
no test coverage detected
searching dependent graphs…