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

Function decideCoordSysUsageKind

src/core/CoordinateSystem.ts:186–233  ·  view source on GitHub ↗
(
    // Component or series
    model: ComponentModel,
    printError?: boolean
)

Source from the content-addressed store, hash-verified

184 | typeof COORD_SYS_USAGE_KIND_BOX;
185
186export function decideCoordSysUsageKind(
187 // Component or series
188 model: ComponentModel,
189 printError?: boolean
190): {
191 kind: CoordinateSystemUsageKind;
192 coordSysType: string | NullUndefined;
193} {
194 // For backward compat, still not use `true` in model.get.
195 const coordSysType = model.getShallow('coordinateSystem');
196 let coordSysUsageOption = model.getShallow('coordinateSystemUsage', true);
197 const isDeclaredExplicitly = coordSysUsageOption != null;
198 let kind: CoordinateSystemUsageKind = COORD_SYS_USAGE_KIND_NONE;
199
200 if (coordSysType) {
201 const isSeries = model.mainType === 'series';
202 if (coordSysUsageOption == null) {
203 coordSysUsageOption = isSeries ? 'data' : 'box';
204 }
205
206 if (coordSysUsageOption === 'data') {
207 kind = COORD_SYS_USAGE_KIND_DATA;
208 if (!isSeries) {
209 if (__DEV__) {
210 if (isDeclaredExplicitly && printError) {
211 error('coordinateSystemUsage "data" is not supported in non-series components.');
212 }
213 }
214 kind = COORD_SYS_USAGE_KIND_NONE;
215 }
216 }
217 else if (coordSysUsageOption === 'box') {
218 kind = COORD_SYS_USAGE_KIND_BOX;
219 if (!isSeries && !canBeNonSeriesBoxCoordSys(coordSysType)) {
220 if (__DEV__) {
221 if (isDeclaredExplicitly && printError) {
222 error(`coordinateSystem "${coordSysType}" cannot be used`
223 + ` as coordinateSystemUsage "box" for "${model.type}" yet.`
224 );
225 }
226 }
227 kind = COORD_SYS_USAGE_KIND_NONE;
228 }
229 }
230 }
231
232 return {coordSysType, kind};
233}
234
235/**
236 * These cases are considered:

Callers 2

getHostGeoModelMethod · 0.90
injectCoordSysByOptionFunction · 0.85

Calls 3

errorFunction · 0.90
getShallowMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…