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

Function axisName

src/component/axis/AxisBuilder.ts:831–980  ·  view source on GitHub ↗

* [CAUTION] This method can be called multiple times, following the change due to `resetCfg` called * in size measurement. Thus this method should be idempotent, and should be performant.

(cfg, local, shared, axisModel, group, transformGroup, api, extraParams)

Source from the content-addressed store, hash-verified

829 * in size measurement. Thus this method should be idempotent, and should be performant.
830 */
831 axisName(cfg, local, shared, axisModel, group, transformGroup, api, extraParams) {
832 const sharedRecord = shared.ensureRecord(axisModel);
833 if (__DEV__) {
834 const ready = sharedRecord.ready;
835 assert(ready.axisTickLabelEstimate || ready.axisTickLabelDetermine);
836 ready.axisName = true;
837 }
838
839 // Remove the existing name result created in estimation phase.
840 if (local.nameEl) {
841 group.remove(local.nameEl);
842 local.nameEl = sharedRecord.nameLayout = sharedRecord.nameLocation = null;
843 }
844
845 const name = cfg.axisName;
846 if (!hasAxisName(name)) {
847 return;
848 }
849
850 const nameLocation = cfg.nameLocation;
851 const nameDirection = cfg.nameDirection;
852 const textStyleModel = axisModel.getModel('nameTextStyle');
853 const gap = (axisModel.get('nameGap') || 0);
854
855 const extent = axisModel.axis.getExtent();
856 const gapStartEndSignal = axisModel.axis.inverse ? -1 : 1;
857 const pos = new Point(0, 0);
858 const nameMoveDirVec = new Point(0, 0);
859 if (nameLocation === 'start') {
860 pos.x = extent[0] - gapStartEndSignal * gap;
861 nameMoveDirVec.x = -gapStartEndSignal;
862 }
863 else if (nameLocation === 'end') {
864 pos.x = extent[1] + gapStartEndSignal * gap;
865 nameMoveDirVec.x = gapStartEndSignal;
866 }
867 else { // 'middle' or 'center'
868 pos.x = (extent[0] + extent[1]) / 2;
869 pos.y = cfg.labelOffset + nameDirection * gap;
870 nameMoveDirVec.y = nameDirection;
871 }
872 const mt = matrixUtil.create();
873 nameMoveDirVec.transform(matrixUtil.rotate(mt, mt, cfg.rotation));
874
875 let nameRotation = axisModel.get('nameRotate');
876 if (nameRotation != null) {
877 nameRotation = nameRotation * PI / 180; // To radian.
878 }
879
880 let labelLayout;
881 let axisNameAvailableWidth;
882
883 if (isNameLocationCenter(nameLocation)) {
884 labelLayout = AxisBuilder.innerTextLayout(
885 cfg.rotation,
886 nameRotation != null ? nameRotation : cfg.rotation, // Adapt to axis.
887 nameDirection
888 );

Callers

nothing calls this directly

Calls 15

isNameLocationCenterFunction · 0.90
createTextStyleFunction · 0.90
hasAxisNameFunction · 0.85
endTextLayoutFunction · 0.85
retrieveFunction · 0.85
ensureRecordMethod · 0.80
innerTextLayoutMethod · 0.80
getFontMethod · 0.80
isLabelSilentMethod · 0.80
getTextColorMethod · 0.80
makeAxisEventDataBaseMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…