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

Function convertToEC4StyleForCustomSerise

src/util/styleCompat.ts:169–212  ·  view source on GitHub ↗
(
    itemStl: ItemStyleProps,
    txStl: TextStyleProps,
    txCfg: ElementTextConfig
)

Source from the content-addressed store, hash-verified

167 * `styleEmphasis: {textFill: 'red'}` will remove the normal auto added stroke.
168 */
169export function convertToEC4StyleForCustomSerise(
170 itemStl: ItemStyleProps,
171 txStl: TextStyleProps,
172 txCfg: ElementTextConfig
173): ZRStyleProps {
174
175 const out = itemStl as Dictionary<unknown>;
176
177 // See `custom.ts`, a trick to set extra `textPosition` firstly.
178 out.textPosition = out.textPosition || txCfg.position || 'inside';
179 txCfg.offset != null && (out.textOffset = txCfg.offset);
180 txCfg.rotation != null && (out.textRotation = txCfg.rotation);
181 txCfg.distance != null && (out.textDistance = txCfg.distance);
182
183 const isInside = (out.textPosition as string).indexOf('inside') >= 0;
184 const hostFill = itemStl.fill || tokens.color.neutral99;
185
186 convertToEC4RichItem(out, txStl);
187
188 const textFillNotSet = out.textFill == null;
189 if (isInside) {
190 if (textFillNotSet) {
191 out.textFill = txCfg.insideFill || tokens.color.neutral00;
192 !out.textStroke && txCfg.insideStroke && (out.textStroke = txCfg.insideStroke);
193 !out.textStroke && (out.textStroke = hostFill);
194 out.textStrokeWidth == null && (out.textStrokeWidth = 2);
195 }
196 }
197 else {
198 if (textFillNotSet) {
199 out.textFill = itemStl.fill || txCfg.outsideFill || tokens.color.neutral00;
200 }
201 !out.textStroke && txCfg.outsideStroke && (out.textStroke = txCfg.outsideStroke);
202 }
203
204 out.text = txStl.text;
205 out.rich = txStl.rich;
206
207 each(txStl.rich, function (richItem) {
208 convertToEC4RichItem(richItem as Dictionary<unknown>, richItem);
209 });
210
211 return out;
212}
213
214function convertToEC4RichItem(out: Dictionary<unknown>, richItem: TextStylePropsPart) {
215 if (!richItem) {

Callers 2

styleFunction · 0.90
styleEmphasisFunction · 0.90

Calls 2

convertToEC4RichItemFunction · 0.85
eachFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…