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

Function injectCoordSysByOption

src/core/CoordinateSystem.ts:290–347  ·  view source on GitHub ↗
(opt: {
    // series or component
    targetModel: ComponentModel;
    coordSysType: string;
    coordSysProvider: CoordSysInjectionProvider;
    isDefaultDataCoordSys?: boolean;
    allowNotFound?: boolean
})

Source from the content-addressed store, hash-verified

288 * once for each series/components.
289 */
290export function injectCoordSysByOption(opt: {
291 // series or component
292 targetModel: ComponentModel;
293 coordSysType: string;
294 coordSysProvider: CoordSysInjectionProvider;
295 isDefaultDataCoordSys?: boolean;
296 allowNotFound?: boolean
297}): CoordinateSystemUsageKind {
298 const {
299 targetModel,
300 coordSysType,
301 coordSysProvider,
302 isDefaultDataCoordSys,
303 allowNotFound,
304 } = opt;
305 if (__DEV__) {
306 zrUtil.assert(!!coordSysType);
307 }
308
309 let {kind, coordSysType: declaredType} = decideCoordSysUsageKind(targetModel, true);
310
311 if (isDefaultDataCoordSys
312 && kind !== COORD_SYS_USAGE_KIND_DATA
313 ) {
314 // If both `COORD_SYS_USAGE_KIND_DATA` and `COORD_SYS_USAGE_KIND_BOX` declared in one model.
315 // There is the only case in series-graph, and no other cases yet.
316 kind = COORD_SYS_USAGE_KIND_DATA;
317 declaredType = coordSysType;
318 }
319
320 if (kind === COORD_SYS_USAGE_KIND_NONE || declaredType !== coordSysType) {
321 return COORD_SYS_USAGE_KIND_NONE;
322 }
323
324 const coordSys = coordSysProvider(coordSysType, targetModel);
325 if (!coordSys) {
326 if (__DEV__) {
327 if (!allowNotFound) {
328 error(`${coordSysType} cannot be found for`
329 + ` ${targetModel.type} (index: ${targetModel.componentIndex}).`
330 );
331 }
332 }
333 return COORD_SYS_USAGE_KIND_NONE;
334 }
335
336 if (kind === COORD_SYS_USAGE_KIND_DATA) {
337 if (__DEV__) {
338 zrUtil.assert(targetModel.mainType === 'series');
339 }
340 (targetModel as SeriesModel).coordinateSystem = coordSys;
341 }
342 else { // kind === COORD_SYS_USAGE_KIND_BOX
343 targetModel.boxCoordinateSystem = coordSys;
344 }
345
346 return kind;
347}

Callers 5

createViewCoordSysFunction · 0.90
createMethod · 0.90
createMethod · 0.90
createMethod · 0.90
createMethod · 0.90

Calls 2

errorFunction · 0.90
decideCoordSysUsageKindFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…