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

Method updateLayoutConfig

src/label/LabelManager.ts:330–440  ·  view source on GitHub ↗
(api: ExtensionAPI)

Source from the content-addressed store, hash-verified

328 }
329
330 updateLayoutConfig(api: ExtensionAPI) {
331 const width = api.getWidth();
332 const height = api.getHeight();
333
334 function createDragHandler(el: Element, labelLineModel: Model) {
335 return function () {
336 updateLabelLinePoints(el, labelLineModel);
337 };
338 }
339 for (let i = 0; i < this._labelList.length; i++) {
340 const labelItem = this._labelList[i];
341 const label = labelItem.label;
342 const hostEl = label.__hostTarget;
343 const defaultLabelAttr = labelItem.defaultAttr;
344 let layoutOption;
345 // TODO A global layout option?
346 if (isFunction(labelItem.layoutOptionOrCb)) {
347 layoutOption = labelItem.layoutOptionOrCb(
348 prepareLayoutCallbackParams(labelItem, hostEl)
349 );
350 }
351 else {
352 layoutOption = labelItem.layoutOptionOrCb;
353 }
354
355 layoutOption = layoutOption || {};
356 labelItem.layoutOption = layoutOption;
357
358 const degreeToRadian = Math.PI / 180;
359 // TODO hostEl should always exists.
360 // Or label should not have parent because the x, y is all in global space.
361 if (hostEl) {
362 hostEl.setTextConfig({
363 // Force to set local false.
364 local: false,
365 // Ignore position and rotation config on the host el if x or y is changed.
366 position: (layoutOption.x != null || layoutOption.y != null)
367 ? null : defaultLabelAttr.attachedPos,
368 // Ignore rotation config on the host el if rotation is changed.
369 rotation: layoutOption.rotate != null
370 ? layoutOption.rotate * degreeToRadian : defaultLabelAttr.attachedRot,
371 offset: [layoutOption.dx || 0, layoutOption.dy || 0]
372 });
373 }
374 let needsUpdateLabelLine = false;
375 if (layoutOption.x != null) {
376 // TODO width of chart view.
377 label.x = parsePercent(layoutOption.x, width);
378 label.setStyle('x', 0); // Ignore movement in style. TODO: origin.
379 needsUpdateLabelLine = true;
380 }
381 else {
382 label.x = defaultLabelAttr.x;
383 label.setStyle('x', defaultLabelAttr.style.x);
384 }
385
386 if (layoutOption.y != null) {
387 // TODO height of chart view.

Callers 1

installLabelLayoutFunction · 0.80

Calls 9

setStyleMethod · 0.80
setShapeMethod · 0.80
getItemModelMethod · 0.80
getWidthMethod · 0.65
getHeightMethod · 0.65
getDataMethod · 0.65
isFunctionFunction · 0.50
getModelMethod · 0.45

Tested by

no test coverage detected