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
139
chart.go
139
chart.go
|
@ -18,6 +18,12 @@ import (
|
||||||
|
|
||||||
// This section defines the currently supported chart types.
|
// This section defines the currently supported chart types.
|
||||||
const (
|
const (
|
||||||
|
Area = "area"
|
||||||
|
AreaStacked = "areaStacked"
|
||||||
|
AreaPercentStacked = "areaPercentStacked"
|
||||||
|
Area3D = "area3D"
|
||||||
|
Area3DStacked = "area3DStacked"
|
||||||
|
Area3DPercentStacked = "area3DPercentStacked"
|
||||||
Bar = "bar"
|
Bar = "bar"
|
||||||
BarStacked = "barStacked"
|
BarStacked = "barStacked"
|
||||||
BarPercentStacked = "barPercentStacked"
|
BarPercentStacked = "barPercentStacked"
|
||||||
|
@ -42,6 +48,12 @@ const (
|
||||||
// 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[string]int{
|
||||||
|
Area: 0,
|
||||||
|
AreaStacked: 0,
|
||||||
|
AreaPercentStacked: 0,
|
||||||
|
Area3D: 15,
|
||||||
|
Area3DStacked: 15,
|
||||||
|
Area3DPercentStacked: 15,
|
||||||
Bar: 0,
|
Bar: 0,
|
||||||
BarStacked: 0,
|
BarStacked: 0,
|
||||||
BarPercentStacked: 0,
|
BarPercentStacked: 0,
|
||||||
|
@ -63,6 +75,12 @@ var (
|
||||||
Scatter: 0,
|
Scatter: 0,
|
||||||
}
|
}
|
||||||
chartView3DRotY = map[string]int{
|
chartView3DRotY = map[string]int{
|
||||||
|
Area: 0,
|
||||||
|
AreaStacked: 0,
|
||||||
|
AreaPercentStacked: 0,
|
||||||
|
Area3D: 20,
|
||||||
|
Area3DStacked: 20,
|
||||||
|
Area3DPercentStacked: 20,
|
||||||
Bar: 0,
|
Bar: 0,
|
||||||
BarStacked: 0,
|
BarStacked: 0,
|
||||||
BarPercentStacked: 0,
|
BarPercentStacked: 0,
|
||||||
|
@ -84,6 +102,12 @@ var (
|
||||||
Scatter: 0,
|
Scatter: 0,
|
||||||
}
|
}
|
||||||
chartView3DDepthPercent = map[string]int{
|
chartView3DDepthPercent = map[string]int{
|
||||||
|
Area: 100,
|
||||||
|
AreaStacked: 100,
|
||||||
|
AreaPercentStacked: 100,
|
||||||
|
Area3D: 100,
|
||||||
|
Area3DStacked: 100,
|
||||||
|
Area3DPercentStacked: 100,
|
||||||
Bar: 100,
|
Bar: 100,
|
||||||
BarStacked: 100,
|
BarStacked: 100,
|
||||||
BarPercentStacked: 100,
|
BarPercentStacked: 100,
|
||||||
|
@ -105,6 +129,12 @@ var (
|
||||||
Scatter: 100,
|
Scatter: 100,
|
||||||
}
|
}
|
||||||
chartView3DRAngAx = map[string]int{
|
chartView3DRAngAx = map[string]int{
|
||||||
|
Area: 0,
|
||||||
|
AreaStacked: 0,
|
||||||
|
AreaPercentStacked: 0,
|
||||||
|
Area3D: 1,
|
||||||
|
Area3DStacked: 1,
|
||||||
|
Area3DPercentStacked: 1,
|
||||||
Bar: 0,
|
Bar: 0,
|
||||||
BarStacked: 0,
|
BarStacked: 0,
|
||||||
BarPercentStacked: 0,
|
BarPercentStacked: 0,
|
||||||
|
@ -133,6 +163,12 @@ var (
|
||||||
"top_right": "tr",
|
"top_right": "tr",
|
||||||
}
|
}
|
||||||
chartValAxNumFmtFormatCode = map[string]string{
|
chartValAxNumFmtFormatCode = map[string]string{
|
||||||
|
Area: "General",
|
||||||
|
AreaStacked: "General",
|
||||||
|
AreaPercentStacked: "0%",
|
||||||
|
Area3D: "General",
|
||||||
|
Area3DStacked: "General",
|
||||||
|
Area3DPercentStacked: "0%",
|
||||||
Bar: "General",
|
Bar: "General",
|
||||||
BarStacked: "General",
|
BarStacked: "General",
|
||||||
BarPercentStacked: "0%",
|
BarPercentStacked: "0%",
|
||||||
|
@ -153,7 +189,40 @@ var (
|
||||||
Radar: "General",
|
Radar: "General",
|
||||||
Scatter: "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{
|
plotAreaChartGrouping = map[string]string{
|
||||||
|
Area: "standard",
|
||||||
|
AreaStacked: "stacked",
|
||||||
|
AreaPercentStacked: "percentStacked",
|
||||||
|
Area3D: "standard",
|
||||||
|
Area3DStacked: "stacked",
|
||||||
|
Area3DPercentStacked: "percentStacked",
|
||||||
Bar: "clustered",
|
Bar: "clustered",
|
||||||
BarStacked: "stacked",
|
BarStacked: "stacked",
|
||||||
BarPercentStacked: "percentStacked",
|
BarPercentStacked: "percentStacked",
|
||||||
|
@ -263,7 +332,13 @@ func parseFormatChartSet(formatSet string) (*formatChart, error) {
|
||||||
// The following shows the type of chart supported by excelize:
|
// The following shows the type of chart supported by excelize:
|
||||||
//
|
//
|
||||||
// Type | 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
|
// bar | 2D clustered bar chart
|
||||||
// barStacked | 2D stacked bar chart
|
// barStacked | 2D stacked bar chart
|
||||||
// barPercentStacked | 2D 100% stacked bar chart
|
// barPercentStacked | 2D 100% stacked bar chart
|
||||||
|
@ -546,6 +621,12 @@ func (f *File) addChart(formatSet *formatChart) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
plotAreaFunc := map[string]func(*formatChart) *cPlotArea{
|
plotAreaFunc := map[string]func(*formatChart) *cPlotArea{
|
||||||
|
Area: f.drawBaseChart,
|
||||||
|
AreaStacked: f.drawBaseChart,
|
||||||
|
AreaPercentStacked: f.drawBaseChart,
|
||||||
|
Area3D: f.drawBaseChart,
|
||||||
|
Area3DStacked: f.drawBaseChart,
|
||||||
|
Area3DPercentStacked: f.drawBaseChart,
|
||||||
Bar: f.drawBaseChart,
|
Bar: f.drawBaseChart,
|
||||||
BarStacked: f.drawBaseChart,
|
BarStacked: f.drawBaseChart,
|
||||||
BarPercentStacked: f.drawBaseChart,
|
BarPercentStacked: f.drawBaseChart,
|
||||||
|
@ -593,14 +674,48 @@ func (f *File) drawBaseChart(formatSet *formatChart) *cPlotArea {
|
||||||
{Val: 753999904},
|
{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]
|
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}
|
c.Overlap = &attrValInt{Val: 100}
|
||||||
}
|
}
|
||||||
catAx := f.drawPlotAreaCatAx(formatSet)
|
catAx := f.drawPlotAreaCatAx(formatSet)
|
||||||
valAx := f.drawPlotAreaValAx(formatSet)
|
valAx := f.drawPlotAreaValAx(formatSet)
|
||||||
charts := map[string]*cPlotArea{
|
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": {
|
"bar": {
|
||||||
BarChart: &c,
|
BarChart: &c,
|
||||||
CatAx: catAx,
|
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]
|
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]
|
return chartSeriesDPt[formatSet.Type]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -867,7 +982,7 @@ func (f *File) drawChartSeriesCat(v formatChartSeries, formatSet *formatChart) *
|
||||||
F: v.Categories,
|
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]
|
return chartSeriesCat[formatSet.Type]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -879,7 +994,7 @@ func (f *File) drawChartSeriesVal(v formatChartSeries, formatSet *formatChart) *
|
||||||
F: v.Values,
|
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]
|
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]
|
return chartSeriesMarker[formatSet.Type]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -917,7 +1032,7 @@ func (f *File) drawChartSeriesXVal(v formatChartSeries, formatSet *formatChart)
|
||||||
F: v.Categories,
|
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]
|
return chartSeriesXVal[formatSet.Type]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -929,7 +1044,7 @@ func (f *File) drawChartSeriesYVal(v formatChartSeries, formatSet *formatChart)
|
||||||
F: v.Values,
|
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]
|
return chartSeriesYVal[formatSet.Type]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -951,7 +1066,7 @@ func (f *File) drawChartDLbls(formatSet *formatChart) *cDLbls {
|
||||||
// given format sets.
|
// given format sets.
|
||||||
func (f *File) drawChartSeriesDLbls(formatSet *formatChart) *cDLbls {
|
func (f *File) drawChartSeriesDLbls(formatSet *formatChart) *cDLbls {
|
||||||
dLbls := f.drawChartDLbls(formatSet)
|
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]
|
return chartSeriesDLbls[formatSet.Type]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1025,7 +1140,7 @@ func (f *File) drawPlotAreaValAx(formatSet *formatChart) []*cAxs {
|
||||||
TxPr: f.drawPlotAreaTxPr(),
|
TxPr: f.drawPlotAreaTxPr(),
|
||||||
CrossAx: &attrValInt{Val: 754001152},
|
CrossAx: &attrValInt{Val: 754001152},
|
||||||
Crosses: &attrValString{Val: "autoZero"},
|
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", "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", "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}}`)
|
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.
|
// Save xlsx file by the given path.
|
||||||
err = xlsx.SaveAs("./test/Book_addchart.xlsx")
|
err = xlsx.SaveAs("./test/Book_addchart.xlsx")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -301,6 +301,8 @@ type cView3D struct {
|
||||||
// plot area of the chart.
|
// plot area of the chart.
|
||||||
type cPlotArea struct {
|
type cPlotArea struct {
|
||||||
Layout *string `xml:"c:layout"`
|
Layout *string `xml:"c:layout"`
|
||||||
|
AreaChart *cCharts `xml:"c:areaChart"`
|
||||||
|
Area3DChart *cCharts `xml:"c:area3DChart"`
|
||||||
BarChart *cCharts `xml:"c:barChart"`
|
BarChart *cCharts `xml:"c:barChart"`
|
||||||
Bar3DChart *cCharts `xml:"c:bar3DChart"`
|
Bar3DChart *cCharts `xml:"c:bar3DChart"`
|
||||||
DoughnutChart *cCharts `xml:"c:doughnutChart"`
|
DoughnutChart *cCharts `xml:"c:doughnutChart"`
|
||||||
|
|
Loading…
Reference in New Issue