MCPcopy Create free account
hub / github.com/apache/echarts / AxisModel

Class AxisModel

src/coord/axisModelCreator.ts:68–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66 );
67
68 class AxisModel extends BaseAxisModelClass implements AxisModelExtendedInCreator {
69
70 static type = axisName + 'Axis.' + axisType;
71 type = axisName + 'Axis.' + axisType;
72
73 static defaultOption = defaultOption;
74
75 private __ordinalMeta: OrdinalMeta;
76
77
78 mergeDefaultAndTheme(option: AxisOptionT, ecModel: GlobalModel): void {
79 const layoutMode = fetchLayoutMode(this);
80 const inputPositionParams = layoutMode
81 ? getLayoutParams(option as BoxLayoutOptionMixin) : {};
82
83 const themeModel = ecModel.getTheme();
84 merge(option, themeModel.get(axisType + 'Axis'));
85 merge(option, this.getDefaultOption());
86
87 option.type = getAxisType(option);
88
89 if (layoutMode) {
90 mergeLayoutParam(option as BoxLayoutOptionMixin, inputPositionParams, layoutMode);
91 }
92 }
93
94 optionUpdated(): void {
95 const thisOption = this.option;
96 if (thisOption.type === 'category') {
97 this.__ordinalMeta = OrdinalMeta.createByAxisModel(this);
98 }
99 }
100
101 /**
102 * Should not be called before all of 'getInitailData' finished.
103 * Because categories are collected during initializing data.
104 */
105 getCategories(rawData?: boolean): OrdinalRawValue[] | CategoryAxisBaseOption['data'] {
106 const option = this.option;
107 // FIXME
108 // warning if called before all of 'getInitailData' finished.
109 if (option.type === 'category') {
110 if (rawData) {
111 // NOTICE: return the raw data even if not existing; never use a fallback like `[]`;
112 // Its existence matters in some legacy cases.
113 return (option as CategoryAxisBaseOption).data;
114 }
115 return this.__ordinalMeta.categories;
116 }
117 }
118
119 getOrdinalMeta(): OrdinalMeta {
120 return this.__ordinalMeta;
121 }
122
123 updateAxisBreaks(payload: BaseAxisBreakPayload): AxisBreakUpdateResult {
124 const axisBreakHelper = getAxisBreakHelper();
125 return axisBreakHelper

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected