{"record":{"id":"2f89fbe7c479bef1","repo":"iOfficeAI/OfficeCLI","slug":"axismin-value-is-invalid-on-a-log-scaled-axis-a","errorCode":null,"errorMessage":"axisMin={value} is invalid on a log-scaled axis: a logarithmic axis minimum must be greater than 0.","messagePattern":"axisMin=(.+?) is invalid on a log-scaled axis: a logarithmic axis minimum must be greater than 0\\.","errorType":"validation","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/officecli/Core/Chart/ChartHelper.Setter.cs","lineNumber":1011,"sourceCode":"                            ?? (OpenXmlElement?)catAxis.GetFirstChild<C.MajorGridlines>()\n                            ?? catAxis.GetFirstChild<C.AxisPosition>();\n                        if (insertAfter != null) catAxis.InsertAfter(BuildChartTitle(value), insertAfter);\n                    }\n                    break;\n                }\n\n                case \"axismin\" or \"min\":\n                {\n                    var plotArea2 = chart.GetFirstChild<C.PlotArea>();\n                    var valAxis = plotArea2?.GetFirstChild<C.ValueAxis>();\n                    var scaling = valAxis?.GetFirstChild<C.Scaling>();\n                    if (scaling == null) { unsupported.Add(key); break; }\n                    var minVal = ParseHelpers.SafeParseDouble(value, \"axismin\");\n                    // A log-scaled axis cannot have min <= 0 — real Excel refuses\n                    // the file (0x800A03EC). Validate the combined state before\n                    // mutating.\n                    if (minVal <= 0 && scaling.GetFirstChild<C.LogBase>() != null)\n                        throw new ArgumentException(\n                            $\"axisMin={value} is invalid on a log-scaled axis: a logarithmic axis minimum must be greater than 0.\");\n                    scaling.RemoveAllChildren<C.MinAxisValue>();\n                    scaling.AppendChild(new C.MinAxisValue { Val = minVal });\n                    break;\n                }\n\n                case \"axismax\" or \"max\":\n                {\n                    var plotArea2 = chart.GetFirstChild<C.PlotArea>();\n                    var valAxis = plotArea2?.GetFirstChild<C.ValueAxis>();\n                    var scaling = valAxis?.GetFirstChild<C.Scaling>();\n                    if (scaling == null) { unsupported.Add(key); break; }\n                    scaling.RemoveAllChildren<C.MaxAxisValue>();\n                    var maxEl = new C.MaxAxisValue { Val = ParseHelpers.SafeParseDouble(value, \"axismax\") };\n                    // Schema order: logBase?, orientation, max?, min? — insert max after orientation\n                    var orient = scaling.GetFirstChild<C.Orientation>();\n                    if (orient != null) orient.InsertAfterSelf(maxEl);\n                    else scaling.PrependChild(maxEl);","sourceCodeStart":993,"sourceCodeEnd":1029,"githubUrl":"https://github.com/iOfficeAI/OfficeCLI/blob/1ced45e900782c5083ed550ddf328ee974e425e7/src/officecli/Core/Chart/ChartHelper.Setter.cs#L993-L1029","documentation":"Thrown when 'axisMin'/'min' is set to a value <= 0 on an axis that already has a C.LogBase child. A logarithmic axis cannot start at zero or a negative number — real Excel refuses the file with 0x800A03EC. The setter validates the combined axis state (value + presence of LogBase) before mutating C.Scaling.","triggerScenarios":"SetChartProperties with { [\"axisMin\"] = \"0\" } or a negative number on a chart whose value axis already carries logBase; or applying min= and logScale= in the same batch where min resolves first.","commonSituations":"Defaulting axis minimum to 0 on a template later switched to log scale; replaying a dump that captured min=0 before the log-scale flag was set; scientific/financial dashboards that auto-zero baselines.","solutions":["Set axisMin to a strictly positive value (> 0) when the axis is log-scaled.","If you do not need an explicit minimum on a log axis, omit axisMin entirely and let Excel auto-scale.","Order your batch so logScale is applied before min only if you intentionally want to clear min, but prefer a positive value regardless."],"exampleFix":"// before\nSetChartProperties(part, new() { [\"logScale\"] = \"true\", [\"axisMin\"] = \"0\" });\n// after\nSetChartProperties(part, new() { [\"logScale\"] = \"true\", [\"axisMin\"] = \"1\" });","handlingStrategy":"validation","validationCode":"static bool IsValidAxisMin(double min, bool isLogScale) =>\n    !double.IsNaN(min) && !double.IsInfinity(min) && (!isLogScale || min > 0);","typeGuard":"static bool IsLegalLogAxisMin(string val, bool logScale, out double min) =>\n    double.TryParse(val, NumberStyles.Float, CultureInfo.InvariantCulture, out min)\n    && (!logScale || min > 0);","tryCatchPattern":"try { SetChartProperties(part, props); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"log-scaled axis\"))\n{ /* drop axisMin or set it to a positive value and retry */ }","preventionTips":["Never default an axis minimum to 0 on templates that may be switched to log scale.","When toggling logScale in the same batch, set a positive axisMin or omit it.","Track per-axis log state so validation can see it before the Set call."],"tags":["ooxml","chart","input-validation","log-scale","axis","csharp"],"backgroundTag":null,"analyzedSha":"1ced45e900782c5083ed550ddf328ee974e425e7","analyzedAt":"2026-08-13T13:01:07.193Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}