Skip to content

Commit 221497c

Browse files
committed
fix(chart): align OOXML builder palette with SVG preview palette
ChartHelper.Builder.DefaultSeriesColors and ChartSvgRenderer.FallbackColors both held a 12-color default rotation but disagreed on slots 8/10/11/12 — the darker (lumMod=75%) tints of accents 2/4/5/6. The Builder values (9B4A22/BF8F00/3A75A8/4E8538) were near-but-wrong; the Renderer values (9E480E/997300/255E91/43682B) match Office's actual lumMod=75% derivation. Result: charts written with no explicit colors picked one palette while the in-app HTML preview drew the same series with a slightly different palette — a real visual drift. Both arrays now derive from a single canonical source on OfficeDefaultThemeColors.DefaultChartSeriesPalette.
1 parent d9aa77f commit 221497c

3 files changed

Lines changed: 27 additions & 9 deletions

File tree

src/officecli/Core/Chart/ChartHelper.Builder.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -820,11 +820,11 @@ internal static C.StockChart BuildStockChart(
820820

821821
// ==================== Default Series Colors ====================
822822

823+
// CONSISTENCY(chart-default-palette): canonical source is
824+
// OfficeDefaultThemeColors.DefaultChartSeriesPalette so the OOXML
825+
// builder and the SVG preview renderer cannot drift apart.
823826
internal static readonly string[] DefaultSeriesColors =
824-
{
825-
"4472C4", "ED7D31", "A5A5A5", "FFC000", "5B9BD5", "70AD47",
826-
"264478", "9B4A22", "636363", "BF8F00", "3A75A8", "4E8538"
827-
};
827+
OfficeDefaultThemeColors.DefaultChartSeriesPalette;
828828

829829
// ==================== Series Color ====================
830830

src/officecli/Core/Chart/ChartSvgRenderer.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ namespace OfficeCli.Core;
1717
/// </summary>
1818
internal partial class ChartSvgRenderer
1919
{
20-
// Fallback chart colors — used only when no theme is available
21-
public static readonly string[] FallbackColors = [
22-
"#4472C4", "#ED7D31", "#A5A5A5", "#FFC000", "#5B9BD5", "#70AD47",
23-
"#264478", "#9E480E", "#636363", "#997300", "#255E91", "#43682B"
24-
];
20+
// CONSISTENCY(chart-default-palette): canonical source is
21+
// OfficeDefaultThemeColors.DefaultChartSeriesPalette; SVG just needs
22+
// the '#'-prefixed form, so we derive once at static init.
23+
public static readonly string[] FallbackColors =
24+
OfficeDefaultThemeColors.DefaultChartSeriesPalette
25+
.Select(hex => "#" + hex)
26+
.ToArray();
2527

2628
/// <summary>
2729
/// Theme-derived accent colors for chart series. Set from document theme accent1-6.

src/officecli/Core/OfficeDefaultThemeColors.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,22 @@ public static class OfficeDefaultThemeColors
3333
public const string Hyperlink = "0563C1";
3434
public const string FollowedHyperlink = "954F72";
3535

36+
/// <summary>
37+
/// Default chart series color rotation when no <c>ColorScheme</c> is
38+
/// available. Slots 1-6 are the six accent colors; slots 7-12 are the
39+
/// same accents with <c>lumMod=75000</c> applied (the darker tints
40+
/// Office cycles through after exhausting the primary accents).
41+
///
42+
/// Hex values are 6-char OOXML format (no leading <c>#</c>). Both the
43+
/// OOXML chart Builder and the SVG preview Renderer derive from this
44+
/// array — keep them aligned to avoid the chart-vs-preview drift.
45+
/// </summary>
46+
public static readonly string[] DefaultChartSeriesPalette =
47+
{
48+
Accent1, Accent2, Accent3, Accent4, Accent5, Accent6,
49+
"264478", "9E480E", "636363", "997300", "255E91", "43682B",
50+
};
51+
3652
/// <summary>
3753
/// Builds a name→hex dictionary covering the canonical scheme keys plus
3854
/// the common aliases (dk1/tx1/text1, bg1/lt1/background1, …) that Word

0 commit comments

Comments
 (0)