From 42b1c8148883844cf80b70a3096e6ee67be01f61 Mon Sep 17 00:00:00 2001 From: "Huy Bui (Kevin)" <2992996+huybuidev@users.noreply.github.com> Date: Sat, 11 Jul 2020 01:07:41 +0800 Subject: Resolve #661 Add Logarithmic scale option support on Y axis (#662) * Resolve #661 Add Logarithmic scale option support on Y axis Example usage: Add the following option into the format string when using AddChart: "y_axis":{"scaling":{"logbase":"10"}} * Change type of LogBase from attrValString to attrVarFloat * Add test case for testing Logarithmic Option in Y axis of charts * Move field `LogBase` in the format string up one level (remove `Scaling`) as suggested the owner Test cases are updated accordingly. --- drawing.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'drawing.go') diff --git a/drawing.go b/drawing.go index ea75e82..3ce1282 100644 --- a/drawing.go +++ b/drawing.go @@ -1000,10 +1000,17 @@ func (f *File) drawPlotAreaValAx(formatSet *formatChart) []*cAxs { if formatSet.YAxis.Maximum == 0 { max = nil } + var logBase *attrValFloat + // Follow OOXML requirements on + // [https://github.com/sc34wg4/OOXMLSchemas/blob/2b074ca2c5df38b18ac118646b329b508b5bdecc/Part1/OfficeOpenXML-XMLSchema-Strict/dml-chart.xsd#L1142-L1147] + if formatSet.YAxis.LogBase >= 2 && formatSet.YAxis.LogBase <= 1000 { + logBase = &attrValFloat{Val: float64Ptr(formatSet.YAxis.LogBase)} + } axs := []*cAxs{ { AxID: &attrValInt{Val: intPtr(753999904)}, Scaling: &cScaling{ + LogBase: logBase, Orientation: &attrValString{Val: stringPtr(orientation[formatSet.YAxis.ReverseOrder])}, Max: max, Min: min, -- cgit v1.2.1