MCPcopy
hub / github.com/tdewolff/minify / createEl

Function createEl

_benchmarks/sample_echarts.js:70521–70572  ·  view source on GitHub ↗
(elOption)

Source from the content-addressed store, hash-verified

70519 }
70520
70521 function createEl(elOption) {
70522 var graphicType = elOption.type;
70523 var el; // Those graphic elements are not shapes. They should not be
70524 // overwritten by users, so do them first.
70525
70526 if (graphicType === 'path') {
70527 var shape = elOption.shape; // Using pathRect brings convenience to users sacle svg path.
70528
70529 var pathRect = shape.width != null && shape.height != null ? {
70530 x: shape.x || 0,
70531 y: shape.y || 0,
70532 width: shape.width,
70533 height: shape.height
70534 } : null;
70535 var pathData = getPathData(shape); // Path is also used for icon, so layout 'center' by default.
70536
70537 el = makePath(pathData, null, pathRect, shape.layout || 'center');
70538 inner$9(el).customPathData = pathData;
70539 } else if (graphicType === 'image') {
70540 el = new ZRImage({});
70541 inner$9(el).customImagePath = elOption.style.image;
70542 } else if (graphicType === 'text') {
70543 el = new ZRText({}); // inner(el).customText = (elOption.style as TextStyleProps).text;
70544 } else if (graphicType === 'group') {
70545 el = new Group();
70546 } else if (graphicType === 'compoundPath') {
70547 throw new Error('"compoundPath" is not supported yet.');
70548 } else {
70549 var Clz = getShapeClass(graphicType);
70550
70551 if (!Clz) {
70552 var errMsg = '';
70553
70554 if ("development" !== 'production') {
70555 errMsg = 'graphic type "' + graphicType + '" can not be found.';
70556 }
70557
70558 throwError(errMsg);
70559 }
70560
70561 el = new Clz();
70562 }
70563
70564 inner$9(el).customGraphicType = graphicType;
70565 el.name = elOption.name; // Compat ec4: the default z2 lift is 1. If changing the number,
70566 // some cases probably be broken: hierarchy layout along z, like circle packing,
70567 // where emphasis only intending to modify color/border rather than lift z2.
70568
70569 el.z2EmphasisLift = 1;
70570 el.z2SelectLift = 1;
70571 return el;
70572 }
70573 /**
70574 * ----------------------------------------------------------
70575 * [STRATEGY_MERGE] Merge properties or erase all properties:

Callers 3

doCreateOrUpdateElFunction · 0.85
doCreateOrUpdateClipPathFunction · 0.85

Calls 4

makePathFunction · 0.85
getShapeClassFunction · 0.85
throwErrorFunction · 0.85
getPathDataFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…