{"record":{"id":"1eae092a69208ac4","repo":"iOfficeAI/OfficeCLI","slug":"chart-requires-a-data-property-use-data-serie","errorCode":null,"errorMessage":"Chart requires a 'data' property. Use: data=\"Series1:1,2,3;Series2:4,5,6\" or dataRange=\"Sheet1!A1:D5\" or series1=\"Revenue:100,200,300\"","messagePattern":"Chart requires a 'data' property\\. Use: data=\"Series1:1,2,3;Series2:4,5,6\" or dataRange=\"Sheet1!A1:D5\" or series1=\"Revenue:100,200,300\"","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Handlers/Excel/ExcelHandler.Add.Chart.cs","lineNumber":86,"sourceCode":"            // a numCache/strCache so the chart renders before the workbook is\n            // re-evaluated (the HTML preview plots only from that cache).\n            // Resolve the ranges against the worksheet now to backfill the\n            // literal values, mirroring ParseDataRangeForChart.\n            BackfillSeriesRangeValues(ref seriesData, ref categories, chartSheetName, properties);\n        }\n\n        if (seriesData.Count == 0)\n        {\n            // A supplied-but-consumed dataRange must not get the generic\n            // \"requires a data property\" message: with a single-column range\n            // and no explicit categories=, the sole column is reserved as\n            // the category column, leaving zero series — say so.\n            if (properties.ContainsKey(\"dataRange\") || properties.ContainsKey(\"datarange\"))\n                throw new ArgumentException(\n                    \"dataRange resolved to 0 series columns: a single-column range is consumed as the \" +\n                    \"category column by default. Pass categories= explicitly (e.g. categories=Sheet1!A1:A5) \" +\n                    \"to plot that column as a series, or widen the dataRange to include a values column.\");\n            throw new ArgumentException(\"Chart requires a 'data' property. Use: data=\\\"Series1:1,2,3;Series2:4,5,6\\\" \" +\n                \"or dataRange=\\\"Sheet1!A1:D5\\\" or series1=\\\"Revenue:100,200,300\\\"\");\n        }\n\n        // Validate the chart type BEFORE any part is created: an unknown type\n        // used to throw inside the builder AFTER the DrawingsPart and its\n        // sheet relationship were attached, leaving an orphaned empty\n        // <xdr:wsDr/> part behind on every failed attempt. Extended (cx)\n        // types — funnel/treemap/… — route through ChartExBuilder below and\n        // must not be run through the classic-type parser.\n        if (!ChartExBuilder.IsExtendedChartType(chartType))\n            ChartHelper.ParseChartType(chartType);\n\n        // Create DrawingsPart if needed\n        var drawingsPart = chartWorksheet.DrawingsPart\n            ?? chartWorksheet.AddNewPart<DrawingsPart>();\n\n        if (drawingsPart.WorksheetDrawing == null)\n        {","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Handlers/Excel/ExcelHandler.Add.Chart.cs#L68-L104","documentation":"Thrown when chart Add ends up with zero series and the user supplied neither a dataRange, a data= string, nor any seriesN= properties. This is the generic counterpart to error 520: the properties dictionary lacks every recognized series-input key, so seriesData is empty and no fallback data source exists.","triggerScenarios":"Calling chart Add with a chartType but none of: data, dataRange/datarange, series1, series2, etc. The inner if checks dataRange/datarange first; if that key is also absent, this generic message fires.","commonSituations":"User sets only cosmetic properties (title, type, anchor) and forgets the actual chart data. Also happens when property names are misspelled (e.g. 'data-set' instead of 'data') or when a script drops the data property conditionally.","solutions":["Add a data= property with inline series: data=\"Series1:1,2,3;Series2:4,5,6\".","Add a dataRange= property pointing to a multi-column cell range: dataRange=Sheet1!A1:D5.","Add one or more seriesN= properties: series1=\"Revenue:100,200,300\".","Verify the property key spelling matches exactly (data, dataRange, series1)."],"exampleFix":"// before\nadd /Sheet1/chart --type chart --chartType bar --title \"Sales\"\n// after\nadd /Sheet1/chart --type chart --chartType bar --title \"Sales\" --data \"Revenue:100,200,300;Cost:50,60,70\"","handlingStrategy":"validation","validationCode":"// Ensure at least one series-data source is present\nbool hasData = properties.ContainsKey(\"data\");\nbool hasRange = properties.ContainsKey(\"dataRange\") || properties.ContainsKey(\"datarange\");\nbool hasSeries = properties.Keys.Any(k => System.Text.RegularExpressions.Regex.IsMatch(k, @\"^series\\d+$\", RegexOptions.IgnoreCase));\nif (!hasData && !hasRange && !hasSeries)\n    throw new InvalidOperationException(\n        \"Chart requires a data source. Provide data=, dataRange=, or seriesN= properties.\");","typeGuard":null,"tryCatchPattern":"try { handler.AddChart(parentPath, type, position, properties); }\ncatch (ArgumentException ex) when (ex.Message.StartsWith(\"Chart requires a 'data' property\"))\n{\n    Console.Error.WriteLine(ex.Message);\n}","preventionTips":["Always include data=, dataRange=, or at least one seriesN= property in every chart-add call.","Build a pre-flight check that scans for recognized series-input keys.","Use a typed chart-options builder that enforces at least one data source at compile time."],"tags":["excel","chart","series","required-property","validation"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}