* Build a chart color palette from theme accents and chart style id. * This improves parity with Office chart styles when series colors are implicit.
(chartXml: SafeXmlNode, ctx: RenderContext)
| 2540 | * This improves parity with Office chart styles when series colors are implicit. |
| 2541 | */ |
| 2542 | function buildChartPalette(chartXml: SafeXmlNode, ctx: RenderContext): string[] | undefined { |
| 2543 | const accents = ['accent1', 'accent2', 'accent3', 'accent4', 'accent5', 'accent6'] |
| 2544 | .map((k) => ctx.theme.colorScheme.get(k)) |
| 2545 | .filter((v): v is string => !!v) |
| 2546 | .map((hex) => (hex.startsWith('#') ? hex : `#${hex}`)) |
| 2547 | |
| 2548 | if (accents.length === 0) return undefined |
| 2549 | |
| 2550 | const styleId = parseChartStyleId(chartXml) |
| 2551 | if (styleId === undefined) return accents |
| 2552 | |
| 2553 | // Style ids 100+ use the same accent order as the base palette. |
| 2554 | // No rotation needed — OOXML chart styles control visual appearance |
| 2555 | // (e.g. 3D, transparency) but don't reorder series colors. |
| 2556 | return accents |
| 2557 | } |
| 2558 | |
| 2559 | // --------------------------------------------------------------------------- |
| 2560 | // Chart-Space Default Font Size + Legend Grid Adjustment |
no test coverage detected