(
axis: Axis | NullUndefined,
seriesModel: SeriesModel,
coordSysType: CoordinateSystem['type']
)
| 375 | * @see scaleRawExtentInfoCreate in `scaleRawExtentInfo.ts` |
| 376 | */ |
| 377 | export function associateSeriesWithAxis( |
| 378 | axis: Axis | NullUndefined, |
| 379 | seriesModel: SeriesModel, |
| 380 | coordSysType: CoordinateSystem['type'] |
| 381 | ): void { |
| 382 | if (!axis) { |
| 383 | return; |
| 384 | } |
| 385 | |
| 386 | const ecModel = seriesModel.ecModel; |
| 387 | const ecFullUpdateCache = ecModelCacheFullUpdateInner(getCachePerECFullUpdate(ecModel)); |
| 388 | const axisModelUid = axis.model.uid; |
| 389 | |
| 390 | if (__DEV__) { |
| 391 | validateInputAxis(axis); |
| 392 | // - An axis can be associated with multiple `axisStatKey`s. For example, if `axisStatKey`s are |
| 393 | // "candlestick" and "bar", they can be associated with the same "xAxis". |
| 394 | // - Within an individual axis, it is a typically incorrect usage if a <axis, series> pair is |
| 395 | // associated with multiple `perKeyPerAxis`, which may cause repeated calculation and |
| 396 | // performance degradation, had hard to be found without the checking below. For example, If |
| 397 | // `axisStatKey` are "grid-bar" (see `barGrid.ts`) and "polar-bar" (see `barPolar.ts`), and |
| 398 | // a <xAxis-series> pair is wrongly associated with both "polar-bar" and "grid-bar", the |
| 399 | // relevant statistics will be computed twice. |
| 400 | const axSerPairCheck = ecFullUpdateCache.axSerPairCheck |
| 401 | || (ecFullUpdateCache.axSerPairCheck = createHashMap()); |
| 402 | const pairKey = `${axisModelUid}${AXIS_STAT_KEY_DELIMITER}${seriesModel.uid}`; |
| 403 | assert(!axSerPairCheck.get(pairKey)); |
| 404 | axSerPairCheck.set(pairKey, 1); |
| 405 | } |
| 406 | |
| 407 | const seriesOnAxisMap = ecFullUpdateCache.axSer || (ecFullUpdateCache.axSer = createHashMap()); |
| 408 | const seriesListPerAxis = seriesOnAxisMap.get(axisModelUid) || (seriesOnAxisMap.set(axisModelUid, [])); |
| 409 | if (__DEV__) { |
| 410 | const lastSeries = seriesListPerAxis[seriesListPerAxis.length - 1]; |
| 411 | if (lastSeries) { |
| 412 | // Series order should respect to the input order, since it matters in some cases |
| 413 | // (e.g., see `barGrid.ts` and `barPolar.ts` - ec option declaration order matters). |
| 414 | assert(lastSeries.seriesIndex < seriesModel.seriesIndex); |
| 415 | } |
| 416 | } |
| 417 | seriesListPerAxis.push(seriesModel); |
| 418 | |
| 419 | const seriesType = seriesModel.subType; |
| 420 | const isBaseAxis = seriesModel.getBaseAxis() === axis; |
| 421 | |
| 422 | const client = clientsForLookup.get(makeClientLookupKey(seriesType, isBaseAxis, coordSysType)) |
| 423 | || clientsForLookup.get(makeClientLookupKey(seriesType, isBaseAxis, null)); |
| 424 | if (!client) { |
| 425 | return; |
| 426 | } |
| 427 | |
| 428 | const keyed: AxisStatKeyed = ecFullUpdateCache.keyed || (ecFullUpdateCache.keyed = createHashMap()); |
| 429 | const keys: AxisStatKeys = ecFullUpdateCache.keys || (ecFullUpdateCache.keys = createHashMap()); |
| 430 | |
| 431 | const axisStatKey = client.key; |
| 432 | const perKey = keyed.get(axisStatKey) || keyed.set(axisStatKey, createHashMap()); |
| 433 | let perKeyPerAxis = perKey.get(axisModelUid); |
| 434 | if (!perKeyPerAxis) { |
no test coverage detected
searching dependent graphs…