Require using ChartType enumeration value to specify the chart type

- Update docs and unit tests
This commit is contained in:
xuri 2023-04-01 00:08:53 +08:00
parent 3b807c4bfe
commit 294f2e1480
No known key found for this signature in database
GPG Key ID: BA5E5BB1C948EDF7
7 changed files with 282 additions and 279 deletions

View File

@ -148,7 +148,7 @@ func main() {
f.SetSheetRow("Sheet1", cell, &row) f.SetSheetRow("Sheet1", cell, &row)
} }
if err := f.AddChart("Sheet1", "E1", &excelize.Chart{ if err := f.AddChart("Sheet1", "E1", &excelize.Chart{
Type: "col3DClustered", Type: excelize.Col3DClustered,
Series: []excelize.ChartSeries{ Series: []excelize.ChartSeries{
{ {
Name: "Sheet1!$A$2", Name: "Sheet1!$A$2",

View File

@ -148,7 +148,7 @@ func main() {
f.SetSheetRow("Sheet1", cell, &row) f.SetSheetRow("Sheet1", cell, &row)
} }
if err := f.AddChart("Sheet1", "E1", &excelize.Chart{ if err := f.AddChart("Sheet1", "E1", &excelize.Chart{
Type: "col3DClustered", Type: excelize.Col3DClustered,
Series: []excelize.ChartSeries{ Series: []excelize.ChartSeries{
{ {
Name: "Sheet1!$A$2", Name: "Sheet1!$A$2",

271
chart.go
View File

@ -18,68 +18,71 @@ import (
"strings" "strings"
) )
// This section defines the currently supported chart types. // ChartType is the type of supported chart types.
type ChartType byte
// This section defines the currently supported chart types enumeration.
const ( const (
Area = "area" Area ChartType = iota
AreaStacked = "areaStacked" AreaStacked
AreaPercentStacked = "areaPercentStacked" AreaPercentStacked
Area3D = "area3D" Area3D
Area3DStacked = "area3DStacked" Area3DStacked
Area3DPercentStacked = "area3DPercentStacked" Area3DPercentStacked
Bar = "bar" Bar
BarStacked = "barStacked" BarStacked
BarPercentStacked = "barPercentStacked" BarPercentStacked
Bar3DClustered = "bar3DClustered" Bar3DClustered
Bar3DStacked = "bar3DStacked" Bar3DStacked
Bar3DPercentStacked = "bar3DPercentStacked" Bar3DPercentStacked
Bar3DConeClustered = "bar3DConeClustered" Bar3DConeClustered
Bar3DConeStacked = "bar3DConeStacked" Bar3DConeStacked
Bar3DConePercentStacked = "bar3DConePercentStacked" Bar3DConePercentStacked
Bar3DPyramidClustered = "bar3DPyramidClustered" Bar3DPyramidClustered
Bar3DPyramidStacked = "bar3DPyramidStacked" Bar3DPyramidStacked
Bar3DPyramidPercentStacked = "bar3DPyramidPercentStacked" Bar3DPyramidPercentStacked
Bar3DCylinderClustered = "bar3DCylinderClustered" Bar3DCylinderClustered
Bar3DCylinderStacked = "bar3DCylinderStacked" Bar3DCylinderStacked
Bar3DCylinderPercentStacked = "bar3DCylinderPercentStacked" Bar3DCylinderPercentStacked
Col = "col" Col
ColStacked = "colStacked" ColStacked
ColPercentStacked = "colPercentStacked" ColPercentStacked
Col3D = "col3D" Col3D
Col3DClustered = "col3DClustered" Col3DClustered
Col3DStacked = "col3DStacked" Col3DStacked
Col3DPercentStacked = "col3DPercentStacked" Col3DPercentStacked
Col3DCone = "col3DCone" Col3DCone
Col3DConeClustered = "col3DConeClustered" Col3DConeClustered
Col3DConeStacked = "col3DConeStacked" Col3DConeStacked
Col3DConePercentStacked = "col3DConePercentStacked" Col3DConePercentStacked
Col3DPyramid = "col3DPyramid" Col3DPyramid
Col3DPyramidClustered = "col3DPyramidClustered" Col3DPyramidClustered
Col3DPyramidStacked = "col3DPyramidStacked" Col3DPyramidStacked
Col3DPyramidPercentStacked = "col3DPyramidPercentStacked" Col3DPyramidPercentStacked
Col3DCylinder = "col3DCylinder" Col3DCylinder
Col3DCylinderClustered = "col3DCylinderClustered" Col3DCylinderClustered
Col3DCylinderStacked = "col3DCylinderStacked" Col3DCylinderStacked
Col3DCylinderPercentStacked = "col3DCylinderPercentStacked" Col3DCylinderPercentStacked
Doughnut = "doughnut" Doughnut
Line = "line" Line
Line3D = "line3D" Line3D
Pie = "pie" Pie
Pie3D = "pie3D" Pie3D
PieOfPieChart = "pieOfPie" PieOfPie
BarOfPieChart = "barOfPie" BarOfPie
Radar = "radar" Radar
Scatter = "scatter" Scatter
Surface3D = "surface3D" Surface3D
WireframeSurface3D = "wireframeSurface3D" WireframeSurface3D
Contour = "contour" Contour
WireframeContour = "wireframeContour" WireframeContour
Bubble = "bubble" Bubble
Bubble3D = "bubble3D" Bubble3D
) )
// This section defines the default value of chart properties. // This section defines the default value of chart properties.
var ( var (
chartView3DRotX = map[string]int{ chartView3DRotX = map[ChartType]int{
Area: 0, Area: 0,
AreaStacked: 0, AreaStacked: 0,
AreaPercentStacked: 0, AreaPercentStacked: 0,
@ -125,8 +128,8 @@ var (
Line3D: 20, Line3D: 20,
Pie: 0, Pie: 0,
Pie3D: 30, Pie3D: 30,
PieOfPieChart: 0, PieOfPie: 0,
BarOfPieChart: 0, BarOfPie: 0,
Radar: 0, Radar: 0,
Scatter: 0, Scatter: 0,
Surface3D: 15, Surface3D: 15,
@ -134,7 +137,7 @@ var (
Contour: 90, Contour: 90,
WireframeContour: 90, WireframeContour: 90,
} }
chartView3DRotY = map[string]int{ chartView3DRotY = map[ChartType]int{
Area: 0, Area: 0,
AreaStacked: 0, AreaStacked: 0,
AreaPercentStacked: 0, AreaPercentStacked: 0,
@ -180,8 +183,8 @@ var (
Line3D: 15, Line3D: 15,
Pie: 0, Pie: 0,
Pie3D: 0, Pie3D: 0,
PieOfPieChart: 0, PieOfPie: 0,
BarOfPieChart: 0, BarOfPie: 0,
Radar: 0, Radar: 0,
Scatter: 0, Scatter: 0,
Surface3D: 20, Surface3D: 20,
@ -189,18 +192,18 @@ var (
Contour: 0, Contour: 0,
WireframeContour: 0, WireframeContour: 0,
} }
plotAreaChartOverlap = map[string]int{ plotAreaChartOverlap = map[ChartType]int{
BarStacked: 100, BarStacked: 100,
BarPercentStacked: 100, BarPercentStacked: 100,
ColStacked: 100, ColStacked: 100,
ColPercentStacked: 100, ColPercentStacked: 100,
} }
chartView3DPerspective = map[string]int{ chartView3DPerspective = map[ChartType]int{
Line3D: 30, Line3D: 30,
Contour: 0, Contour: 0,
WireframeContour: 0, WireframeContour: 0,
} }
chartView3DRAngAx = map[string]int{ chartView3DRAngAx = map[ChartType]int{
Area: 0, Area: 0,
AreaStacked: 0, AreaStacked: 0,
AreaPercentStacked: 0, AreaPercentStacked: 0,
@ -246,8 +249,8 @@ var (
Line3D: 0, Line3D: 0,
Pie: 0, Pie: 0,
Pie3D: 0, Pie3D: 0,
PieOfPieChart: 0, PieOfPie: 0,
BarOfPieChart: 0, BarOfPie: 0,
Radar: 0, Radar: 0,
Scatter: 0, Scatter: 0,
Surface3D: 0, Surface3D: 0,
@ -263,7 +266,7 @@ var (
"top": "t", "top": "t",
"top_right": "tr", "top_right": "tr",
} }
chartValAxNumFmtFormatCode = map[string]string{ chartValAxNumFmtFormatCode = map[ChartType]string{
Area: "General", Area: "General",
AreaStacked: "General", AreaStacked: "General",
AreaPercentStacked: "0%", AreaPercentStacked: "0%",
@ -309,8 +312,8 @@ var (
Line3D: "General", Line3D: "General",
Pie: "General", Pie: "General",
Pie3D: "General", Pie3D: "General",
PieOfPieChart: "General", PieOfPie: "General",
BarOfPieChart: "General", BarOfPie: "General",
Radar: "General", Radar: "General",
Scatter: "General", Scatter: "General",
Surface3D: "General", Surface3D: "General",
@ -320,7 +323,7 @@ var (
Bubble: "General", Bubble: "General",
Bubble3D: "General", Bubble3D: "General",
} }
chartValAxCrossBetween = map[string]string{ chartValAxCrossBetween = map[ChartType]string{
Area: "midCat", Area: "midCat",
AreaStacked: "midCat", AreaStacked: "midCat",
AreaPercentStacked: "midCat", AreaPercentStacked: "midCat",
@ -366,8 +369,8 @@ var (
Line3D: "between", Line3D: "between",
Pie: "between", Pie: "between",
Pie3D: "between", Pie3D: "between",
PieOfPieChart: "between", PieOfPie: "between",
BarOfPieChart: "between", BarOfPie: "between",
Radar: "between", Radar: "between",
Scatter: "between", Scatter: "between",
Surface3D: "midCat", Surface3D: "midCat",
@ -377,7 +380,7 @@ var (
Bubble: "midCat", Bubble: "midCat",
Bubble3D: "midCat", Bubble3D: "midCat",
} }
plotAreaChartGrouping = map[string]string{ plotAreaChartGrouping = map[ChartType]string{
Area: "standard", Area: "standard",
AreaStacked: "stacked", AreaStacked: "stacked",
AreaPercentStacked: "percentStacked", AreaPercentStacked: "percentStacked",
@ -421,7 +424,7 @@ var (
Line: "standard", Line: "standard",
Line3D: "standard", Line3D: "standard",
} }
plotAreaChartBarDir = map[string]string{ plotAreaChartBarDir = map[ChartType]string{
Bar: "bar", Bar: "bar",
BarStacked: "bar", BarStacked: "bar",
BarPercentStacked: "bar", BarPercentStacked: "bar",
@ -471,7 +474,7 @@ var (
true: "r", true: "r",
false: "l", false: "l",
} }
valTickLblPos = map[string]string{ valTickLblPos = map[ChartType]string{
Contour: "none", Contour: "none",
WireframeContour: "none", WireframeContour: "none",
} }
@ -548,7 +551,7 @@ func parseChartOptions(opts *Chart) (*Chart, error) {
// f.SetSheetRow("Sheet1", cell, &row) // f.SetSheetRow("Sheet1", cell, &row)
// } // }
// if err := f.AddChart("Sheet1", "E1", &excelize.Chart{ // if err := f.AddChart("Sheet1", "E1", &excelize.Chart{
// Type: "col3DClustered", // Type: excelize.Col3DClustered,
// Series: []excelize.ChartSeries{ // Series: []excelize.ChartSeries{
// { // {
// Name: "Sheet1!$A$2", // Name: "Sheet1!$A$2",
@ -592,63 +595,63 @@ func parseChartOptions(opts *Chart) (*Chart, error) {
// //
// The following shows the type of chart supported by excelize: // The following shows the type of chart supported by excelize:
// //
// Type | Chart // ID | Enumeration | Chart
// -----------------------------+------------------------------ // ----+-----------------------------+------------------------------
// area | 2D area chart // 0 | Area | 2D area chart
// areaStacked | 2D stacked area chart // 1 | AreaStacked | 2D stacked area chart
// areaPercentStacked | 2D 100% stacked area chart // 2 | AreaPercentStacked | 2D 100% stacked area chart
// area3D | 3D area chart // 3 | Area3D | 3D area chart
// area3DStacked | 3D stacked area chart // 4 | Area3DStacked | 3D stacked area chart
// area3DPercentStacked | 3D 100% stacked area chart // 5 | Area3DPercentStacked | 3D 100% stacked area chart
// bar | 2D clustered bar chart // 6 | Bar | 2D clustered bar chart
// barStacked | 2D stacked bar chart // 7 | BarStacked | 2D stacked bar chart
// barPercentStacked | 2D 100% stacked bar chart // 8 | BarPercentStacked | 2D 100% stacked bar chart
// bar3DClustered | 3D clustered bar chart // 9 | Bar3DClustered | 3D clustered bar chart
// bar3DStacked | 3D stacked bar chart // 10 | Bar3DStacked | 3D stacked bar chart
// bar3DPercentStacked | 3D 100% stacked bar chart // 11 | Bar3DPercentStacked | 3D 100% stacked bar chart
// bar3DConeClustered | 3D cone clustered bar chart // 12 | Bar3DConeClustered | 3D cone clustered bar chart
// bar3DConeStacked | 3D cone stacked bar chart // 13 | Bar3DConeStacked | 3D cone stacked bar chart
// bar3DConePercentStacked | 3D cone percent bar chart // 14 | Bar3DConePercentStacked | 3D cone percent bar chart
// bar3DPyramidClustered | 3D pyramid clustered bar chart // 15 | Bar3DPyramidClustered | 3D pyramid clustered bar chart
// bar3DPyramidStacked | 3D pyramid stacked bar chart // 16 | Bar3DPyramidStacked | 3D pyramid stacked bar chart
// bar3DPyramidPercentStacked | 3D pyramid percent stacked bar chart // 17 | Bar3DPyramidPercentStacked | 3D pyramid percent stacked bar chart
// bar3DCylinderClustered | 3D cylinder clustered bar chart // 18 | Bar3DCylinderClustered | 3D cylinder clustered bar chart
// bar3DCylinderStacked | 3D cylinder stacked bar chart // 19 | Bar3DCylinderStacked | 3D cylinder stacked bar chart
// bar3DCylinderPercentStacked | 3D cylinder percent stacked bar chart // 20 | Bar3DCylinderPercentStacked | 3D cylinder percent stacked bar chart
// col | 2D clustered column chart // 21 | Col | 2D clustered column chart
// colStacked | 2D stacked column chart // 22 | ColStacked | 2D stacked column chart
// colPercentStacked | 2D 100% stacked column chart // 23 | ColPercentStacked | 2D 100% stacked column chart
// col3DClustered | 3D clustered column chart // 24 | Col3DClustered | 3D clustered column chart
// col3D | 3D column chart // 25 | Col3D | 3D column chart
// col3DStacked | 3D stacked column chart // 26 | Col3DStacked | 3D stacked column chart
// col3DPercentStacked | 3D 100% stacked column chart // 27 | Col3DPercentStacked | 3D 100% stacked column chart
// col3DCone | 3D cone column chart // 28 | Col3DCone | 3D cone column chart
// col3DConeClustered | 3D cone clustered column chart // 29 | Col3DConeClustered | 3D cone clustered column chart
// col3DConeStacked | 3D cone stacked column chart // 30 | Col3DConeStacked | 3D cone stacked column chart
// col3DConePercentStacked | 3D cone percent stacked column chart // 31 | Col3DConePercentStacked | 3D cone percent stacked column chart
// col3DPyramid | 3D pyramid column chart // 32 | Col3DPyramid | 3D pyramid column chart
// col3DPyramidClustered | 3D pyramid clustered column chart // 33 | Col3DPyramidClustered | 3D pyramid clustered column chart
// col3DPyramidStacked | 3D pyramid stacked column chart // 34 | Col3DPyramidStacked | 3D pyramid stacked column chart
// col3DPyramidPercentStacked | 3D pyramid percent stacked column chart // 35 | Col3DPyramidPercentStacked | 3D pyramid percent stacked column chart
// col3DCylinder | 3D cylinder column chart // 36 | Col3DCylinder | 3D cylinder column chart
// col3DCylinderClustered | 3D cylinder clustered column chart // 37 | Col3DCylinderClustered | 3D cylinder clustered column chart
// col3DCylinderStacked | 3D cylinder stacked column chart // 38 | Col3DCylinderStacked | 3D cylinder stacked column chart
// col3DCylinderPercentStacked | 3D cylinder percent stacked column chart // 39 | Col3DCylinderPercentStacked | 3D cylinder percent stacked column chart
// doughnut | doughnut chart // 40 | Doughnut | doughnut chart
// line | line chart // 41 | Line | line chart
// line3D | 3D line chart // 42 | Line3D | 3D line chart
// pie | pie chart // 43 | Pie | pie chart
// pie3D | 3D pie chart // 44 | Pie3D | 3D pie chart
// pieOfPie | pie of pie chart // 45 | PieOfPie | pie of pie chart
// barOfPie | bar of pie chart // 46 | BarOfPie | bar of pie chart
// radar | radar chart // 47 | Radar | radar chart
// scatter | scatter chart // 48 | Scatter | scatter chart
// surface3D | 3D surface chart // 49 | Surface3D | 3D surface chart
// wireframeSurface3D | 3D wireframe surface chart // 50 | WireframeSurface3D | 3D wireframe surface chart
// contour | contour chart // 51 | Contour | contour chart
// wireframeContour | wireframe contour chart // 52 | WireframeContour | wireframe contour chart
// bubble | bubble chart // 53 | Bubble | bubble chart
// bubble3D | 3D bubble chart // 54 | Bubble3D | 3D bubble chart
// //
// In Excel a chart series is a collection of information that defines which // In Excel a chart series is a collection of information that defines which
// data is plotted such as values, axis labels and formatting. // data is plotted such as values, axis labels and formatting.

View File

@ -42,7 +42,7 @@ func TestChartSize(t *testing.T) {
} }
assert.NoError(t, f.AddChart("Sheet1", "E4", &Chart{ assert.NoError(t, f.AddChart("Sheet1", "E4", &Chart{
Type: "col3DClustered", Type: Col3DClustered,
Dimension: ChartDimension{ Dimension: ChartDimension{
Width: 640, Width: 640,
Height: 480, Height: 480,
@ -200,106 +200,106 @@ func TestAddChart(t *testing.T) {
sheetName, cell string sheetName, cell string
opts *Chart opts *Chart
}{ }{
{sheetName: "Sheet1", cell: "P1", opts: &Chart{Type: "col", Series: series, Format: format, Legend: ChartLegend{Position: "none", ShowLegendKey: true}, Title: ChartTitle{Name: "2D Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{Font: Font{Bold: true, Italic: true, Underline: "dbl", Color: "000000"}}, YAxis: ChartAxis{Font: Font{Bold: false, Italic: false, Underline: "sng", Color: "777777"}}}}, {sheetName: "Sheet1", cell: "P1", opts: &Chart{Type: Col, Series: series, Format: format, Legend: ChartLegend{Position: "none", ShowLegendKey: true}, Title: ChartTitle{Name: "2D Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{Font: Font{Bold: true, Italic: true, Underline: "dbl", Color: "000000"}}, YAxis: ChartAxis{Font: Font{Bold: false, Italic: false, Underline: "sng", Color: "777777"}}}},
{sheetName: "Sheet1", cell: "X1", opts: &Chart{Type: "colStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D Stacked Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet1", cell: "X1", opts: &Chart{Type: ColStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D Stacked Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet1", cell: "P16", opts: &Chart{Type: "colPercentStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "100% Stacked Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet1", cell: "P16", opts: &Chart{Type: ColPercentStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "100% Stacked Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet1", cell: "X16", opts: &Chart{Type: "col3DClustered", Series: series, Format: format, Legend: ChartLegend{Position: "bottom", ShowLegendKey: false}, Title: ChartTitle{Name: "3D Clustered Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet1", cell: "X16", opts: &Chart{Type: Col3DClustered, Series: series, Format: format, Legend: ChartLegend{Position: "bottom", ShowLegendKey: false}, Title: ChartTitle{Name: "3D Clustered Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet1", cell: "P30", opts: &Chart{Type: "col3DStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Stacked Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet1", cell: "P30", opts: &Chart{Type: Col3DStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Stacked Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet1", cell: "X30", opts: &Chart{Type: "col3DPercentStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D 100% Stacked Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet1", cell: "X30", opts: &Chart{Type: Col3DPercentStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D 100% Stacked Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet1", cell: "X45", opts: &Chart{Type: "radar", Series: series, Format: format, Legend: ChartLegend{Position: "top_right", ShowLegendKey: false}, Title: ChartTitle{Name: "Radar Chart"}, PlotArea: plotArea, ShowBlanksAs: "span"}}, {sheetName: "Sheet1", cell: "X45", opts: &Chart{Type: Radar, Series: series, Format: format, Legend: ChartLegend{Position: "top_right", ShowLegendKey: false}, Title: ChartTitle{Name: "Radar Chart"}, PlotArea: plotArea, ShowBlanksAs: "span"}},
{sheetName: "Sheet1", cell: "AF1", opts: &Chart{Type: "col3DConeStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Cone Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet1", cell: "AF1", opts: &Chart{Type: Col3DConeStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Cone Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet1", cell: "AF16", opts: &Chart{Type: "col3DConeClustered", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Cone Clustered Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet1", cell: "AF16", opts: &Chart{Type: Col3DConeClustered, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Cone Clustered Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet1", cell: "AF30", opts: &Chart{Type: "col3DConePercentStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Cone Percent Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet1", cell: "AF30", opts: &Chart{Type: Col3DConePercentStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Cone Percent Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet1", cell: "AF45", opts: &Chart{Type: "col3DCone", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Cone Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet1", cell: "AF45", opts: &Chart{Type: Col3DCone, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Cone Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet1", cell: "AN1", opts: &Chart{Type: "col3DPyramidStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Pyramid Percent Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet1", cell: "AN1", opts: &Chart{Type: Col3DPyramidStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Pyramid Percent Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet1", cell: "AN16", opts: &Chart{Type: "col3DPyramidClustered", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Pyramid Clustered Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet1", cell: "AN16", opts: &Chart{Type: Col3DPyramidClustered, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Pyramid Clustered Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet1", cell: "AN30", opts: &Chart{Type: "col3DPyramidPercentStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Pyramid Percent Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet1", cell: "AN30", opts: &Chart{Type: Col3DPyramidPercentStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Pyramid Percent Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet1", cell: "AN45", opts: &Chart{Type: "col3DPyramid", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Pyramid Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet1", cell: "AN45", opts: &Chart{Type: Col3DPyramid, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Pyramid Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet1", cell: "AV1", opts: &Chart{Type: "col3DCylinderStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Cylinder Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet1", cell: "AV1", opts: &Chart{Type: Col3DCylinderStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Cylinder Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet1", cell: "AV16", opts: &Chart{Type: "col3DCylinderClustered", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Cylinder Clustered Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet1", cell: "AV16", opts: &Chart{Type: Col3DCylinderClustered, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Cylinder Clustered Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet1", cell: "AV30", opts: &Chart{Type: "col3DCylinderPercentStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Cylinder Percent Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet1", cell: "AV30", opts: &Chart{Type: Col3DCylinderPercentStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Cylinder Percent Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet1", cell: "AV45", opts: &Chart{Type: "col3DCylinder", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Cylinder Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet1", cell: "AV45", opts: &Chart{Type: Col3DCylinder, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Cylinder Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet1", cell: "P45", opts: &Chart{Type: "col3D", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet1", cell: "P45", opts: &Chart{Type: Col3D, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "P1", opts: &Chart{Type: "line3D", Series: series2, Format: format, Legend: ChartLegend{Position: "top", ShowLegendKey: false}, Title: ChartTitle{Name: "3D Line Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{MajorGridLines: true, MinorGridLines: true, TickLabelSkip: 1, NumFmt: ChartNumFmt{CustomNumFmt: "General"}}, YAxis: ChartAxis{MajorGridLines: true, MinorGridLines: true, MajorUnit: 1, NumFmt: ChartNumFmt{CustomNumFmt: "General"}}}}, {sheetName: "Sheet2", cell: "P1", opts: &Chart{Type: Line3D, Series: series2, Format: format, Legend: ChartLegend{Position: "top", ShowLegendKey: false}, Title: ChartTitle{Name: "3D Line Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{MajorGridLines: true, MinorGridLines: true, TickLabelSkip: 1, NumFmt: ChartNumFmt{CustomNumFmt: "General"}}, YAxis: ChartAxis{MajorGridLines: true, MinorGridLines: true, MajorUnit: 1, NumFmt: ChartNumFmt{CustomNumFmt: "General"}}}},
{sheetName: "Sheet2", cell: "X1", opts: &Chart{Type: "scatter", Series: series, Format: format, Legend: ChartLegend{Position: "bottom", ShowLegendKey: false}, Title: ChartTitle{Name: "Scatter Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "X1", opts: &Chart{Type: Scatter, Series: series, Format: format, Legend: ChartLegend{Position: "bottom", ShowLegendKey: false}, Title: ChartTitle{Name: "Scatter Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "P16", opts: &Chart{Type: "doughnut", Series: series3, Format: format, Legend: ChartLegend{Position: "right", ShowLegendKey: false}, Title: ChartTitle{Name: "Doughnut Chart"}, PlotArea: ChartPlotArea{ShowBubbleSize: false, ShowCatName: false, ShowLeaderLines: false, ShowPercent: true, ShowSerName: false, ShowVal: false}, ShowBlanksAs: "zero", HoleSize: 30}}, {sheetName: "Sheet2", cell: "P16", opts: &Chart{Type: Doughnut, Series: series3, Format: format, Legend: ChartLegend{Position: "right", ShowLegendKey: false}, Title: ChartTitle{Name: "Doughnut Chart"}, PlotArea: ChartPlotArea{ShowBubbleSize: false, ShowCatName: false, ShowLeaderLines: false, ShowPercent: true, ShowSerName: false, ShowVal: false}, ShowBlanksAs: "zero", HoleSize: 30}},
{sheetName: "Sheet2", cell: "X16", opts: &Chart{Type: "line", Series: series2, Format: format, Legend: ChartLegend{Position: "top", ShowLegendKey: false}, Title: ChartTitle{Name: "Line Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{MajorGridLines: true, MinorGridLines: true, TickLabelSkip: 1}, YAxis: ChartAxis{MajorGridLines: true, MinorGridLines: true, MajorUnit: 1}}}, {sheetName: "Sheet2", cell: "X16", opts: &Chart{Type: Line, Series: series2, Format: format, Legend: ChartLegend{Position: "top", ShowLegendKey: false}, Title: ChartTitle{Name: "Line Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{MajorGridLines: true, MinorGridLines: true, TickLabelSkip: 1}, YAxis: ChartAxis{MajorGridLines: true, MinorGridLines: true, MajorUnit: 1}}},
{sheetName: "Sheet2", cell: "P32", opts: &Chart{Type: "pie3D", Series: series3, Format: format, Legend: ChartLegend{Position: "bottom", ShowLegendKey: false}, Title: ChartTitle{Name: "3D Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "P32", opts: &Chart{Type: Pie3D, Series: series3, Format: format, Legend: ChartLegend{Position: "bottom", ShowLegendKey: false}, Title: ChartTitle{Name: "3D Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "X32", opts: &Chart{Type: "pie", Series: series3, Format: format, Legend: ChartLegend{Position: "bottom", ShowLegendKey: false}, Title: ChartTitle{Name: "Pie Chart"}, PlotArea: ChartPlotArea{ShowBubbleSize: true, ShowCatName: false, ShowLeaderLines: false, ShowPercent: true, ShowSerName: false, ShowVal: false, NumFmt: ChartNumFmt{CustomNumFmt: "0.00%;0;;"}}, ShowBlanksAs: "gap"}}, {sheetName: "Sheet2", cell: "X32", opts: &Chart{Type: Pie, Series: series3, Format: format, Legend: ChartLegend{Position: "bottom", ShowLegendKey: false}, Title: ChartTitle{Name: "Pie Chart"}, PlotArea: ChartPlotArea{ShowBubbleSize: true, ShowCatName: false, ShowLeaderLines: false, ShowPercent: true, ShowSerName: false, ShowVal: false, NumFmt: ChartNumFmt{CustomNumFmt: "0.00%;0;;"}}, ShowBlanksAs: "gap"}},
// bar series chart // bar series chart
{sheetName: "Sheet2", cell: "P48", opts: &Chart{Type: "bar", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D Clustered Bar Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "P48", opts: &Chart{Type: Bar, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D Clustered Bar Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "X48", opts: &Chart{Type: "barStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D Stacked Bar Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "X48", opts: &Chart{Type: BarStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D Stacked Bar Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "P64", opts: &Chart{Type: "barPercentStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D Stacked 100% Bar Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "P64", opts: &Chart{Type: BarPercentStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D Stacked 100% Bar Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "X64", opts: &Chart{Type: "bar3DClustered", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Clustered Bar Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "X64", opts: &Chart{Type: Bar3DClustered, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Clustered Bar Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "P80", opts: &Chart{Type: "bar3DStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Stacked Bar Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", YAxis: ChartAxis{Maximum: &maximum, Minimum: &minimum}}}, {sheetName: "Sheet2", cell: "P80", opts: &Chart{Type: Bar3DStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Stacked Bar Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", YAxis: ChartAxis{Maximum: &maximum, Minimum: &minimum}}},
{sheetName: "Sheet2", cell: "X80", opts: &Chart{Type: "bar3DPercentStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D 100% Stacked Bar Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{ReverseOrder: true, Minimum: &zero}, YAxis: ChartAxis{ReverseOrder: true, Minimum: &zero}}}, {sheetName: "Sheet2", cell: "X80", opts: &Chart{Type: Bar3DPercentStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D 100% Stacked Bar Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{ReverseOrder: true, Minimum: &zero}, YAxis: ChartAxis{ReverseOrder: true, Minimum: &zero}}},
// area series chart // area series chart
{sheetName: "Sheet2", cell: "AF1", opts: &Chart{Type: "area", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D Area Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "AF1", opts: &Chart{Type: Area, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D Area Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "AN1", opts: &Chart{Type: "areaStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D Stacked Area Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "AN1", opts: &Chart{Type: AreaStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D Stacked Area Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "AF16", opts: &Chart{Type: "areaPercentStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D 100% Stacked Area Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "AF16", opts: &Chart{Type: AreaPercentStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D 100% Stacked Area Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "AN16", opts: &Chart{Type: "area3D", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Area Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "AN16", opts: &Chart{Type: Area3D, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Area Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "AF32", opts: &Chart{Type: "area3DStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Stacked Area Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "AF32", opts: &Chart{Type: Area3DStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Stacked Area Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "AN32", opts: &Chart{Type: "area3DPercentStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D 100% Stacked Area Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "AN32", opts: &Chart{Type: Area3DPercentStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D 100% Stacked Area Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
// cylinder series chart // cylinder series chart
{sheetName: "Sheet2", cell: "AF48", opts: &Chart{Type: "bar3DCylinderStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Bar Cylinder Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "AF48", opts: &Chart{Type: Bar3DCylinderStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Bar Cylinder Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "AF64", opts: &Chart{Type: "bar3DCylinderClustered", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Bar Cylinder Clustered Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "AF64", opts: &Chart{Type: Bar3DCylinderClustered, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Bar Cylinder Clustered Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "AF80", opts: &Chart{Type: "bar3DCylinderPercentStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Bar Cylinder Percent Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "AF80", opts: &Chart{Type: Bar3DCylinderPercentStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Bar Cylinder Percent Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
// cone series chart // cone series chart
{sheetName: "Sheet2", cell: "AN48", opts: &Chart{Type: "bar3DConeStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Bar Cone Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "AN48", opts: &Chart{Type: Bar3DConeStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Bar Cone Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "AN64", opts: &Chart{Type: "bar3DConeClustered", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Bar Cone Clustered Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "AN64", opts: &Chart{Type: Bar3DConeClustered, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Bar Cone Clustered Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "AN80", opts: &Chart{Type: "bar3DConePercentStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Bar Cone Percent Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "AN80", opts: &Chart{Type: Bar3DConePercentStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Bar Cone Percent Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "AV48", opts: &Chart{Type: "bar3DPyramidStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Bar Pyramid Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "AV48", opts: &Chart{Type: Bar3DPyramidStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Bar Pyramid Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "AV64", opts: &Chart{Type: "bar3DPyramidClustered", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Bar Pyramid Clustered Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "AV64", opts: &Chart{Type: Bar3DPyramidClustered, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Bar Pyramid Clustered Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "AV80", opts: &Chart{Type: "bar3DPyramidPercentStacked", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Bar Pyramid Percent Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "AV80", opts: &Chart{Type: Bar3DPyramidPercentStacked, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Bar Pyramid Percent Stacked Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
// surface series chart // surface series chart
{sheetName: "Sheet2", cell: "AV1", opts: &Chart{Type: "surface3D", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Surface Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", YAxis: ChartAxis{MajorGridLines: true}}}, {sheetName: "Sheet2", cell: "AV1", opts: &Chart{Type: Surface3D, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Surface Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", YAxis: ChartAxis{MajorGridLines: true}}},
{sheetName: "Sheet2", cell: "AV16", opts: &Chart{Type: "wireframeSurface3D", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Wireframe Surface Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", YAxis: ChartAxis{MajorGridLines: true}}}, {sheetName: "Sheet2", cell: "AV16", opts: &Chart{Type: WireframeSurface3D, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "3D Wireframe Surface Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", YAxis: ChartAxis{MajorGridLines: true}}},
{sheetName: "Sheet2", cell: "AV32", opts: &Chart{Type: "contour", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "Contour Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "AV32", opts: &Chart{Type: Contour, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "Contour Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "BD1", opts: &Chart{Type: "wireframeContour", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "Wireframe Contour Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "BD1", opts: &Chart{Type: WireframeContour, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "Wireframe Contour Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
// bubble chart // bubble chart
{sheetName: "Sheet2", cell: "BD16", opts: &Chart{Type: "bubble", Series: series4, Format: format, Legend: legend, Title: ChartTitle{Name: "Bubble Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}}, {sheetName: "Sheet2", cell: "BD16", opts: &Chart{Type: Bubble, Series: series4, Format: format, Legend: legend, Title: ChartTitle{Name: "Bubble Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}},
{sheetName: "Sheet2", cell: "BD32", opts: &Chart{Type: "bubble3D", Series: series4, Format: format, Legend: legend, Title: ChartTitle{Name: "Bubble 3D Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{MajorGridLines: true}, YAxis: ChartAxis{MajorGridLines: true}}}, {sheetName: "Sheet2", cell: "BD32", opts: &Chart{Type: Bubble3D, Series: series4, Format: format, Legend: legend, Title: ChartTitle{Name: "Bubble 3D Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{MajorGridLines: true}, YAxis: ChartAxis{MajorGridLines: true}}},
// pie of pie chart // pie of pie chart
{sheetName: "Sheet2", cell: "BD48", opts: &Chart{Type: "pieOfPie", Series: series3, Format: format, Legend: legend, Title: ChartTitle{Name: "Pie of Pie Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{MajorGridLines: true}, YAxis: ChartAxis{MajorGridLines: true}}}, {sheetName: "Sheet2", cell: "BD48", opts: &Chart{Type: PieOfPie, Series: series3, Format: format, Legend: legend, Title: ChartTitle{Name: "Pie of Pie Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{MajorGridLines: true}, YAxis: ChartAxis{MajorGridLines: true}}},
// bar of pie chart // bar of pie chart
{sheetName: "Sheet2", cell: "BD64", opts: &Chart{Type: "barOfPie", Series: series3, Format: format, Legend: legend, Title: ChartTitle{Name: "Bar of Pie Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{MajorGridLines: true}, YAxis: ChartAxis{MajorGridLines: true}}}, {sheetName: "Sheet2", cell: "BD64", opts: &Chart{Type: BarOfPie, Series: series3, Format: format, Legend: legend, Title: ChartTitle{Name: "Bar of Pie Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{MajorGridLines: true}, YAxis: ChartAxis{MajorGridLines: true}}},
} { } {
assert.NoError(t, f.AddChart(c.sheetName, c.cell, c.opts)) assert.NoError(t, f.AddChart(c.sheetName, c.cell, c.opts))
} }
// combo chart // combo chart
_, err = f.NewSheet("Combo Charts") _, err = f.NewSheet("Combo Charts")
assert.NoError(t, err) assert.NoError(t, err)
clusteredColumnCombo := [][]string{ clusteredColumnCombo := [][]interface{}{
{"A1", "line", "Clustered Column - Line Chart"}, {"A1", Line, "Clustered Column - Line Chart"},
{"I1", "doughnut", "Clustered Column - Doughnut Chart"}, {"I1", Doughnut, "Clustered Column - Doughnut Chart"},
} }
for _, props := range clusteredColumnCombo { for _, props := range clusteredColumnCombo {
assert.NoError(t, f.AddChart("Combo Charts", props[0], &Chart{Type: "col", Series: series[:4], Format: format, Legend: legend, Title: ChartTitle{Name: props[2]}, PlotArea: ChartPlotArea{ShowBubbleSize: true, ShowCatName: false, ShowLeaderLines: false, ShowPercent: true, ShowSerName: true, ShowVal: true}}, &Chart{Type: props[1], Series: series[4:], Format: format, Legend: legend, PlotArea: ChartPlotArea{ShowBubbleSize: true, ShowCatName: false, ShowLeaderLines: false, ShowPercent: true, ShowSerName: true, ShowVal: true}})) assert.NoError(t, f.AddChart("Combo Charts", props[0].(string), &Chart{Type: Col, Series: series[:4], Format: format, Legend: legend, Title: ChartTitle{Name: props[2].(string)}, PlotArea: ChartPlotArea{ShowBubbleSize: true, ShowCatName: false, ShowLeaderLines: false, ShowPercent: true, ShowSerName: true, ShowVal: true}}, &Chart{Type: props[1].(ChartType), Series: series[4:], Format: format, Legend: legend, PlotArea: ChartPlotArea{ShowBubbleSize: true, ShowCatName: false, ShowLeaderLines: false, ShowPercent: true, ShowSerName: true, ShowVal: true}}))
} }
stackedAreaCombo := map[string][]string{ stackedAreaCombo := map[string][]interface{}{
"A16": {"line", "Stacked Area - Line Chart"}, "A16": {Line, "Stacked Area - Line Chart"},
"I16": {"doughnut", "Stacked Area - Doughnut Chart"}, "I16": {Doughnut, "Stacked Area - Doughnut Chart"},
} }
for axis, props := range stackedAreaCombo { for axis, props := range stackedAreaCombo {
assert.NoError(t, f.AddChart("Combo Charts", axis, &Chart{Type: "areaStacked", Series: series[:4], Format: format, Legend: legend, Title: ChartTitle{Name: props[1]}, PlotArea: ChartPlotArea{ShowBubbleSize: true, ShowCatName: false, ShowLeaderLines: false, ShowPercent: true, ShowSerName: true, ShowVal: true}}, &Chart{Type: props[0], Series: series[4:], Format: format, Legend: legend, PlotArea: ChartPlotArea{ShowBubbleSize: true, ShowCatName: false, ShowLeaderLines: false, ShowPercent: true, ShowSerName: true, ShowVal: true}})) assert.NoError(t, f.AddChart("Combo Charts", axis, &Chart{Type: AreaStacked, Series: series[:4], Format: format, Legend: legend, Title: ChartTitle{Name: props[1].(string)}, PlotArea: ChartPlotArea{ShowBubbleSize: true, ShowCatName: false, ShowLeaderLines: false, ShowPercent: true, ShowSerName: true, ShowVal: true}}, &Chart{Type: props[0].(ChartType), Series: series[4:], Format: format, Legend: legend, PlotArea: ChartPlotArea{ShowBubbleSize: true, ShowCatName: false, ShowLeaderLines: false, ShowPercent: true, ShowSerName: true, ShowVal: true}}))
} }
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestAddChart.xlsx"))) assert.NoError(t, f.SaveAs(filepath.Join("test", "TestAddChart.xlsx")))
// Test with invalid sheet name // Test with invalid sheet name
assert.EqualError(t, f.AddChart("Sheet:1", "A1", &Chart{Type: "col", Series: series[:1]}), ErrSheetNameInvalid.Error()) assert.EqualError(t, f.AddChart("Sheet:1", "A1", &Chart{Type: Col, Series: series[:1]}), ErrSheetNameInvalid.Error())
// Test with illegal cell reference // Test with illegal cell reference
assert.EqualError(t, f.AddChart("Sheet2", "A", &Chart{Type: "col", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}), newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error()) assert.EqualError(t, f.AddChart("Sheet2", "A", &Chart{Type: Col, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}), newCellNameToCoordinatesError("A", newInvalidCellNameError("A")).Error())
// Test with unsupported chart type // Test with unsupported chart type
assert.EqualError(t, f.AddChart("Sheet2", "BD32", &Chart{Type: "unknown", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "Bubble 3D Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}), "unsupported chart type unknown") assert.EqualError(t, f.AddChart("Sheet2", "BD32", &Chart{Type: 0x37, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "Bubble 3D Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}), newUnsupportedChartType(0x37).Error())
// Test add combo chart with invalid format set // Test add combo chart with invalid format set
assert.EqualError(t, f.AddChart("Sheet2", "BD32", &Chart{Type: "col", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}, nil), ErrParameterInvalid.Error()) assert.EqualError(t, f.AddChart("Sheet2", "BD32", &Chart{Type: Col, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}, nil), ErrParameterInvalid.Error())
// Test add combo chart with unsupported chart type // Test add combo chart with unsupported chart type
assert.EqualError(t, f.AddChart("Sheet2", "BD64", &Chart{Type: "barOfPie", Series: []ChartSeries{{Name: "Sheet1!$A$30", Categories: "Sheet1!$A$30:$D$37", Values: "Sheet1!$B$30:$B$37"}}, Format: format, Legend: legend, Title: ChartTitle{Name: "Bar of Pie Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{MajorGridLines: true}, YAxis: ChartAxis{MajorGridLines: true}}, &Chart{Type: "unknown", Series: []ChartSeries{{Name: "Sheet1!$A$30", Categories: "Sheet1!$A$30:$D$37", Values: "Sheet1!$B$30:$B$37"}}, Format: format, Legend: legend, Title: ChartTitle{Name: "Bar of Pie Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{MajorGridLines: true}, YAxis: ChartAxis{MajorGridLines: true}}), "unsupported chart type unknown") assert.EqualError(t, f.AddChart("Sheet2", "BD64", &Chart{Type: BarOfPie, Series: []ChartSeries{{Name: "Sheet1!$A$30", Categories: "Sheet1!$A$30:$D$37", Values: "Sheet1!$B$30:$B$37"}}, Format: format, Legend: legend, Title: ChartTitle{Name: "Bar of Pie Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{MajorGridLines: true}, YAxis: ChartAxis{MajorGridLines: true}}, &Chart{Type: 0x37, Series: []ChartSeries{{Name: "Sheet1!$A$30", Categories: "Sheet1!$A$30:$D$37", Values: "Sheet1!$B$30:$B$37"}}, Format: format, Legend: legend, Title: ChartTitle{Name: "Bar of Pie Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero", XAxis: ChartAxis{MajorGridLines: true}, YAxis: ChartAxis{MajorGridLines: true}}), newUnsupportedChartType(0x37).Error())
assert.NoError(t, f.Close()) assert.NoError(t, f.Close())
// Test add chart with unsupported charset content types. // Test add chart with unsupported charset content types.
f.ContentTypes = nil f.ContentTypes = nil
f.Pkg.Store(defaultXMLPathContentTypes, MacintoshCyrillicCharset) f.Pkg.Store(defaultXMLPathContentTypes, MacintoshCyrillicCharset)
assert.EqualError(t, f.AddChart("Sheet1", "P1", &Chart{Type: "col", Series: []ChartSeries{{Name: "Sheet1!$A$30", Categories: "Sheet1!$B$29:$D$29", Values: "Sheet1!$B$30:$D$30"}}, Title: ChartTitle{Name: "2D Column Chart"}}), "XML syntax error on line 1: invalid UTF-8") assert.EqualError(t, f.AddChart("Sheet1", "P1", &Chart{Type: Col, Series: []ChartSeries{{Name: "Sheet1!$A$30", Categories: "Sheet1!$B$29:$D$29", Values: "Sheet1!$B$30:$D$30"}}, Title: ChartTitle{Name: "2D Column Chart"}}), "XML syntax error on line 1: invalid UTF-8")
} }
func TestAddChartSheet(t *testing.T) { func TestAddChartSheet(t *testing.T) {
@ -317,7 +317,7 @@ func TestAddChartSheet(t *testing.T) {
{Name: "Sheet1!$A$3", Categories: "Sheet1!$B$1:$D$1", Values: "Sheet1!$B$3:$D$3"}, {Name: "Sheet1!$A$3", Categories: "Sheet1!$B$1:$D$1", Values: "Sheet1!$B$3:$D$3"},
{Name: "Sheet1!$A$4", Categories: "Sheet1!$B$1:$D$1", Values: "Sheet1!$B$4:$D$4"}, {Name: "Sheet1!$A$4", Categories: "Sheet1!$B$1:$D$1", Values: "Sheet1!$B$4:$D$4"},
} }
assert.NoError(t, f.AddChartSheet("Chart1", &Chart{Type: "col3DClustered", Series: series, Title: ChartTitle{Name: "Fruit 3D Clustered Column Chart"}})) assert.NoError(t, f.AddChartSheet("Chart1", &Chart{Type: Col3DClustered, Series: series, Title: ChartTitle{Name: "Fruit 3D Clustered Column Chart"}}))
// Test set the chartsheet as active sheet // Test set the chartsheet as active sheet
var sheetIdx int var sheetIdx int
for idx, sheetName := range f.GetSheetList() { for idx, sheetName := range f.GetSheetList() {
@ -332,11 +332,11 @@ func TestAddChartSheet(t *testing.T) {
assert.EqualError(t, f.SetCellValue("Chart1", "A1", true), "sheet Chart1 is not a worksheet") assert.EqualError(t, f.SetCellValue("Chart1", "A1", true), "sheet Chart1 is not a worksheet")
// Test add chartsheet on already existing name sheet // Test add chartsheet on already existing name sheet
assert.EqualError(t, f.AddChartSheet("Sheet1", &Chart{Type: "col3DClustered", Series: series, Title: ChartTitle{Name: "Fruit 3D Clustered Column Chart"}}), ErrExistsSheet.Error()) assert.EqualError(t, f.AddChartSheet("Sheet1", &Chart{Type: Col3DClustered, Series: series, Title: ChartTitle{Name: "Fruit 3D Clustered Column Chart"}}), ErrExistsSheet.Error())
// Test add chartsheet with invalid sheet name // Test add chartsheet with invalid sheet name
assert.EqualError(t, f.AddChartSheet("Sheet:1", nil, &Chart{Type: "col3DClustered", Series: series, Title: ChartTitle{Name: "Fruit 3D Clustered Column Chart"}}), ErrSheetNameInvalid.Error()) assert.EqualError(t, f.AddChartSheet("Sheet:1", nil, &Chart{Type: Col3DClustered, Series: series, Title: ChartTitle{Name: "Fruit 3D Clustered Column Chart"}}), ErrSheetNameInvalid.Error())
// Test with unsupported chart type // Test with unsupported chart type
assert.EqualError(t, f.AddChartSheet("Chart2", &Chart{Type: "unknown", Series: series, Title: ChartTitle{Name: "Fruit 3D Clustered Column Chart"}}), "unsupported chart type unknown") assert.EqualError(t, f.AddChartSheet("Chart2", &Chart{Type: 0x37, Series: series, Title: ChartTitle{Name: "Fruit 3D Clustered Column Chart"}}), newUnsupportedChartType(0x37).Error())
assert.NoError(t, f.UpdateLinkedValue()) assert.NoError(t, f.UpdateLinkedValue())
@ -345,7 +345,7 @@ func TestAddChartSheet(t *testing.T) {
f = NewFile() f = NewFile()
f.ContentTypes = nil f.ContentTypes = nil
f.Pkg.Store(defaultXMLPathContentTypes, MacintoshCyrillicCharset) f.Pkg.Store(defaultXMLPathContentTypes, MacintoshCyrillicCharset)
assert.EqualError(t, f.AddChartSheet("Chart4", &Chart{Type: "col", Series: []ChartSeries{{Name: "Sheet1!$A$30", Categories: "Sheet1!$B$29:$D$29", Values: "Sheet1!$B$30:$D$30"}}, Title: ChartTitle{Name: "2D Column Chart"}}), "XML syntax error on line 1: invalid UTF-8") assert.EqualError(t, f.AddChartSheet("Chart4", &Chart{Type: Col, Series: []ChartSeries{{Name: "Sheet1!$A$30", Categories: "Sheet1!$B$29:$D$29", Values: "Sheet1!$B$30:$D$30"}}, Title: ChartTitle{Name: "2D Column Chart"}}), "XML syntax error on line 1: invalid UTF-8")
} }
func TestDeleteChart(t *testing.T) { func TestDeleteChart(t *testing.T) {
@ -380,7 +380,7 @@ func TestDeleteChart(t *testing.T) {
ShowSerName: true, ShowSerName: true,
ShowVal: true, ShowVal: true,
} }
assert.NoError(t, f.AddChart("Sheet1", "P1", &Chart{Type: "col", Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"})) assert.NoError(t, f.AddChart("Sheet1", "P1", &Chart{Type: Col, Series: series, Format: format, Legend: legend, Title: ChartTitle{Name: "2D Column Chart"}, PlotArea: plotArea, ShowBlanksAs: "zero"}))
assert.NoError(t, f.DeleteChart("Sheet1", "P1")) assert.NoError(t, f.DeleteChart("Sheet1", "P1"))
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestDeleteChart.xlsx"))) assert.NoError(t, f.SaveAs(filepath.Join("test", "TestDeleteChart.xlsx")))
// Test delete chart with invalid sheet name // Test delete chart with invalid sheet name
@ -429,12 +429,12 @@ func TestChartWithLogarithmicBase(t *testing.T) {
cell string cell string
opts *Chart opts *Chart
}{ }{
{cell: "C1", opts: &Chart{Type: "line", Dimension: ChartDimension{Width: dimension[0], Height: dimension[1]}, Series: series, Title: ChartTitle{Name: "Line chart without log scaling"}}}, {cell: "C1", opts: &Chart{Type: Line, Dimension: ChartDimension{Width: dimension[0], Height: dimension[1]}, Series: series, Title: ChartTitle{Name: "Line chart without log scaling"}}},
{cell: "M1", opts: &Chart{Type: "line", Dimension: ChartDimension{Width: dimension[0], Height: dimension[1]}, Series: series, Title: ChartTitle{Name: "Line chart with log 10.5 scaling"}, YAxis: ChartAxis{LogBase: 10.5}}}, {cell: "M1", opts: &Chart{Type: Line, Dimension: ChartDimension{Width: dimension[0], Height: dimension[1]}, Series: series, Title: ChartTitle{Name: "Line chart with log 10.5 scaling"}, YAxis: ChartAxis{LogBase: 10.5}}},
{cell: "A25", opts: &Chart{Type: "line", Dimension: ChartDimension{Width: dimension[2], Height: dimension[3]}, Series: series, Title: ChartTitle{Name: "Line chart with log 1.9 scaling"}, YAxis: ChartAxis{LogBase: 1.9}}}, {cell: "A25", opts: &Chart{Type: Line, Dimension: ChartDimension{Width: dimension[2], Height: dimension[3]}, Series: series, Title: ChartTitle{Name: "Line chart with log 1.9 scaling"}, YAxis: ChartAxis{LogBase: 1.9}}},
{cell: "F25", opts: &Chart{Type: "line", Dimension: ChartDimension{Width: dimension[2], Height: dimension[3]}, Series: series, Title: ChartTitle{Name: "Line chart with log 2 scaling"}, YAxis: ChartAxis{LogBase: 2}}}, {cell: "F25", opts: &Chart{Type: Line, Dimension: ChartDimension{Width: dimension[2], Height: dimension[3]}, Series: series, Title: ChartTitle{Name: "Line chart with log 2 scaling"}, YAxis: ChartAxis{LogBase: 2}}},
{cell: "K25", opts: &Chart{Type: "line", Dimension: ChartDimension{Width: dimension[2], Height: dimension[3]}, Series: series, Title: ChartTitle{Name: "Line chart with log 1000.1 scaling"}, YAxis: ChartAxis{LogBase: 1000.1}}}, {cell: "K25", opts: &Chart{Type: Line, Dimension: ChartDimension{Width: dimension[2], Height: dimension[3]}, Series: series, Title: ChartTitle{Name: "Line chart with log 1000.1 scaling"}, YAxis: ChartAxis{LogBase: 1000.1}}},
{cell: "P25", opts: &Chart{Type: "line", Dimension: ChartDimension{Width: dimension[2], Height: dimension[3]}, Series: series, Title: ChartTitle{Name: "Line chart with log 1000 scaling"}, YAxis: ChartAxis{LogBase: 1000}}}, {cell: "P25", opts: &Chart{Type: Line, Dimension: ChartDimension{Width: dimension[2], Height: dimension[3]}, Series: series, Title: ChartTitle{Name: "Line chart with log 1000 scaling"}, YAxis: ChartAxis{LogBase: 1000}}},
} { } {
// Add two chart, one without and one with log scaling // Add two chart, one without and one with log scaling
assert.NoError(t, f.AddChart(sheet1, c.cell, c.opts)) assert.NoError(t, f.AddChart(sheet1, c.cell, c.opts))

View File

@ -180,7 +180,7 @@ func (f *File) addChart(opts *Chart, comboCharts []*Chart) {
}, },
}, },
} }
plotAreaFunc := map[string]func(*Chart) *cPlotArea{ plotAreaFunc := map[ChartType]func(*Chart) *cPlotArea{
Area: f.drawBaseChart, Area: f.drawBaseChart,
AreaStacked: f.drawBaseChart, AreaStacked: f.drawBaseChart,
AreaPercentStacked: f.drawBaseChart, AreaPercentStacked: f.drawBaseChart,
@ -226,8 +226,8 @@ func (f *File) addChart(opts *Chart, comboCharts []*Chart) {
Line3D: f.drawLine3DChart, Line3D: f.drawLine3DChart,
Pie: f.drawPieChart, Pie: f.drawPieChart,
Pie3D: f.drawPie3DChart, Pie3D: f.drawPie3DChart,
PieOfPieChart: f.drawPieOfPieChart, PieOfPie: f.drawPieOfPieChart,
BarOfPieChart: f.drawBarOfPieChart, BarOfPie: f.drawBarOfPieChart,
Radar: f.drawRadarChart, Radar: f.drawRadarChart,
Scatter: f.drawScatterChart, Scatter: f.drawScatterChart,
Surface3D: f.drawSurface3DChart, Surface3D: f.drawSurface3DChart,
@ -293,213 +293,213 @@ func (f *File) drawBaseChart(opts *Chart) *cPlotArea {
} }
catAx := f.drawPlotAreaCatAx(opts) catAx := f.drawPlotAreaCatAx(opts)
valAx := f.drawPlotAreaValAx(opts) valAx := f.drawPlotAreaValAx(opts)
charts := map[string]*cPlotArea{ charts := map[ChartType]*cPlotArea{
"area": { Area: {
AreaChart: &c, AreaChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"areaStacked": { AreaStacked: {
AreaChart: &c, AreaChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"areaPercentStacked": { AreaPercentStacked: {
AreaChart: &c, AreaChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"area3D": { Area3D: {
Area3DChart: &c, Area3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"area3DStacked": { Area3DStacked: {
Area3DChart: &c, Area3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"area3DPercentStacked": { Area3DPercentStacked: {
Area3DChart: &c, Area3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"bar": { Bar: {
BarChart: &c, BarChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"barStacked": { BarStacked: {
BarChart: &c, BarChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"barPercentStacked": { BarPercentStacked: {
BarChart: &c, BarChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"bar3DClustered": { Bar3DClustered: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"bar3DStacked": { Bar3DStacked: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"bar3DPercentStacked": { Bar3DPercentStacked: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"bar3DConeClustered": { Bar3DConeClustered: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"bar3DConeStacked": { Bar3DConeStacked: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"bar3DConePercentStacked": { Bar3DConePercentStacked: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"bar3DPyramidClustered": { Bar3DPyramidClustered: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"bar3DPyramidStacked": { Bar3DPyramidStacked: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"bar3DPyramidPercentStacked": { Bar3DPyramidPercentStacked: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"bar3DCylinderClustered": { Bar3DCylinderClustered: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"bar3DCylinderStacked": { Bar3DCylinderStacked: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"bar3DCylinderPercentStacked": { Bar3DCylinderPercentStacked: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"col": { Col: {
BarChart: &c, BarChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"colStacked": { ColStacked: {
BarChart: &c, BarChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"colPercentStacked": { ColPercentStacked: {
BarChart: &c, BarChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"col3D": { Col3D: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"col3DClustered": { Col3DClustered: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"col3DStacked": { Col3DStacked: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"col3DPercentStacked": { Col3DPercentStacked: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"col3DCone": { Col3DCone: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"col3DConeClustered": { Col3DConeClustered: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"col3DConeStacked": { Col3DConeStacked: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"col3DConePercentStacked": { Col3DConePercentStacked: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"col3DPyramid": { Col3DPyramid: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"col3DPyramidClustered": { Col3DPyramidClustered: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"col3DPyramidStacked": { Col3DPyramidStacked: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"col3DPyramidPercentStacked": { Col3DPyramidPercentStacked: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"col3DCylinder": { Col3DCylinder: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"col3DCylinderClustered": { Col3DCylinderClustered: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"col3DCylinderStacked": { Col3DCylinderStacked: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"col3DCylinderPercentStacked": { Col3DCylinderPercentStacked: {
Bar3DChart: &c, Bar3DChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"bubble": { Bubble: {
BubbleChart: &c, BubbleChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
}, },
"bubble3D": { Bubble3D: {
BubbleChart: &c, BubbleChart: &c,
CatAx: catAx, CatAx: catAx,
ValAx: valAx, ValAx: valAx,
@ -756,7 +756,7 @@ func (f *File) drawBubbleChart(opts *Chart) *cPlotArea {
// drawChartShape provides a function to draw the c:shape element by given // drawChartShape provides a function to draw the c:shape element by given
// format sets. // format sets.
func (f *File) drawChartShape(opts *Chart) *attrValString { func (f *File) drawChartShape(opts *Chart) *attrValString {
shapes := map[string]string{ shapes := map[ChartType]string{
Bar3DConeClustered: "cone", Bar3DConeClustered: "cone",
Bar3DConeStacked: "cone", Bar3DConeStacked: "cone",
Bar3DConePercentStacked: "cone", Bar3DConePercentStacked: "cone",
@ -844,7 +844,7 @@ func (f *File) drawChartSeriesSpPr(i int, opts *Chart) *cSpPr {
}, },
}, },
} }
if chartSeriesSpPr, ok := map[string]*cSpPr{ if chartSeriesSpPr, ok := map[ChartType]*cSpPr{
Line: spPrLine, Scatter: spPrScatter, Line: spPrLine, Scatter: spPrScatter,
}[opts.Type]; ok { }[opts.Type]; ok {
return chartSeriesSpPr return chartSeriesSpPr
@ -880,7 +880,7 @@ func (f *File) drawChartSeriesDPt(i int, opts *Chart) []*cDPt {
}, },
}, },
}} }}
chartSeriesDPt := map[string][]*cDPt{Pie: dpt, Pie3D: dpt} chartSeriesDPt := map[ChartType][]*cDPt{Pie: dpt, Pie3D: dpt}
return chartSeriesDPt[opts.Type] return chartSeriesDPt[opts.Type]
} }
@ -892,7 +892,7 @@ func (f *File) drawChartSeriesCat(v ChartSeries, opts *Chart) *cCat {
F: v.Categories, F: v.Categories,
}, },
} }
chartSeriesCat := map[string]*cCat{Scatter: nil, Bubble: nil, Bubble3D: nil} chartSeriesCat := map[ChartType]*cCat{Scatter: nil, Bubble: nil, Bubble3D: nil}
if _, ok := chartSeriesCat[opts.Type]; ok || v.Categories == "" { if _, ok := chartSeriesCat[opts.Type]; ok || v.Categories == "" {
return nil return nil
} }
@ -907,7 +907,7 @@ func (f *File) drawChartSeriesVal(v ChartSeries, opts *Chart) *cVal {
F: v.Values, F: v.Values,
}, },
} }
chartSeriesVal := map[string]*cVal{Scatter: nil, Bubble: nil, Bubble3D: nil} chartSeriesVal := map[ChartType]*cVal{Scatter: nil, Bubble: nil, Bubble3D: nil}
if _, ok := chartSeriesVal[opts.Type]; ok { if _, ok := chartSeriesVal[opts.Type]; ok {
return nil return nil
} }
@ -917,7 +917,7 @@ func (f *File) drawChartSeriesVal(v ChartSeries, opts *Chart) *cVal {
// drawChartSeriesMarker provides a function to draw the c:marker element by // drawChartSeriesMarker provides a function to draw the c:marker element by
// given data index and format sets. // given data index and format sets.
func (f *File) drawChartSeriesMarker(i int, opts *Chart) *cMarker { func (f *File) drawChartSeriesMarker(i int, opts *Chart) *cMarker {
defaultSymbol := map[string]*attrValString{Scatter: {Val: stringPtr("circle")}} defaultSymbol := map[ChartType]*attrValString{Scatter: {Val: stringPtr("circle")}}
marker := &cMarker{ marker := &cMarker{
Symbol: defaultSymbol[opts.Type], Symbol: defaultSymbol[opts.Type],
Size: &attrValInt{Val: intPtr(5)}, Size: &attrValInt{Val: intPtr(5)},
@ -945,7 +945,7 @@ func (f *File) drawChartSeriesMarker(i int, opts *Chart) *cMarker {
}, },
} }
} }
chartSeriesMarker := map[string]*cMarker{Scatter: marker, Line: marker} chartSeriesMarker := map[ChartType]*cMarker{Scatter: marker, Line: marker}
return chartSeriesMarker[opts.Type] return chartSeriesMarker[opts.Type]
} }
@ -957,7 +957,7 @@ func (f *File) drawChartSeriesXVal(v ChartSeries, opts *Chart) *cCat {
F: v.Categories, F: v.Categories,
}, },
} }
chartSeriesXVal := map[string]*cCat{Scatter: cat, Bubble: cat, Bubble3D: cat} chartSeriesXVal := map[ChartType]*cCat{Scatter: cat, Bubble: cat, Bubble3D: cat}
return chartSeriesXVal[opts.Type] return chartSeriesXVal[opts.Type]
} }
@ -969,14 +969,14 @@ func (f *File) drawChartSeriesYVal(v ChartSeries, opts *Chart) *cVal {
F: v.Values, F: v.Values,
}, },
} }
chartSeriesYVal := map[string]*cVal{Scatter: val, Bubble: val, Bubble3D: val} chartSeriesYVal := map[ChartType]*cVal{Scatter: val, Bubble: val, Bubble3D: val}
return chartSeriesYVal[opts.Type] return chartSeriesYVal[opts.Type]
} }
// drawCharSeriesBubbleSize provides a function to draw the c:bubbleSize // drawCharSeriesBubbleSize provides a function to draw the c:bubbleSize
// element by given chart series and format sets. // element by given chart series and format sets.
func (f *File) drawCharSeriesBubbleSize(v ChartSeries, opts *Chart) *cVal { func (f *File) drawCharSeriesBubbleSize(v ChartSeries, opts *Chart) *cVal {
if _, ok := map[string]bool{Bubble: true, Bubble3D: true}[opts.Type]; !ok || v.Sizes == "" { if _, ok := map[ChartType]bool{Bubble: true, Bubble3D: true}[opts.Type]; !ok || v.Sizes == "" {
return nil return nil
} }
return &cVal{ return &cVal{
@ -989,7 +989,7 @@ func (f *File) drawCharSeriesBubbleSize(v ChartSeries, opts *Chart) *cVal {
// drawCharSeriesBubble3D provides a function to draw the c:bubble3D element // drawCharSeriesBubble3D provides a function to draw the c:bubble3D element
// by given format sets. // by given format sets.
func (f *File) drawCharSeriesBubble3D(opts *Chart) *attrValBool { func (f *File) drawCharSeriesBubble3D(opts *Chart) *attrValBool {
if _, ok := map[string]bool{Bubble3D: true}[opts.Type]; !ok { if _, ok := map[ChartType]bool{Bubble3D: true}[opts.Type]; !ok {
return nil return nil
} }
return &attrValBool{Val: boolPtr(true)} return &attrValBool{Val: boolPtr(true)}
@ -1027,7 +1027,7 @@ func (f *File) drawChartDLbls(opts *Chart) *cDLbls {
// given format sets. // given format sets.
func (f *File) drawChartSeriesDLbls(opts *Chart) *cDLbls { func (f *File) drawChartSeriesDLbls(opts *Chart) *cDLbls {
dLbls := f.drawChartDLbls(opts) dLbls := f.drawChartDLbls(opts)
chartSeriesDLbls := map[string]*cDLbls{ chartSeriesDLbls := map[ChartType]*cDLbls{
Scatter: nil, Surface3D: nil, WireframeSurface3D: nil, Contour: nil, WireframeContour: nil, Bubble: nil, Bubble3D: nil, Scatter: nil, Surface3D: nil, WireframeSurface3D: nil, Contour: nil, WireframeContour: nil, Bubble: nil, Bubble3D: nil,
} }
if _, ok := chartSeriesDLbls[opts.Type]; ok { if _, ok := chartSeriesDLbls[opts.Type]; ok {

View File

@ -48,8 +48,8 @@ func newInvalidTableNameError(name string) error {
// newUnsupportedChartType defined the error message on receiving the chart // newUnsupportedChartType defined the error message on receiving the chart
// type are unsupported. // type are unsupported.
func newUnsupportedChartType(chartType string) error { func newUnsupportedChartType(chartType ChartType) error {
return fmt.Errorf("unsupported chart type %s", chartType) return fmt.Errorf("unsupported chart type %d", chartType)
} }
// newUnzipSizeLimitError defined the error message on unzip size exceeds the // newUnzipSizeLimitError defined the error message on unzip size exceeds the

View File

@ -561,7 +561,7 @@ type ChartPlotArea struct {
// Chart directly maps the format settings of the chart. // Chart directly maps the format settings of the chart.
type Chart struct { type Chart struct {
Type string Type ChartType
Series []ChartSeries Series []ChartSeries
Format GraphicOptions Format GraphicOptions
Dimension ChartDimension Dimension ChartDimension