MCPcopy
hub / github.com/apache/echarts / _enableRealtimeSort

Method _enableRealtimeSort

src/chart/bar/BarView.ts:478–514  ·  view source on GitHub ↗
(
        realtimeSortCfg: RealtimeSortConfig,
        data: ReturnType<BarSeriesModel['getData']>,
        api: ExtensionAPI
    )

Source from the content-addressed store, hash-verified

476 }
477
478 private _enableRealtimeSort(
479 realtimeSortCfg: RealtimeSortConfig,
480 data: ReturnType<BarSeriesModel['getData']>,
481 api: ExtensionAPI
482 ): void {
483 // If no data in the first frame, wait for data to initSort
484 if (!data.count()) {
485 return;
486 }
487
488 const baseAxis = realtimeSortCfg.baseAxis;
489
490 if (this._isFirstFrame) {
491 this._dispatchInitSort(data, realtimeSortCfg, api);
492 this._isFirstFrame = false;
493 }
494 else {
495 const orderMapping = (idx: number) => {
496 const el = (data.getItemGraphicEl(idx) as Rect);
497 const shape = el && el.shape;
498 return (shape && (
499 // The result should be consistent with the initial sort by data value.
500 // Do not support the case that both positive and negative exist.
501 Math.abs(
502 baseAxis.isHorizontal()
503 ? shape.height
504 : shape.width
505 )
506 // If data is NaN, shape.xxx may be NaN, so use || 0 here in case
507 )) || 0;
508 };
509 this._onRendered = () => {
510 this._updateSortWithinSameData(data, orderMapping, baseAxis, api);
511 };
512 api.getZr().on('rendered', this._onRendered);
513 }
514 }
515
516 private _dataSort(
517 data: SeriesData<BarSeriesModel, DefaultDataVisual>,

Callers 1

_renderNormalMethod · 0.95

Calls 4

_dispatchInitSortMethod · 0.95
countMethod · 0.65
getZrMethod · 0.65

Tested by

no test coverage detected