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

Function createSymbol

src/util/symbol.ts:333–388  ·  view source on GitHub ↗
(
    symbolType: string,
    x: number,
    y: number,
    w: number,
    h: number,
    color?: ZRColor,
    // whether to keep the ratio of w/h,
    keepAspect?: boolean
)

Source from the content-addressed store, hash-verified

331 * Create a symbol element with given symbol configuration: shape, x, y, width, height, color
332 */
333export function createSymbol(
334 symbolType: string,
335 x: number,
336 y: number,
337 w: number,
338 h: number,
339 color?: ZRColor,
340 // whether to keep the ratio of w/h,
341 keepAspect?: boolean
342) {
343 // TODO Support image object, DynamicImage.
344
345 const isEmpty = symbolType.indexOf('empty') === 0;
346 if (isEmpty) {
347 symbolType = symbolType.substr(5, 1).toLowerCase() + symbolType.substr(6);
348 }
349 let symbolPath: ECSymbol | graphic.Image;
350
351 if (symbolType.indexOf('image://') === 0) {
352 symbolPath = graphic.makeImage(
353 symbolType.slice(8),
354 new BoundingRect(x, y, w, h),
355 keepAspect ? 'center' : 'cover'
356 );
357 }
358 else if (symbolType.indexOf('path://') === 0) {
359 symbolPath = graphic.makePath(
360 symbolType.slice(7),
361 {},
362 new BoundingRect(x, y, w, h),
363 keepAspect ? 'center' : 'cover'
364 ) as unknown as ECSymbol;
365 }
366 else {
367 symbolPath = new SymbolClz({
368 shape: {
369 symbolType: symbolType,
370 x: x,
371 y: y,
372 width: w,
373 height: h
374 }
375 }) as unknown as ECSymbol;
376 }
377
378 (symbolPath as ECSymbol).__isEmptyBrush = isEmpty;
379
380 // TODO Should deprecate setColor
381 (symbolPath as ECSymbol).setColor = symbolPathSetColor;
382
383 if (color) {
384 (symbolPath as ECSymbol).setColor(color);
385 }
386
387 return symbolPath as ECSymbol;
388}
389
390export function normalizeSymbolSize(symbolSize: number | number[]): [number, number] {

Callers 15

getLegendIconMethod · 0.90
_setCommonMethod · 0.90
startEffectAnimationMethod · 0.90
_createSymbolMethod · 0.90
_updateEffectSymbolMethod · 0.90
createPathFunction · 0.90
createPointerMethod · 0.90
_renderAnchorMethod · 0.90
getLegendIconMethod · 0.90
getDefaultLegendIconFunction · 0.90
giveSymbolFunction · 0.90
_createHandleMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…