forked from p30928647/excelize
Resolve #311, create 2D/3D area, stacked area, 100% stacked area chart support
This commit is contained in:
parent
e7a96da2db
commit
b04107c4a3
473
chart.go
473
chart.go
|
@ -18,112 +18,142 @@ import (
|
|||
|
||||
// This section defines the currently supported chart types.
|
||||
const (
|
||||
Bar = "bar"
|
||||
BarStacked = "barStacked"
|
||||
BarPercentStacked = "barPercentStacked"
|
||||
Bar3DClustered = "bar3DClustered"
|
||||
Bar3DStacked = "bar3DStacked"
|
||||
Bar3DPercentStacked = "bar3DPercentStacked"
|
||||
Col = "col"
|
||||
ColStacked = "colStacked"
|
||||
ColPercentStacked = "colPercentStacked"
|
||||
Col3DClustered = "col3DClustered"
|
||||
Col3D = "col3D"
|
||||
Col3DStacked = "col3DStacked"
|
||||
Col3DPercentStacked = "col3DPercentStacked"
|
||||
Doughnut = "doughnut"
|
||||
Line = "line"
|
||||
Pie = "pie"
|
||||
Pie3D = "pie3D"
|
||||
Radar = "radar"
|
||||
Scatter = "scatter"
|
||||
Area = "area"
|
||||
AreaStacked = "areaStacked"
|
||||
AreaPercentStacked = "areaPercentStacked"
|
||||
Area3D = "area3D"
|
||||
Area3DStacked = "area3DStacked"
|
||||
Area3DPercentStacked = "area3DPercentStacked"
|
||||
Bar = "bar"
|
||||
BarStacked = "barStacked"
|
||||
BarPercentStacked = "barPercentStacked"
|
||||
Bar3DClustered = "bar3DClustered"
|
||||
Bar3DStacked = "bar3DStacked"
|
||||
Bar3DPercentStacked = "bar3DPercentStacked"
|
||||
Col = "col"
|
||||
ColStacked = "colStacked"
|
||||
ColPercentStacked = "colPercentStacked"
|
||||
Col3DClustered = "col3DClustered"
|
||||
Col3D = "col3D"
|
||||
Col3DStacked = "col3DStacked"
|
||||
Col3DPercentStacked = "col3DPercentStacked"
|
||||
Doughnut = "doughnut"
|
||||
Line = "line"
|
||||
Pie = "pie"
|
||||
Pie3D = "pie3D"
|
||||
Radar = "radar"
|
||||
Scatter = "scatter"
|
||||
)
|
||||
|
||||
// This section defines the default value of chart properties.
|
||||
var (
|
||||
chartView3DRotX = map[string]int{
|
||||
Bar: 0,
|
||||
BarStacked: 0,
|
||||
BarPercentStacked: 0,
|
||||
Bar3DClustered: 15,
|
||||
Bar3DStacked: 15,
|
||||
Bar3DPercentStacked: 15,
|
||||
Col: 0,
|
||||
ColStacked: 0,
|
||||
ColPercentStacked: 0,
|
||||
Col3DClustered: 15,
|
||||
Col3D: 15,
|
||||
Col3DStacked: 15,
|
||||
Col3DPercentStacked: 15,
|
||||
Doughnut: 0,
|
||||
Line: 0,
|
||||
Pie: 0,
|
||||
Pie3D: 30,
|
||||
Radar: 0,
|
||||
Scatter: 0,
|
||||
Area: 0,
|
||||
AreaStacked: 0,
|
||||
AreaPercentStacked: 0,
|
||||
Area3D: 15,
|
||||
Area3DStacked: 15,
|
||||
Area3DPercentStacked: 15,
|
||||
Bar: 0,
|
||||
BarStacked: 0,
|
||||
BarPercentStacked: 0,
|
||||
Bar3DClustered: 15,
|
||||
Bar3DStacked: 15,
|
||||
Bar3DPercentStacked: 15,
|
||||
Col: 0,
|
||||
ColStacked: 0,
|
||||
ColPercentStacked: 0,
|
||||
Col3DClustered: 15,
|
||||
Col3D: 15,
|
||||
Col3DStacked: 15,
|
||||
Col3DPercentStacked: 15,
|
||||
Doughnut: 0,
|
||||
Line: 0,
|
||||
Pie: 0,
|
||||
Pie3D: 30,
|
||||
Radar: 0,
|
||||
Scatter: 0,
|
||||
}
|
||||
chartView3DRotY = map[string]int{
|
||||
Bar: 0,
|
||||
BarStacked: 0,
|
||||
BarPercentStacked: 0,
|
||||
Bar3DClustered: 20,
|
||||
Bar3DStacked: 20,
|
||||
Bar3DPercentStacked: 20,
|
||||
Col: 0,
|
||||
ColStacked: 0,
|
||||
ColPercentStacked: 0,
|
||||
Col3DClustered: 20,
|
||||
Col3D: 20,
|
||||
Col3DStacked: 20,
|
||||
Col3DPercentStacked: 20,
|
||||
Doughnut: 0,
|
||||
Line: 0,
|
||||
Pie: 0,
|
||||
Pie3D: 0,
|
||||
Radar: 0,
|
||||
Scatter: 0,
|
||||
Area: 0,
|
||||
AreaStacked: 0,
|
||||
AreaPercentStacked: 0,
|
||||
Area3D: 20,
|
||||
Area3DStacked: 20,
|
||||
Area3DPercentStacked: 20,
|
||||
Bar: 0,
|
||||
BarStacked: 0,
|
||||
BarPercentStacked: 0,
|
||||
Bar3DClustered: 20,
|
||||
Bar3DStacked: 20,
|
||||
Bar3DPercentStacked: 20,
|
||||
Col: 0,
|
||||
ColStacked: 0,
|
||||
ColPercentStacked: 0,
|
||||
Col3DClustered: 20,
|
||||
Col3D: 20,
|
||||
Col3DStacked: 20,
|
||||
Col3DPercentStacked: 20,
|
||||
Doughnut: 0,
|
||||
Line: 0,
|
||||
Pie: 0,
|
||||
Pie3D: 0,
|
||||
Radar: 0,
|
||||
Scatter: 0,
|
||||
}
|
||||
chartView3DDepthPercent = map[string]int{
|
||||
Bar: 100,
|
||||
BarStacked: 100,
|
||||
BarPercentStacked: 100,
|
||||
Bar3DClustered: 100,
|
||||
Bar3DStacked: 100,
|
||||
Bar3DPercentStacked: 100,
|
||||
Col: 100,
|
||||
ColStacked: 100,
|
||||
ColPercentStacked: 100,
|
||||
Col3DClustered: 100,
|
||||
Col3D: 100,
|
||||
Col3DStacked: 100,
|
||||
Col3DPercentStacked: 100,
|
||||
Doughnut: 100,
|
||||
Line: 100,
|
||||
Pie: 100,
|
||||
Pie3D: 100,
|
||||
Radar: 100,
|
||||
Scatter: 100,
|
||||
Area: 100,
|
||||
AreaStacked: 100,
|
||||
AreaPercentStacked: 100,
|
||||
Area3D: 100,
|
||||
Area3DStacked: 100,
|
||||
Area3DPercentStacked: 100,
|
||||
Bar: 100,
|
||||
BarStacked: 100,
|
||||
BarPercentStacked: 100,
|
||||
Bar3DClustered: 100,
|
||||
Bar3DStacked: 100,
|
||||
Bar3DPercentStacked: 100,
|
||||
Col: 100,
|
||||
ColStacked: 100,
|
||||
ColPercentStacked: 100,
|
||||
Col3DClustered: 100,
|
||||
Col3D: 100,
|
||||
Col3DStacked: 100,
|
||||
Col3DPercentStacked: 100,
|
||||
Doughnut: 100,
|
||||
Line: 100,
|
||||
Pie: 100,
|
||||
Pie3D: 100,
|
||||
Radar: 100,
|
||||
Scatter: 100,
|
||||
}
|
||||
chartView3DRAngAx = map[string]int{
|
||||
Bar: 0,
|
||||
BarStacked: 0,
|
||||
BarPercentStacked: 0,
|
||||
Bar3DClustered: 1,
|
||||
Bar3DStacked: 1,
|
||||
Bar3DPercentStacked: 1,
|
||||
Col: 0,
|
||||
ColStacked: 0,
|
||||
ColPercentStacked: 0,
|
||||
Col3DClustered: 1,
|
||||
Col3D: 1,
|
||||
Col3DStacked: 1,
|
||||
Col3DPercentStacked: 1,
|
||||
Doughnut: 0,
|
||||
Line: 0,
|
||||
Pie: 0,
|
||||
Pie3D: 0,
|
||||
Radar: 0,
|
||||
Scatter: 0,
|
||||
Area: 0,
|
||||
AreaStacked: 0,
|
||||
AreaPercentStacked: 0,
|
||||
Area3D: 1,
|
||||
Area3DStacked: 1,
|
||||
Area3DPercentStacked: 1,
|
||||
Bar: 0,
|
||||
BarStacked: 0,
|
||||
BarPercentStacked: 0,
|
||||
Bar3DClustered: 1,
|
||||
Bar3DStacked: 1,
|
||||
Bar3DPercentStacked: 1,
|
||||
Col: 0,
|
||||
ColStacked: 0,
|
||||
ColPercentStacked: 0,
|
||||
Col3DClustered: 1,
|
||||
Col3D: 1,
|
||||
Col3DStacked: 1,
|
||||
Col3DPercentStacked: 1,
|
||||
Doughnut: 0,
|
||||
Line: 0,
|
||||
Pie: 0,
|
||||
Pie3D: 0,
|
||||
Radar: 0,
|
||||
Scatter: 0,
|
||||
}
|
||||
chartLegendPosition = map[string]string{
|
||||
"bottom": "b",
|
||||
|
@ -133,41 +163,80 @@ var (
|
|||
"top_right": "tr",
|
||||
}
|
||||
chartValAxNumFmtFormatCode = map[string]string{
|
||||
Bar: "General",
|
||||
BarStacked: "General",
|
||||
BarPercentStacked: "0%",
|
||||
Bar3DClustered: "General",
|
||||
Bar3DStacked: "General",
|
||||
Bar3DPercentStacked: "0%",
|
||||
Col: "General",
|
||||
ColStacked: "General",
|
||||
ColPercentStacked: "0%",
|
||||
Col3DClustered: "General",
|
||||
Col3D: "General",
|
||||
Col3DStacked: "General",
|
||||
Col3DPercentStacked: "0%",
|
||||
Doughnut: "General",
|
||||
Line: "General",
|
||||
Pie: "General",
|
||||
Pie3D: "General",
|
||||
Radar: "General",
|
||||
Scatter: "General",
|
||||
Area: "General",
|
||||
AreaStacked: "General",
|
||||
AreaPercentStacked: "0%",
|
||||
Area3D: "General",
|
||||
Area3DStacked: "General",
|
||||
Area3DPercentStacked: "0%",
|
||||
Bar: "General",
|
||||
BarStacked: "General",
|
||||
BarPercentStacked: "0%",
|
||||
Bar3DClustered: "General",
|
||||
Bar3DStacked: "General",
|
||||
Bar3DPercentStacked: "0%",
|
||||
Col: "General",
|
||||
ColStacked: "General",
|
||||
ColPercentStacked: "0%",
|
||||
Col3DClustered: "General",
|
||||
Col3D: "General",
|
||||
Col3DStacked: "General",
|
||||
Col3DPercentStacked: "0%",
|
||||
Doughnut: "General",
|
||||
Line: "General",
|
||||
Pie: "General",
|
||||
Pie3D: "General",
|
||||
Radar: "General",
|
||||
Scatter: "General",
|
||||
}
|
||||
chartValAxCrossBetween = map[string]string{
|
||||
Area: "midCat",
|
||||
AreaStacked: "midCat",
|
||||
AreaPercentStacked: "midCat",
|
||||
Area3D: "midCat",
|
||||
Area3DStacked: "midCat",
|
||||
Area3DPercentStacked: "midCat",
|
||||
Bar: "between",
|
||||
BarStacked: "between",
|
||||
BarPercentStacked: "between",
|
||||
Bar3DClustered: "between",
|
||||
Bar3DStacked: "between",
|
||||
Bar3DPercentStacked: "between",
|
||||
Col: "between",
|
||||
ColStacked: "between",
|
||||
ColPercentStacked: "between",
|
||||
Col3DClustered: "between",
|
||||
Col3D: "between",
|
||||
Col3DStacked: "between",
|
||||
Col3DPercentStacked: "between",
|
||||
Doughnut: "between",
|
||||
Line: "between",
|
||||
Pie: "between",
|
||||
Pie3D: "between",
|
||||
Radar: "between",
|
||||
Scatter: "between",
|
||||
}
|
||||
plotAreaChartGrouping = map[string]string{
|
||||
Bar: "clustered",
|
||||
BarStacked: "stacked",
|
||||
BarPercentStacked: "percentStacked",
|
||||
Bar3DClustered: "clustered",
|
||||
Bar3DStacked: "stacked",
|
||||
Bar3DPercentStacked: "percentStacked",
|
||||
Col: "clustered",
|
||||
ColStacked: "stacked",
|
||||
ColPercentStacked: "percentStacked",
|
||||
Col3DClustered: "clustered",
|
||||
Col3D: "standard",
|
||||
Col3DStacked: "stacked",
|
||||
Col3DPercentStacked: "percentStacked",
|
||||
Line: "standard",
|
||||
Area: "standard",
|
||||
AreaStacked: "stacked",
|
||||
AreaPercentStacked: "percentStacked",
|
||||
Area3D: "standard",
|
||||
Area3DStacked: "stacked",
|
||||
Area3DPercentStacked: "percentStacked",
|
||||
Bar: "clustered",
|
||||
BarStacked: "stacked",
|
||||
BarPercentStacked: "percentStacked",
|
||||
Bar3DClustered: "clustered",
|
||||
Bar3DStacked: "stacked",
|
||||
Bar3DPercentStacked: "percentStacked",
|
||||
Col: "clustered",
|
||||
ColStacked: "stacked",
|
||||
ColPercentStacked: "percentStacked",
|
||||
Col3DClustered: "clustered",
|
||||
Col3D: "standard",
|
||||
Col3DStacked: "stacked",
|
||||
Col3DPercentStacked: "percentStacked",
|
||||
Line: "standard",
|
||||
}
|
||||
plotAreaChartBarDir = map[string]string{
|
||||
Bar: "bar",
|
||||
|
@ -262,27 +331,33 @@ func parseFormatChartSet(formatSet string) (*formatChart, error) {
|
|||
//
|
||||
// The following shows the type of chart supported by excelize:
|
||||
//
|
||||
// Type | Chart
|
||||
// ---------------------+------------------------------
|
||||
// bar | 2D clustered bar chart
|
||||
// barStacked | 2D stacked bar chart
|
||||
// barPercentStacked | 2D 100% stacked bar chart
|
||||
// bar3DClustered | 3D clustered bar chart
|
||||
// bar3DStacked | 3D stacked bar chart
|
||||
// bar3DPercentStacked | 3D 100% stacked bar chart
|
||||
// col | 2D clustered column chart
|
||||
// colStacked | 2D stacked column chart
|
||||
// colPercentStacked | 2D 100% stacked column chart
|
||||
// col3DClustered | 3D clustered column chart
|
||||
// col3D | 3D column chart
|
||||
// col3DStacked | 3D stacked column chart
|
||||
// col3DPercentStacked | 3D 100% stacked column chart
|
||||
// doughnut | doughnut chart
|
||||
// line | line chart
|
||||
// pie | pie chart
|
||||
// pie3D | 3D pie chart
|
||||
// radar | radar chart
|
||||
// scatter | scatter chart
|
||||
// Type | Chart
|
||||
// ----------------------+------------------------------
|
||||
// area | 2D area chart
|
||||
// areaStacked | 2D stacked area chart
|
||||
// areaPercentStacked | 2D 100% stacked area chart
|
||||
// area3D | 3D area chart
|
||||
// area3DStacked | 3D stacked area chart
|
||||
// area3DPercentStacked | 3D 100% stacked area chart
|
||||
// bar | 2D clustered bar chart
|
||||
// barStacked | 2D stacked bar chart
|
||||
// barPercentStacked | 2D 100% stacked bar chart
|
||||
// bar3DClustered | 3D clustered bar chart
|
||||
// bar3DStacked | 3D stacked bar chart
|
||||
// bar3DPercentStacked | 3D 100% stacked bar chart
|
||||
// col | 2D clustered column chart
|
||||
// colStacked | 2D stacked column chart
|
||||
// colPercentStacked | 2D 100% stacked column chart
|
||||
// col3DClustered | 3D clustered column chart
|
||||
// col3D | 3D column chart
|
||||
// col3DStacked | 3D stacked column chart
|
||||
// col3DPercentStacked | 3D 100% stacked column chart
|
||||
// doughnut | doughnut chart
|
||||
// line | line chart
|
||||
// pie | pie chart
|
||||
// pie3D | 3D pie chart
|
||||
// radar | radar chart
|
||||
// scatter | scatter chart
|
||||
//
|
||||
// In Excel a chart series is a collection of information that defines which data is plotted such as values, axis labels and formatting.
|
||||
//
|
||||
|
@ -546,25 +621,31 @@ func (f *File) addChart(formatSet *formatChart) {
|
|||
},
|
||||
}
|
||||
plotAreaFunc := map[string]func(*formatChart) *cPlotArea{
|
||||
Bar: f.drawBaseChart,
|
||||
BarStacked: f.drawBaseChart,
|
||||
BarPercentStacked: f.drawBaseChart,
|
||||
Bar3DClustered: f.drawBaseChart,
|
||||
Bar3DStacked: f.drawBaseChart,
|
||||
Bar3DPercentStacked: f.drawBaseChart,
|
||||
Col: f.drawBaseChart,
|
||||
ColStacked: f.drawBaseChart,
|
||||
ColPercentStacked: f.drawBaseChart,
|
||||
Col3DClustered: f.drawBaseChart,
|
||||
Col3D: f.drawBaseChart,
|
||||
Col3DStacked: f.drawBaseChart,
|
||||
Col3DPercentStacked: f.drawBaseChart,
|
||||
Doughnut: f.drawDoughnutChart,
|
||||
Line: f.drawLineChart,
|
||||
Pie3D: f.drawPie3DChart,
|
||||
Pie: f.drawPieChart,
|
||||
Radar: f.drawRadarChart,
|
||||
Scatter: f.drawScatterChart,
|
||||
Area: f.drawBaseChart,
|
||||
AreaStacked: f.drawBaseChart,
|
||||
AreaPercentStacked: f.drawBaseChart,
|
||||
Area3D: f.drawBaseChart,
|
||||
Area3DStacked: f.drawBaseChart,
|
||||
Area3DPercentStacked: f.drawBaseChart,
|
||||
Bar: f.drawBaseChart,
|
||||
BarStacked: f.drawBaseChart,
|
||||
BarPercentStacked: f.drawBaseChart,
|
||||
Bar3DClustered: f.drawBaseChart,
|
||||
Bar3DStacked: f.drawBaseChart,
|
||||
Bar3DPercentStacked: f.drawBaseChart,
|
||||
Col: f.drawBaseChart,
|
||||
ColStacked: f.drawBaseChart,
|
||||
ColPercentStacked: f.drawBaseChart,
|
||||
Col3DClustered: f.drawBaseChart,
|
||||
Col3D: f.drawBaseChart,
|
||||
Col3DStacked: f.drawBaseChart,
|
||||
Col3DPercentStacked: f.drawBaseChart,
|
||||
Doughnut: f.drawDoughnutChart,
|
||||
Line: f.drawLineChart,
|
||||
Pie3D: f.drawPie3DChart,
|
||||
Pie: f.drawPieChart,
|
||||
Radar: f.drawRadarChart,
|
||||
Scatter: f.drawScatterChart,
|
||||
}
|
||||
xlsxChartSpace.Chart.PlotArea = plotAreaFunc[formatSet.Type](formatSet)
|
||||
|
||||
|
@ -593,14 +674,48 @@ func (f *File) drawBaseChart(formatSet *formatChart) *cPlotArea {
|
|||
{Val: 753999904},
|
||||
},
|
||||
}
|
||||
c.BarDir.Val = plotAreaChartBarDir[formatSet.Type]
|
||||
var ok bool
|
||||
c.BarDir.Val, ok = plotAreaChartBarDir[formatSet.Type]
|
||||
if !ok {
|
||||
c.BarDir = nil
|
||||
}
|
||||
c.Grouping.Val = plotAreaChartGrouping[formatSet.Type]
|
||||
if formatSet.Type == "colStacked" || formatSet.Type == "barStacked" || formatSet.Type == "barPercentStacked" || formatSet.Type == "colPercentStacked" {
|
||||
if formatSet.Type == "colStacked" || formatSet.Type == "barStacked" || formatSet.Type == "barPercentStacked" || formatSet.Type == "colPercentStacked" || formatSet.Type == "areaPercentStacked" {
|
||||
c.Overlap = &attrValInt{Val: 100}
|
||||
}
|
||||
catAx := f.drawPlotAreaCatAx(formatSet)
|
||||
valAx := f.drawPlotAreaValAx(formatSet)
|
||||
charts := map[string]*cPlotArea{
|
||||
"area": {
|
||||
AreaChart: &c,
|
||||
CatAx: catAx,
|
||||
ValAx: valAx,
|
||||
},
|
||||
"areaStacked": {
|
||||
AreaChart: &c,
|
||||
CatAx: catAx,
|
||||
ValAx: valAx,
|
||||
},
|
||||
"areaPercentStacked": {
|
||||
AreaChart: &c,
|
||||
CatAx: catAx,
|
||||
ValAx: valAx,
|
||||
},
|
||||
"area3D": {
|
||||
Area3DChart: &c,
|
||||
CatAx: catAx,
|
||||
ValAx: valAx,
|
||||
},
|
||||
"area3DStacked": {
|
||||
Area3DChart: &c,
|
||||
CatAx: catAx,
|
||||
ValAx: valAx,
|
||||
},
|
||||
"area3DPercentStacked": {
|
||||
Area3DChart: &c,
|
||||
CatAx: catAx,
|
||||
ValAx: valAx,
|
||||
},
|
||||
"bar": {
|
||||
BarChart: &c,
|
||||
CatAx: catAx,
|
||||
|
@ -826,7 +941,7 @@ func (f *File) drawChartSeriesSpPr(i int, formatSet *formatChart) *cSpPr {
|
|||
},
|
||||
},
|
||||
}
|
||||
chartSeriesSpPr := map[string]*cSpPr{Bar: nil, BarStacked: nil, BarPercentStacked: nil, Bar3DClustered: nil, Bar3DStacked: nil, Bar3DPercentStacked: nil, Col: nil, ColStacked: nil, ColPercentStacked: nil, Col3DClustered: nil, Col3D: nil, Col3DStacked: nil, Col3DPercentStacked: nil, Doughnut: nil, Line: spPrLine, Pie: nil, Pie3D: nil, Radar: nil, Scatter: spPrScatter}
|
||||
chartSeriesSpPr := map[string]*cSpPr{Area: nil, AreaStacked: nil, AreaPercentStacked: nil, Area3D: nil, Area3DStacked: nil, Area3DPercentStacked: nil, Bar: nil, BarStacked: nil, BarPercentStacked: nil, Bar3DClustered: nil, Bar3DStacked: nil, Bar3DPercentStacked: nil, Col: nil, ColStacked: nil, ColPercentStacked: nil, Col3DClustered: nil, Col3D: nil, Col3DStacked: nil, Col3DPercentStacked: nil, Doughnut: nil, Line: spPrLine, Pie: nil, Pie3D: nil, Radar: nil, Scatter: spPrScatter}
|
||||
return chartSeriesSpPr[formatSet.Type]
|
||||
}
|
||||
|
||||
|
@ -855,7 +970,7 @@ func (f *File) drawChartSeriesDPt(i int, formatSet *formatChart) []*cDPt {
|
|||
},
|
||||
},
|
||||
}}
|
||||
chartSeriesDPt := map[string][]*cDPt{Bar: nil, BarStacked: nil, BarPercentStacked: nil, Bar3DClustered: nil, Bar3DStacked: nil, Bar3DPercentStacked: nil, Col: nil, ColStacked: nil, ColPercentStacked: nil, Col3DClustered: nil, Col3D: nil, Col3DStacked: nil, Col3DPercentStacked: nil, Doughnut: nil, Line: nil, Pie: dpt, Pie3D: dpt, Radar: nil, Scatter: nil}
|
||||
chartSeriesDPt := map[string][]*cDPt{Area: nil, AreaStacked: nil, AreaPercentStacked: nil, Area3D: nil, Area3DStacked: nil, Area3DPercentStacked: nil, Bar: nil, BarStacked: nil, BarPercentStacked: nil, Bar3DClustered: nil, Bar3DStacked: nil, Bar3DPercentStacked: nil, Col: nil, ColStacked: nil, ColPercentStacked: nil, Col3DClustered: nil, Col3D: nil, Col3DStacked: nil, Col3DPercentStacked: nil, Doughnut: nil, Line: nil, Pie: dpt, Pie3D: dpt, Radar: nil, Scatter: nil}
|
||||
return chartSeriesDPt[formatSet.Type]
|
||||
}
|
||||
|
||||
|
@ -867,7 +982,7 @@ func (f *File) drawChartSeriesCat(v formatChartSeries, formatSet *formatChart) *
|
|||
F: v.Categories,
|
||||
},
|
||||
}
|
||||
chartSeriesCat := map[string]*cCat{Bar: cat, BarStacked: cat, BarPercentStacked: cat, Bar3DClustered: cat, Bar3DStacked: cat, Bar3DPercentStacked: cat, Col: cat, ColStacked: cat, ColPercentStacked: cat, Col3DClustered: cat, Col3D: cat, Col3DStacked: cat, Col3DPercentStacked: cat, Doughnut: cat, Line: cat, Pie: cat, Pie3D: cat, Radar: cat, Scatter: nil}
|
||||
chartSeriesCat := map[string]*cCat{Area: cat, AreaStacked: cat, AreaPercentStacked: cat, Area3D: cat, Area3DStacked: cat, Area3DPercentStacked: cat, Bar: cat, BarStacked: cat, BarPercentStacked: cat, Bar3DClustered: cat, Bar3DStacked: cat, Bar3DPercentStacked: cat, Col: cat, ColStacked: cat, ColPercentStacked: cat, Col3DClustered: cat, Col3D: cat, Col3DStacked: cat, Col3DPercentStacked: cat, Doughnut: cat, Line: cat, Pie: cat, Pie3D: cat, Radar: cat, Scatter: nil}
|
||||
return chartSeriesCat[formatSet.Type]
|
||||
}
|
||||
|
||||
|
@ -879,7 +994,7 @@ func (f *File) drawChartSeriesVal(v formatChartSeries, formatSet *formatChart) *
|
|||
F: v.Values,
|
||||
},
|
||||
}
|
||||
chartSeriesVal := map[string]*cVal{Bar: val, BarStacked: val, BarPercentStacked: val, Bar3DClustered: val, Bar3DStacked: val, Bar3DPercentStacked: val, Col: val, ColStacked: val, ColPercentStacked: val, Col3DClustered: val, Col3D: val, Col3DStacked: val, Col3DPercentStacked: val, Doughnut: val, Line: val, Pie: val, Pie3D: val, Radar: val, Scatter: nil}
|
||||
chartSeriesVal := map[string]*cVal{Area: val, AreaStacked: val, AreaPercentStacked: val, Area3D: val, Area3DStacked: val, Area3DPercentStacked: val, Bar: val, BarStacked: val, BarPercentStacked: val, Bar3DClustered: val, Bar3DStacked: val, Bar3DPercentStacked: val, Col: val, ColStacked: val, ColPercentStacked: val, Col3DClustered: val, Col3D: val, Col3DStacked: val, Col3DPercentStacked: val, Doughnut: val, Line: val, Pie: val, Pie3D: val, Radar: val, Scatter: nil}
|
||||
return chartSeriesVal[formatSet.Type]
|
||||
}
|
||||
|
||||
|
@ -905,7 +1020,7 @@ func (f *File) drawChartSeriesMarker(i int, formatSet *formatChart) *cMarker {
|
|||
},
|
||||
},
|
||||
}
|
||||
chartSeriesMarker := map[string]*cMarker{Bar: nil, BarStacked: nil, BarPercentStacked: nil, Bar3DClustered: nil, Bar3DStacked: nil, Bar3DPercentStacked: nil, Col: nil, ColStacked: nil, ColPercentStacked: nil, Col3DClustered: nil, Col3D: nil, Col3DStacked: nil, Col3DPercentStacked: nil, Doughnut: nil, Line: nil, Pie: nil, Pie3D: nil, Radar: nil, Scatter: marker}
|
||||
chartSeriesMarker := map[string]*cMarker{Area: nil, AreaStacked: nil, AreaPercentStacked: nil, Area3D: nil, Area3DStacked: nil, Area3DPercentStacked: nil, Bar: nil, BarStacked: nil, BarPercentStacked: nil, Bar3DClustered: nil, Bar3DStacked: nil, Bar3DPercentStacked: nil, Col: nil, ColStacked: nil, ColPercentStacked: nil, Col3DClustered: nil, Col3D: nil, Col3DStacked: nil, Col3DPercentStacked: nil, Doughnut: nil, Line: nil, Pie: nil, Pie3D: nil, Radar: nil, Scatter: marker}
|
||||
return chartSeriesMarker[formatSet.Type]
|
||||
}
|
||||
|
||||
|
@ -917,7 +1032,7 @@ func (f *File) drawChartSeriesXVal(v formatChartSeries, formatSet *formatChart)
|
|||
F: v.Categories,
|
||||
},
|
||||
}
|
||||
chartSeriesXVal := map[string]*cCat{Bar: nil, BarStacked: nil, BarPercentStacked: nil, Bar3DClustered: nil, Bar3DStacked: nil, Bar3DPercentStacked: nil, Col: nil, ColStacked: nil, ColPercentStacked: nil, Col3DClustered: nil, Col3D: nil, Col3DStacked: nil, Col3DPercentStacked: nil, Doughnut: nil, Line: nil, Pie: nil, Pie3D: nil, Radar: nil, Scatter: cat}
|
||||
chartSeriesXVal := map[string]*cCat{Area: nil, AreaStacked: nil, AreaPercentStacked: nil, Area3D: nil, Area3DStacked: nil, Area3DPercentStacked: nil, Bar: nil, BarStacked: nil, BarPercentStacked: nil, Bar3DClustered: nil, Bar3DStacked: nil, Bar3DPercentStacked: nil, Col: nil, ColStacked: nil, ColPercentStacked: nil, Col3DClustered: nil, Col3D: nil, Col3DStacked: nil, Col3DPercentStacked: nil, Doughnut: nil, Line: nil, Pie: nil, Pie3D: nil, Radar: nil, Scatter: cat}
|
||||
return chartSeriesXVal[formatSet.Type]
|
||||
}
|
||||
|
||||
|
@ -929,7 +1044,7 @@ func (f *File) drawChartSeriesYVal(v formatChartSeries, formatSet *formatChart)
|
|||
F: v.Values,
|
||||
},
|
||||
}
|
||||
chartSeriesYVal := map[string]*cVal{Bar: nil, BarStacked: nil, BarPercentStacked: nil, Bar3DClustered: nil, Bar3DStacked: nil, Bar3DPercentStacked: nil, Col: nil, ColStacked: nil, ColPercentStacked: nil, Col3DClustered: nil, Col3D: nil, Col3DStacked: nil, Col3DPercentStacked: nil, Doughnut: nil, Line: nil, Pie: nil, Pie3D: nil, Radar: nil, Scatter: val}
|
||||
chartSeriesYVal := map[string]*cVal{Area: nil, AreaStacked: nil, AreaPercentStacked: nil, Area3D: nil, Area3DStacked: nil, Area3DPercentStacked: nil, Bar: nil, BarStacked: nil, BarPercentStacked: nil, Bar3DClustered: nil, Bar3DStacked: nil, Bar3DPercentStacked: nil, Col: nil, ColStacked: nil, ColPercentStacked: nil, Col3DClustered: nil, Col3D: nil, Col3DStacked: nil, Col3DPercentStacked: nil, Doughnut: nil, Line: nil, Pie: nil, Pie3D: nil, Radar: nil, Scatter: val}
|
||||
return chartSeriesYVal[formatSet.Type]
|
||||
}
|
||||
|
||||
|
@ -951,7 +1066,7 @@ func (f *File) drawChartDLbls(formatSet *formatChart) *cDLbls {
|
|||
// given format sets.
|
||||
func (f *File) drawChartSeriesDLbls(formatSet *formatChart) *cDLbls {
|
||||
dLbls := f.drawChartDLbls(formatSet)
|
||||
chartSeriesDLbls := map[string]*cDLbls{Bar: dLbls, BarStacked: dLbls, BarPercentStacked: dLbls, Bar3DClustered: dLbls, Bar3DStacked: dLbls, Bar3DPercentStacked: dLbls, Col: dLbls, ColStacked: dLbls, ColPercentStacked: dLbls, Col3DClustered: dLbls, Col3D: dLbls, Col3DStacked: dLbls, Col3DPercentStacked: dLbls, Doughnut: dLbls, Line: dLbls, Pie: dLbls, Pie3D: dLbls, Radar: dLbls, Scatter: nil}
|
||||
chartSeriesDLbls := map[string]*cDLbls{Area: dLbls, AreaStacked: dLbls, AreaPercentStacked: dLbls, Area3D: dLbls, Area3DStacked: dLbls, Area3DPercentStacked: dLbls, Bar: dLbls, BarStacked: dLbls, BarPercentStacked: dLbls, Bar3DClustered: dLbls, Bar3DStacked: dLbls, Bar3DPercentStacked: dLbls, Col: dLbls, ColStacked: dLbls, ColPercentStacked: dLbls, Col3DClustered: dLbls, Col3D: dLbls, Col3DStacked: dLbls, Col3DPercentStacked: dLbls, Doughnut: dLbls, Line: dLbls, Pie: dLbls, Pie3D: dLbls, Radar: dLbls, Scatter: nil}
|
||||
return chartSeriesDLbls[formatSet.Type]
|
||||
}
|
||||
|
||||
|
@ -1025,7 +1140,7 @@ func (f *File) drawPlotAreaValAx(formatSet *formatChart) []*cAxs {
|
|||
TxPr: f.drawPlotAreaTxPr(),
|
||||
CrossAx: &attrValInt{Val: 754001152},
|
||||
Crosses: &attrValString{Val: "autoZero"},
|
||||
CrossBetween: &attrValString{Val: "between"},
|
||||
CrossBetween: &attrValString{Val: chartValAxCrossBetween[formatSet.Type]},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -959,6 +959,13 @@ func TestAddChart(t *testing.T) {
|
|||
xlsx.AddChart("Sheet2", "X64", `{"type":"bar3DClustered","series":[{"name":"Sheet1!$A$30","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$30:$D$30"},{"name":"Sheet1!$A$31","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$31:$D$31"},{"name":"Sheet1!$A$32","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$32:$D$32"}],"format":{"x_scale":1.0,"y_scale":1.0,"x_offset":15,"y_offset":10,"print_obj":true,"lock_aspect_ratio":false,"locked":false},"legend":{"position":"left","show_legend_key":false},"title":{"name":"Fruit 3D Clustered Bar Chart"},"plotarea":{"show_bubble_size":true,"show_cat_name":false,"show_leader_lines":false,"show_percent":true,"show_series_name":true,"show_val":true},"show_blanks_as":"zero"}`)
|
||||
xlsx.AddChart("Sheet2", "P80", `{"type":"bar3DStacked","series":[{"name":"Sheet1!$A$30","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$30:$D$30"},{"name":"Sheet1!$A$31","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$31:$D$31"},{"name":"Sheet1!$A$32","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$32:$D$32"}],"format":{"x_scale":1.0,"y_scale":1.0,"x_offset":15,"y_offset":10,"print_obj":true,"lock_aspect_ratio":false,"locked":false},"legend":{"position":"left","show_legend_key":false},"title":{"name":"Fruit 3D Stacked Bar Chart"},"plotarea":{"show_bubble_size":true,"show_cat_name":false,"show_leader_lines":false,"show_percent":true,"show_series_name":true,"show_val":true},"show_blanks_as":"zero","y_axis":{"maximum":7.5,"minimum":0.5}}`)
|
||||
xlsx.AddChart("Sheet2", "X80", `{"type":"bar3DPercentStacked","series":[{"name":"Sheet1!$A$30","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$30:$D$30"},{"name":"Sheet1!$A$31","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$31:$D$31"},{"name":"Sheet1!$A$32","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$32:$D$32"}],"format":{"x_scale":1.0,"y_scale":1.0,"x_offset":15,"y_offset":10,"print_obj":true,"lock_aspect_ratio":false,"locked":false},"legend":{"position":"left","show_legend_key":false},"title":{"name":"Fruit 3D 100% Stacked Bar Chart"},"plotarea":{"show_bubble_size":true,"show_cat_name":false,"show_leader_lines":false,"show_percent":true,"show_series_name":true,"show_val":true},"show_blanks_as":"zero","x_axis":{"reverse_order":true,"maximum":0,"minimum":0},"y_axis":{"reverse_order":true,"maximum":0,"minimum":0}}`)
|
||||
// area series charts
|
||||
xlsx.AddChart("Sheet2", "AF1", `{"type":"area","series":[{"name":"Sheet1!$A$30","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$30:$D$30"},{"name":"Sheet1!$A$31","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$31:$D$31"},{"name":"Sheet1!$A$32","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$32:$D$32"}],"format":{"x_scale":1.0,"y_scale":1.0,"x_offset":15,"y_offset":10,"print_obj":true,"lock_aspect_ratio":false,"locked":false},"legend":{"position":"left","show_legend_key":false},"title":{"name":"Fruit 2D Area Chart"},"plotarea":{"show_bubble_size":true,"show_cat_name":false,"show_leader_lines":false,"show_percent":true,"show_series_name":true,"show_val":true},"show_blanks_as":"zero"}`)
|
||||
xlsx.AddChart("Sheet2", "AN1", `{"type":"areaStacked","series":[{"name":"Sheet1!$A$30","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$30:$D$30"},{"name":"Sheet1!$A$31","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$31:$D$31"},{"name":"Sheet1!$A$32","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$32:$D$32"}],"format":{"x_scale":1.0,"y_scale":1.0,"x_offset":15,"y_offset":10,"print_obj":true,"lock_aspect_ratio":false,"locked":false},"legend":{"position":"left","show_legend_key":false},"title":{"name":"Fruit 2D Stacked Area Chart"},"plotarea":{"show_bubble_size":true,"show_cat_name":false,"show_leader_lines":false,"show_percent":true,"show_series_name":true,"show_val":true},"show_blanks_as":"zero"}`)
|
||||
xlsx.AddChart("Sheet2", "AF16", `{"type":"areaPercentStacked","series":[{"name":"Sheet1!$A$30","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$30:$D$30"},{"name":"Sheet1!$A$31","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$31:$D$31"},{"name":"Sheet1!$A$32","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$32:$D$32"}],"format":{"x_scale":1.0,"y_scale":1.0,"x_offset":15,"y_offset":10,"print_obj":true,"lock_aspect_ratio":false,"locked":false},"legend":{"position":"left","show_legend_key":false},"title":{"name":"Fruit 2D 100% Stacked Area Chart"},"plotarea":{"show_bubble_size":true,"show_cat_name":false,"show_leader_lines":false,"show_percent":true,"show_series_name":true,"show_val":true},"show_blanks_as":"zero"}`)
|
||||
xlsx.AddChart("Sheet2", "AN16", `{"type":"area3D","series":[{"name":"Sheet1!$A$30","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$30:$D$30"},{"name":"Sheet1!$A$31","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$31:$D$31"},{"name":"Sheet1!$A$32","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$32:$D$32"}],"format":{"x_scale":1.0,"y_scale":1.0,"x_offset":15,"y_offset":10,"print_obj":true,"lock_aspect_ratio":false,"locked":false},"legend":{"position":"left","show_legend_key":false},"title":{"name":"Fruit 3D Area Chart"},"plotarea":{"show_bubble_size":true,"show_cat_name":false,"show_leader_lines":false,"show_percent":true,"show_series_name":true,"show_val":true},"show_blanks_as":"zero"}`)
|
||||
xlsx.AddChart("Sheet2", "AF32", `{"type":"area3DStacked","series":[{"name":"Sheet1!$A$30","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$30:$D$30"},{"name":"Sheet1!$A$31","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$31:$D$31"},{"name":"Sheet1!$A$32","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$32:$D$32"}],"format":{"x_scale":1.0,"y_scale":1.0,"x_offset":15,"y_offset":10,"print_obj":true,"lock_aspect_ratio":false,"locked":false},"legend":{"position":"left","show_legend_key":false},"title":{"name":"Fruit 3D Stacked Area Chart"},"plotarea":{"show_bubble_size":true,"show_cat_name":false,"show_leader_lines":false,"show_percent":true,"show_series_name":true,"show_val":true},"show_blanks_as":"zero"}`)
|
||||
xlsx.AddChart("Sheet2", "AN32", `{"type":"area3DPercentStacked","series":[{"name":"Sheet1!$A$30","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$30:$D$30"},{"name":"Sheet1!$A$31","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$31:$D$31"},{"name":"Sheet1!$A$32","categories":"Sheet1!$B$29:$D$29","values":"Sheet1!$B$32:$D$32"}],"format":{"x_scale":1.0,"y_scale":1.0,"x_offset":15,"y_offset":10,"print_obj":true,"lock_aspect_ratio":false,"locked":false},"legend":{"position":"left","show_legend_key":false},"title":{"name":"Fruit 3D 100% Stacked Area Chart"},"plotarea":{"show_bubble_size":true,"show_cat_name":false,"show_leader_lines":false,"show_percent":true,"show_series_name":true,"show_val":true},"show_blanks_as":"zero"}`)
|
||||
// Save xlsx file by the given path.
|
||||
err = xlsx.SaveAs("./test/Book_addchart.xlsx")
|
||||
if err != nil {
|
||||
|
|
|
@ -301,6 +301,8 @@ type cView3D struct {
|
|||
// plot area of the chart.
|
||||
type cPlotArea struct {
|
||||
Layout *string `xml:"c:layout"`
|
||||
AreaChart *cCharts `xml:"c:areaChart"`
|
||||
Area3DChart *cCharts `xml:"c:area3DChart"`
|
||||
BarChart *cCharts `xml:"c:barChart"`
|
||||
Bar3DChart *cCharts `xml:"c:bar3DChart"`
|
||||
DoughnutChart *cCharts `xml:"c:doughnutChart"`
|
||||
|
|
Loading…
Reference in New Issue