iOfficeAI/OfficeCLI · error · ArgumentException
Unknown chart type: '{kind}'. Supported: column, bar, line,
Error message
Unknown chart type: '{kind}'. Supported: column, bar, line, pie, doughnut, area, scatter, bubble, radar, stock, combo, waterfall. Add 'stacked' or 'percentstacked' suffix for variants (e.g. columnstacked). What it means
The chart builder dispatches on a 'kind' string to construct the appropriate OOXML chart element (column, bar, line, pie, doughnut, area, scatter, bubble, radar, stock, combo, waterfall). Any unrecognized kind reaches the default arm and throws. Stacked/percentStacked suffixes are handled within specific chart-type arms (column, bar, line, area), not by this dispatch.
Source
Thrown at src/officecli/Core/Chart/ChartHelper.Builder.cs:382
int gi = 0;
while (gi < seriesData.Count)
{
var t = gi < comboTypes.Length ? comboTypes[gi] : "line";
int gj = gi + 1;
while (gj < seriesData.Count
&& gj < comboTypes.Length
&& comboTypes[gj] == t)
gj++;
BuildComboGroup(t, plotArea, seriesData, categories,
startIdx: gi, endIdxExclusive: gj,
catAxisId, valAxisId, colors, noFillSeries);
gi = gj;
}
chartElement = null;
break;
}
default:
throw new ArgumentException(
$"Unknown chart type: '{kind}'. Supported: column, bar, line, pie, doughnut, area, scatter, bubble, radar, stock, combo, waterfall. " +
"Add 'stacked' or 'percentstacked' suffix for variants (e.g. columnstacked).");
}
if (chartElement != null)
plotArea.AppendChild(chartElement);
if (needsAxes)
{
if (kind == "scatter")
{
plotArea.AppendChild(BuildValueAxis(catAxisId, valAxisId, C.AxisPositionValues.Bottom));
plotArea.AppendChild(BuildValueAxis(valAxisId, catAxisId, C.AxisPositionValues.Left));
}
else
{
plotArea.AppendChild(BuildCategoryAxis(catAxisId, valAxisId));
plotArea.AppendChild(BuildValueAxis(valAxisId, catAxisId, C.AxisPositionValues.Left));View on GitHub (pinned to 1ced45e900)
Solutions
- Use one of the supported types: column, bar, line, pie, doughnut, area, scatter, bubble, radar, stock, combo, waterfall.
- Append 'stacked' or 'percentstacked' for supported variants: columnstacked, barpercentstacked.
- Check spelling — the error message lists all valid types.
Example fix
// before kind: "colunm" // after kind: "column" // stacked variant kind: "columnstacked"
Defensive patterns
Strategy: validation
Validate before calling
static readonly HashSet<string> ValidChartTypes = new(StringComparer.OrdinalIgnoreCase)
{ "column", "bar", "line", "pie", "doughnut", "area", "scatter",
"bubble", "radar", "stock", "combo", "waterfall" };
static bool IsValidChartKind(string kind)
{
// Check base type (strip stacked/percentstacked suffix)
var baseKind = kind.EndsWith("percentstacked", StringComparison.OrdinalIgnoreCase)
? kind[..^14]
: kind.EndsWith("stacked", StringComparison.OrdinalIgnoreCase)
? kind[..^7] : kind;
return ValidChartTypes.Contains(baseKind);
} Try / catch
try { ChartHelper.BuildChart(kind, ...); }
catch (ArgumentException ex) when (ex.Message.StartsWith("Unknown chart type"))
{
Console.Error.WriteLine($"{ex.Message}");
} Prevention
- Validate the chart kind against the supported set before building.
- Check spelling carefully (column, not colunm; doughnut, not donut).
- Append stacked/percentstacked only to chart types that support variants.
When it happens
Trigger: Creating a chart with an unrecognized type string: kind='histogram', kind='treemap', kind='sunburst', kind='colum'. The kind is matched against the switch arms before any chart element is built.
Common situations: Misspelling a chart type ('colunm', 'dognut', 'watterfall'). Using a chart type supported by newer Excel versions but not by this library (histogram, treemap, funnel). Using an OOXML internal name instead of the friendly name (e.g. 'barChart' instead of 'bar').
Related errors
- Invalid comboTypes token '{t}'. Expected bar/column/line/are
- Invalid legend position '{posSpec}'. Valid: none, top, botto
- Invalid referenceLine value '{parts[0]}'. Expected: number o
- Invalid referenceLine width '{widthStr}'. Expected a number
- Invalid referenceLine width '{widthPt.ToString("G", System.G
AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13).
Data as JSON: /api/errors/1234227efcab8ef4.
Report an issue: GitHub.