(
fromSeries: ResolvedChartGPUOptions['series'],
toSeries: ResolvedChartGPUOptions['series'],
t01: number,
caches: UpdateInterpolationCaches | null
)
| 1651 | }; |
| 1652 | |
| 1653 | const interpolateSeriesForUpdate = ( |
| 1654 | fromSeries: ResolvedChartGPUOptions['series'], |
| 1655 | toSeries: ResolvedChartGPUOptions['series'], |
| 1656 | t01: number, |
| 1657 | caches: UpdateInterpolationCaches | null |
| 1658 | ): ResolvedChartGPUOptions['series'] => { |
| 1659 | if (fromSeries.length !== toSeries.length) return toSeries; |
| 1660 | |
| 1661 | const out: ResolvedChartGPUOptions['series'][number][] = new Array(toSeries.length); |
| 1662 | |
| 1663 | for (let i = 0; i < toSeries.length; i++) { |
| 1664 | const a = fromSeries[i]!; |
| 1665 | const b = toSeries[i]!; |
| 1666 | |
| 1667 | if (a.type !== b.type) { |
| 1668 | out[i] = b; |
| 1669 | continue; |
| 1670 | } |
| 1671 | |
| 1672 | if (b.type === 'pie') { |
| 1673 | const cache = caches?.pieDataBySeriesIndex[i] ?? null; |
| 1674 | const animated = interpolatePieSeriesByIndex(a as ResolvedPieSeriesConfig, b as ResolvedPieSeriesConfig, t01, cache); |
| 1675 | if (caches) caches.pieDataBySeriesIndex[i] = animated.data as any; |
| 1676 | out[i] = animated; |
| 1677 | continue; |
| 1678 | } |
| 1679 | |
| 1680 | // Cartesian series: interpolate y-values by index. Keep x from "to". |
| 1681 | const aAny = a as unknown as { readonly data: ReadonlyArray<DataPoint> }; |
| 1682 | const bAny = b as unknown as { readonly data: ReadonlyArray<DataPoint> }; |
| 1683 | const aData = aAny.data; |
| 1684 | const bData = bAny.data; |
| 1685 | |
| 1686 | if (aData.length !== bData.length) { |
| 1687 | out[i] = b; |
| 1688 | continue; |
| 1689 | } |
| 1690 | if (bData.length > MAX_ANIMATED_POINTS_PER_SERIES) { |
| 1691 | out[i] = b; |
| 1692 | continue; |
| 1693 | } |
| 1694 | |
| 1695 | const cache = caches?.cartesianDataBySeriesIndex[i] ?? null; |
| 1696 | const animatedData = interpolateCartesianSeriesDataByIndex(aData, bData, t01, cache); |
| 1697 | if (!animatedData) { |
| 1698 | out[i] = b; |
| 1699 | continue; |
| 1700 | } |
| 1701 | if (caches) caches.cartesianDataBySeriesIndex[i] = animatedData; |
| 1702 | |
| 1703 | out[i] = { ...(b as any), data: animatedData }; |
| 1704 | } |
| 1705 | |
| 1706 | return out; |
| 1707 | }; |
| 1708 | |
| 1709 | const computeUpdateSnapshotAtProgress = ( |
| 1710 | transition: UpdateTransition, |
no test coverage detected