summaryrefslogtreecommitdiff
path: root/xmlChart.go
diff options
context:
space:
mode:
authorxuri <xuri.me@gmail.com>2022-09-29 22:00:21 +0800
committerxuri <xuri.me@gmail.com>2022-09-29 22:04:50 +0800
commit53a495563a2b9acf09ae45eae05d5f33aa242a87 (patch)
tree36ae707b1e38e755063aec7c13e878126a128c84 /xmlChart.go
parentefcf599dfe2ec25f10c4d55513a5648addfe989b (diff)
This closes #1358, made a refactor with breaking changes, see details:
This made a refactor with breaking changes: Motivation and Context When I decided to add set horizontal centered support for this library to resolve #1358, the reason I made this huge breaking change was: - There are too many exported types for set sheet view, properties, and format properties, although a function using the functional options pattern can be optimized by returning an anonymous function, these types or property set or get function has no binding categorization, so I change these functions like `SetAppProps` to accept a pointer of options structure. - Users can not easily find out which properties should be in the `SetSheetPrOptions` or `SetSheetFormatPr` categories - Nested properties cannot proceed modify easily Introduce 5 new export data types: `HeaderFooterOptions`, `PageLayoutMarginsOptions`, `PageLayoutOptions`, `SheetPropsOptions`, and `ViewOptions` Rename 4 exported data types: - Rename `PivotTableOption` to `PivotTableOptions` - Rename `FormatHeaderFooter` to `HeaderFooterOptions` - Rename `FormatSheetProtection` to `SheetProtectionOptions` - Rename `SparklineOption` to `SparklineOptions` Remove 54 exported types: `AutoPageBreaks`, `BaseColWidth`, `BlackAndWhite`, `CodeName`, `CustomHeight`, `Date1904`, `DefaultColWidth`, `DefaultGridColor`, `DefaultRowHeight`, `EnableFormatConditionsCalculation`, `FilterPrivacy`, `FirstPageNumber`, `FitToHeight`, `FitToPage`, `FitToWidth`, `OutlineSummaryBelow`, `PageLayoutOption`, `PageLayoutOptionPtr`, `PageLayoutOrientation`, `PageLayoutPaperSize`, `PageLayoutScale`, `PageMarginBottom`, `PageMarginFooter`, `PageMarginHeader`, `PageMarginLeft`, `PageMarginRight`, `PageMarginsOptions`, `PageMarginsOptionsPtr`, `PageMarginTop`, `Published`, `RightToLeft`, `SheetFormatPrOptions`, `SheetFormatPrOptionsPtr`, `SheetPrOption`, `SheetPrOptionPtr`, `SheetViewOption`, `SheetViewOptionPtr`, `ShowFormulas`, `ShowGridLines`, `ShowRowColHeaders`, `ShowRuler`, `ShowZeros`, `TabColorIndexed`, `TabColorRGB`, `TabColorTheme`, `TabColorTint`, `ThickBottom`, `ThickTop`, `TopLeftCell`, `View`, `WorkbookPrOption`, `WorkbookPrOptionPtr`, `ZeroHeight` and `ZoomScale` Remove 2 exported constants: `OrientationPortrait` and `OrientationLandscape` Change 8 functions: - Change the `func (f *File) SetPageLayout(sheet string, opts ...PageLayoutOption) error` to `func (f *File) SetPageLayout(sheet string, opts *PageLayoutOptions) error` - Change the `func (f *File) GetPageLayout(sheet string, opts ...PageLayoutOptionPtr) error` to `func (f *File) GetPageLayout(sheet string) (PageLayoutOptions, error)` - Change the `func (f *File) SetPageMargins(sheet string, opts ...PageMarginsOptions) error` to `func (f *File) SetPageMargins(sheet string, opts *PageLayoutMarginsOptions) error` - Change the `func (f *File) GetPageMargins(sheet string, opts ...PageMarginsOptionsPtr) error` to `func (f *File) GetPageMargins(sheet string) (PageLayoutMarginsOptions, error)` - Change the `func (f *File) SetSheetViewOptions(sheet string, viewIndex int, opts ...SheetViewOption) error` to `func (f *File) SetSheetView(sheet string, viewIndex int, opts *ViewOptions) error` - Change the `func (f *File) GetSheetViewOptions(sheet string, viewIndex int, opts ...SheetViewOptionPtr) error` to `func (f *File) GetSheetView(sheet string, viewIndex int) (ViewOptions, error)` - Change the `func (f *File) SetWorkbookPrOptions(opts ...WorkbookPrOption) error` to `func (f *File) SetWorkbookProps(opts *WorkbookPropsOptions) error` - Change the `func (f *File) GetWorkbookPrOptions(opts ...WorkbookPrOptionPtr) error` to `func (f *File) GetWorkbookProps() (WorkbookPropsOptions, error)` Introduce new function to instead of existing functions: - New function `func (f *File) SetSheetProps(sheet string, opts *SheetPropsOptions) error` instead of `func (f *File) SetSheetPrOptions(sheet string, opts ...SheetPrOption) error` and `func (f *File) SetSheetFormatPr(sheet string, opts ...SheetFormatPrOption
Diffstat (limited to 'xmlChart.go')
-rw-r--r--xmlChart.go73
1 files changed, 37 insertions, 36 deletions
diff --git a/xmlChart.go b/xmlChart.go
index dcd33e4..53755f3 100644
--- a/xmlChart.go
+++ b/xmlChart.go
@@ -518,8 +518,8 @@ type cPageMargins struct {
T float64 `xml:"t,attr"`
}
-// formatChartAxis directly maps the format settings of the chart axis.
-type formatChartAxis struct {
+// chartAxisOptions directly maps the format settings of the chart axis.
+type chartAxisOptions struct {
None bool `json:"none"`
Crossing string `json:"crossing"`
MajorGridlines bool `json:"major_grid_lines"`
@@ -543,26 +543,27 @@ type formatChartAxis struct {
Italic bool `json:"italic"`
Underline bool `json:"underline"`
} `json:"num_font"`
- LogBase float64 `json:"logbase"`
- NameLayout formatLayout `json:"name_layout"`
+ LogBase float64 `json:"logbase"`
+ NameLayout layoutOptions `json:"name_layout"`
}
-type formatChartDimension struct {
+// chartDimensionOptions directly maps the dimension of the chart.
+type chartDimensionOptions struct {
Width int `json:"width"`
Height int `json:"height"`
}
-// formatChart directly maps the format settings of the chart.
-type formatChart struct {
- Type string `json:"type"`
- Series []formatChartSeries `json:"series"`
- Format formatPicture `json:"format"`
- Dimension formatChartDimension `json:"dimension"`
- Legend formatChartLegend `json:"legend"`
- Title formatChartTitle `json:"title"`
- VaryColors bool `json:"vary_colors"`
- XAxis formatChartAxis `json:"x_axis"`
- YAxis formatChartAxis `json:"y_axis"`
+// chartOptions directly maps the format settings of the chart.
+type chartOptions struct {
+ Type string `json:"type"`
+ Series []chartSeriesOptions `json:"series"`
+ Format pictureOptions `json:"format"`
+ Dimension chartDimensionOptions `json:"dimension"`
+ Legend chartLegendOptions `json:"legend"`
+ Title chartTitleOptions `json:"title"`
+ VaryColors bool `json:"vary_colors"`
+ XAxis chartAxisOptions `json:"x_axis"`
+ YAxis chartAxisOptions `json:"y_axis"`
Chartarea struct {
Border struct {
None bool `json:"none"`
@@ -594,7 +595,7 @@ type formatChart struct {
Fill struct {
Color string `json:"color"`
} `json:"fill"`
- Layout formatLayout `json:"layout"`
+ Layout layoutOptions `json:"layout"`
} `json:"plotarea"`
ShowBlanksAs string `json:"show_blanks_as"`
ShowHiddenData bool `json:"show_hidden_data"`
@@ -603,19 +604,19 @@ type formatChart struct {
order int
}
-// formatChartLegend directly maps the format settings of the chart legend.
-type formatChartLegend struct {
- None bool `json:"none"`
- DeleteSeries []int `json:"delete_series"`
- Font Font `json:"font"`
- Layout formatLayout `json:"layout"`
- Position string `json:"position"`
- ShowLegendEntry bool `json:"show_legend_entry"`
- ShowLegendKey bool `json:"show_legend_key"`
+// chartLegendOptions directly maps the format settings of the chart legend.
+type chartLegendOptions struct {
+ None bool `json:"none"`
+ DeleteSeries []int `json:"delete_series"`
+ Font Font `json:"font"`
+ Layout layoutOptions `json:"layout"`
+ Position string `json:"position"`
+ ShowLegendEntry bool `json:"show_legend_entry"`
+ ShowLegendKey bool `json:"show_legend_key"`
}
-// formatChartSeries directly maps the format settings of the chart series.
-type formatChartSeries struct {
+// chartSeriesOptions directly maps the format settings of the chart series.
+type chartSeriesOptions struct {
Name string `json:"name"`
Categories string `json:"categories"`
Values string `json:"values"`
@@ -640,16 +641,16 @@ type formatChartSeries struct {
} `json:"marker"`
}
-// formatChartTitle directly maps the format settings of the chart title.
-type formatChartTitle struct {
- None bool `json:"none"`
- Name string `json:"name"`
- Overlay bool `json:"overlay"`
- Layout formatLayout `json:"layout"`
+// chartTitleOptions directly maps the format settings of the chart title.
+type chartTitleOptions struct {
+ None bool `json:"none"`
+ Name string `json:"name"`
+ Overlay bool `json:"overlay"`
+ Layout layoutOptions `json:"layout"`
}
-// formatLayout directly maps the format settings of the element layout.
-type formatLayout struct {
+// layoutOptions directly maps the format settings of the element layout.
+type layoutOptions struct {
X float64 `json:"x"`
Y float64 `json:"y"`
Width float64 `json:"width"`