MCPcopy Index your code
hub / github.com/apache/echarts / createOrUpdatePatternFromDecal

Function createOrUpdatePatternFromDecal

src/util/decal.ts:51–306  ·  view source on GitHub ↗
(
    decalObject: InnerDecalObject | 'none',
    api: ExtensionAPI
)

Source from the content-addressed store, hash-verified

49 * @return {Pattern} pattern with generated image, null if no decal
50 */
51export function createOrUpdatePatternFromDecal(
52 decalObject: InnerDecalObject | 'none',
53 api: ExtensionAPI
54): PatternObject {
55 if (decalObject === 'none') {
56 return null;
57 }
58
59 const dpr = api.getDevicePixelRatio();
60 const zr = api.getZr();
61 const isSVG = zr.painter.type === 'svg';
62
63 if (decalObject.dirty) {
64 decalMap.delete(decalObject);
65 }
66
67 const oldPattern = decalMap.get(decalObject);
68 if (oldPattern) {
69 return oldPattern;
70 }
71
72 const decalOpt = defaults(decalObject, {
73 symbol: 'rect',
74 symbolSize: 1,
75 symbolKeepAspect: true,
76 color: 'rgba(0, 0, 0, 0.2)',
77 backgroundColor: null,
78 dashArrayX: 5,
79 dashArrayY: 5,
80 rotation: 0,
81 maxTileWidth: 512,
82 maxTileHeight: 512
83 } as DecalObject);
84 if (decalOpt.backgroundColor === 'none') {
85 decalOpt.backgroundColor = null;
86 }
87
88 const pattern: PatternObject = { repeat: 'repeat' } as PatternObject;
89 setPatternnSource(pattern);
90 pattern.rotation = decalOpt.rotation;
91 pattern.scaleX = pattern.scaleY = isSVG ? 1 : 1 / dpr;
92
93 decalMap.set(decalObject, pattern);
94
95 decalObject.dirty = false;
96
97 return pattern;
98
99 function setPatternnSource(pattern: PatternObject) {
100 const keys = [dpr];
101 let isValidKey = true;
102 for (let i = 0; i < decalKeys.length; ++i) {
103 const value = (decalOpt as any)[decalKeys[i]];
104 if (value != null
105 && !isArray(value)
106 && !isString(value)
107 && !isNumber(value)
108 && typeof value !== 'boolean'

Callers 5

updateDataMethod · 0.90
updateElNormalFunction · 0.90
getLegendStyleFunction · 0.90
decalVisualFunction · 0.90

Calls 4

setPatternnSourceFunction · 0.85
getDevicePixelRatioMethod · 0.65
getZrMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…