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

Function findEffectedDataZooms

src/component/dataZoom/helper.ts:103–163  ·  view source on GitHub ↗
(ecModel: GlobalModel, payload: Payload)

Source from the content-addressed store, hash-verified

101 * This function finds all linked dataZoomModels start from the given payload.
102 */
103export function findEffectedDataZooms(ecModel: GlobalModel, payload: Payload): DataZoomModel[] {
104
105 // Key: `DataZoomAxisDimension`
106 const axisRecords = createHashMap<boolean[], DataZoomAxisDimension>();
107 const effectedModels: DataZoomModel[] = [];
108 // Key: uid of dataZoomModel
109 const effectedModelMap = createHashMap<boolean>();
110
111 // Find the dataZooms specified by payload.
112 ecModel.eachComponent(
113 { mainType: 'dataZoom', query: payload },
114 function (dataZoomModel: DataZoomModel) {
115 if (!effectedModelMap.get(dataZoomModel.uid)) {
116 addToEffected(dataZoomModel);
117 }
118 }
119 );
120
121 // Start from the given dataZoomModels, travel the graph to find
122 // all of the linked dataZoom models.
123 let foundNewLink;
124 do {
125 foundNewLink = false;
126 ecModel.eachComponent('dataZoom', processSingle);
127 }
128 while (foundNewLink);
129
130 function processSingle(dataZoomModel: DataZoomModel): void {
131 if (!effectedModelMap.get(dataZoomModel.uid) && isLinked(dataZoomModel)) {
132 addToEffected(dataZoomModel);
133 foundNewLink = true;
134 }
135 }
136
137 function addToEffected(dataZoom: DataZoomModel): void {
138 effectedModelMap.set(dataZoom.uid, true);
139 effectedModels.push(dataZoom);
140 markAxisControlled(dataZoom);
141 }
142
143 function isLinked(dataZoomModel: DataZoomModel): boolean {
144 let isLink = false;
145 dataZoomModel.eachTargetAxis(function (axisDim, axisIndex) {
146 const axisIdxArr = axisRecords.get(axisDim);
147 if (axisIdxArr && axisIdxArr[axisIndex]) {
148 isLink = true;
149 }
150 });
151 return isLink;
152 }
153
154 function markAxisControlled(dataZoomModel: DataZoomModel) {
155 dataZoomModel.eachTargetAxis(function (axisDim, axisIndex) {
156 (
157 axisRecords.get(axisDim) || axisRecords.set(axisDim, [])
158 )[axisIndex] = true;
159 });
160 }

Callers 2

helper.test.tsFile · 0.90
installDataZoomActionFunction · 0.90

Calls 3

addToEffectedFunction · 0.85
eachComponentMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…