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

Method _updateViewCoordSys

src/chart/tree/TreeView.ts:252–297  ·  view source on GitHub ↗
(seriesModel: TreeSeriesModel, api: ExtensionAPI)

Source from the content-addressed store, hash-verified

250 }
251
252 private _updateViewCoordSys(seriesModel: TreeSeriesModel, api: ExtensionAPI) {
253 const data = seriesModel.getData();
254 const points: number[][] = [];
255 data.each(function (idx) {
256 const layout = data.getItemLayout(idx);
257 if (layout && !isNaN(layout.x) && !isNaN(layout.y)) {
258 points.push([+layout.x, +layout.y]);
259 }
260 });
261 const min: number[] = [];
262 const max: number[] = [];
263 bbox.fromPoints(points, min, max);
264
265 // If don't Store min max when collapse the root node after roam,
266 // the root node will disappear.
267 const oldMin = this._min;
268 const oldMax = this._max;
269
270 // If width or height is 0
271 if (max[0] - min[0] === 0) {
272 min[0] = oldMin ? oldMin[0] : min[0] - 1;
273 max[0] = oldMax ? oldMax[0] : max[0] + 1;
274 }
275 if (max[1] - min[1] === 0) {
276 min[1] = oldMin ? oldMin[1] : min[1] - 1;
277 max[1] = oldMax ? oldMax[1] : max[1] + 1;
278 }
279
280 // Here we use viewCoordSys just for computing the 'position' and 'scale' of the group,
281 // and 'treeRoam' action.
282 const ownCoordSys = seriesModel.coordinateSystem = createViewCoordSysSimply(
283 seriesModel,
284 api,
285 min[0], min[1], max[0] - min[0], max[1] - min[1]
286 );
287
288 applyViewCoordSysTransToElement(
289 this.group,
290 VIEW_COORD_SYS_TRANS_OVERALL,
291 ownCoordSys,
292 this._firstRender ? null : seriesModel,
293 );
294
295 this._min = min;
296 this._max = max;
297 }
298
299 _updateNodeAndLinkScale(seriesModel: TreeSeriesModel) {
300 const data = seriesModel.getData();

Callers 1

renderMethod · 0.95

Calls 5

createViewCoordSysSimplyFunction · 0.90
getItemLayoutMethod · 0.80
getDataMethod · 0.65
eachMethod · 0.45

Tested by

no test coverage detected