MCPcopy Index your code
hub / github.com/simstudioai/sim / extractSeriesColor

Function extractSeriesColor

apps/sim/lib/pptx-renderer/renderer/chart-renderer.ts:329–358  ·  view source on GitHub ↗

* Extract a series color from c:ser > c:spPr fill. * Supports solidFill and gradFill (converted to ECharts LinearGradient). * Also checks c:spPr > a:ln > a:solidFill as fallback (used by line/area charts).

(ser: SafeXmlNode, ctx: RenderContext)

Source from the content-addressed store, hash-verified

327 * Also checks c:spPr > a:ln > a:solidFill as fallback (used by line/area charts).
328 */
329function extractSeriesColor(ser: SafeXmlNode, ctx: RenderContext): string | object | undefined {
330 const spPr = ser.child('spPr')
331 if (!spPr.exists()) return undefined
332
333 // Primary: solid fill
334 const solidFill = spPr.child('solidFill')
335 if (solidFill.exists()) {
336 const hex = resolveColorToHex(solidFill, ctx)
337 if (hex) return hex
338 }
339
340 // Gradient fill → ECharts LinearGradient
341 const gradFill = spPr.child('gradFill')
342 if (gradFill.exists()) {
343 const grad = buildEChartsGradient(gradFill, ctx)
344 if (grad) return grad
345 }
346
347 // Fallback: line color (used by lineChart, areaChart series)
348 const ln = spPr.child('ln')
349 if (ln.exists()) {
350 const lnFill = ln.child('solidFill')
351 if (lnFill.exists()) {
352 const hex = resolveColorToHex(lnFill, ctx)
353 if (hex) return hex
354 }
355 }
356
357 return undefined
358}
359
360function extractSeriesLineWidth(ser: SafeXmlNode): number | undefined {
361 const lnWidthEmu = ser.child('spPr').child('ln').numAttr('w')

Callers 1

parseSeriesFunction · 0.85

Calls 4

resolveColorToHexFunction · 0.85
buildEChartsGradientFunction · 0.85
childMethod · 0.80
existsMethod · 0.80

Tested by

no test coverage detected