From 5f3a4bc39f9cf2987104ffe57242a0526cdd9158 Mon Sep 17 00:00:00 2001 From: xuri Date: Wed, 25 Dec 2019 00:00:50 +0800 Subject: Fix #538, added setting a major unit and tick label skip support for the chart --- chart.go | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) (limited to 'chart.go') diff --git a/chart.go b/chart.go index 5a42c5b..b1446fb 100644 --- a/chart.go +++ b/chart.go @@ -653,10 +653,21 @@ func parseFormatChartSet(formatSet string) (*formatChart, error) { // // show_val: Specifies that the value shall be shown in a data label. The show_val property is optional. The default value is false. // -// Set the primary horizontal and vertical axis options by x_axis and y_axis. The properties that can be set are: +// Set the primary horizontal and vertical axis options by x_axis and y_axis. The properties of x_axis that can be set are: // // major_grid_lines // minor_grid_lines +// major_unit +// reverse_order +// maximum +// minimum +// +// The properties of y_axis that can be set are: +// +// major_grid_lines +// minor_grid_lines +// major_unit +// tick_label_skip // reverse_order // maximum // minimum @@ -665,6 +676,10 @@ func parseFormatChartSet(formatSet string) (*formatChart, error) { // // minor_grid_lines: Specifies minor gridlines. // +// major_unit: Specifies the distance between major ticks. Shall contain a positive floating-point number. The major_unit property is optional. The default value is auto. +// +// tick_label_skip: Specifies how many tick labels to skip between label that is drawn. The tick_label_skip property is optional. The default value is auto. +// // reverse_order: Specifies that the categories or values on reverse order (orientation of the chart). The reverse_order property is optional. The default value is false. // // maximum: Specifies that the fixed maximum, 0 is auto. The maximum property is optional. The default value is auto. @@ -1612,6 +1627,12 @@ func (f *File) drawPlotAreaCatAx(formatSet *formatChart) []*cAxs { if formatSet.XAxis.MinorGridlines { axs[0].MinorGridlines = &cChartLines{SpPr: f.drawPlotAreaSpPr()} } + if formatSet.XAxis.MajorUnit != 0 { + axs[0].MajorUnit = &attrValFloat{Val: float64Ptr(formatSet.XAxis.MajorUnit)} + } + if formatSet.XAxis.TickLabelSkip != 0 { + axs[0].TickLblSkip = &attrValInt{Val: intPtr(formatSet.XAxis.TickLabelSkip)} + } return axs } @@ -1658,6 +1679,9 @@ func (f *File) drawPlotAreaValAx(formatSet *formatChart) []*cAxs { if pos, ok := valTickLblPos[formatSet.Type]; ok { axs[0].TickLblPos.Val = stringPtr(pos) } + if formatSet.YAxis.MajorUnit != 0 { + axs[0].MajorUnit = &attrValFloat{Val: float64Ptr(formatSet.YAxis.MajorUnit)} + } return axs } -- cgit v1.2.1