diff options
author | xuri <xuri.me@gmail.com> | 2018-09-27 23:40:00 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-27 23:40:00 +0800 |
commit | 204139739a34aa6e6c5ea8764008276a6d184ff6 (patch) | |
tree | 0b9a795ea20804753134fd54c40d17c5a01c64f6 /chart.go | |
parent | 250946568ca1e5a69c07f19dff4d1d3a2264e31d (diff) | |
parent | 3e004d900b103379c2d62657a3070de4a2e8585a (diff) |
Merge branch 'master' into master
Diffstat (limited to 'chart.go')
-rw-r--r-- | chart.go | 93 |
1 files changed, 52 insertions, 41 deletions
@@ -1,3 +1,12 @@ +// Copyright 2016 - 2018 The excelize Authors. All rights reserved. Use of +// this source code is governed by a BSD-style license that can be found in +// the LICENSE file. +// +// Package excelize providing a set of functions that allow you to write to +// and read from XLSX files. Support reads and writes XLSX file generated by +// Microsoft Excelâ„¢ 2007 and later. Support save file without losing original +// charts of XLSX. This library needs Go version 1.8 or later. + package excelize import ( @@ -190,7 +199,7 @@ var ( } ) -// parseFormatChartSet provides function to parse the format settings of the +// parseFormatChartSet provides a function to parse the format settings of the // chart with default value. func parseFormatChartSet(formatSet string) (*formatChart, error) { format := formatChart{ @@ -352,7 +361,9 @@ func parseFormatChartSet(formatSet string) (*formatChart, error) { // minimum // // reverse_order: Specifies that the categories or values on reverse order (orientation of the chart). The reverse_order property is optional. The default value is false. +// // maximum: Specifies that the fixed maximum, 0 is auto. The maximum property is optional. The default value is auto. +// // minimum: Specifies that the fixed minimum, 0 is auto. The minimum property is optional. The default value is auto. // // Set chart size by dimension property. The dimension property is optional. The default width is 480, and height is 290. @@ -377,7 +388,7 @@ func (f *File) AddChart(sheet, cell, format string) error { return err } -// countCharts provides function to get chart files count storage in the +// countCharts provides a function to get chart files count storage in the // folder xl/charts. func (f *File) countCharts() int { count := 0 @@ -389,7 +400,7 @@ func (f *File) countCharts() int { return count } -// prepareDrawing provides function to prepare drawing ID and XML by given +// prepareDrawing provides a function to prepare drawing ID and XML by given // drawingID, worksheet name and default drawingXML. func (f *File) prepareDrawing(xlsx *xlsxWorksheet, drawingID int, sheet, drawingXML string) (int, string) { sheetRelationshipsDrawingXML := "../drawings/drawing" + strconv.Itoa(drawingID) + ".xml" @@ -406,8 +417,8 @@ func (f *File) prepareDrawing(xlsx *xlsxWorksheet, drawingID int, sheet, drawing return drawingID, drawingXML } -// addChart provides function to create chart as xl/charts/chart%d.xml by given -// format sets. +// addChart provides a function to create chart as xl/charts/chart%d.xml by +// given format sets. func (f *File) addChart(formatSet *formatChart) { count := f.countCharts() xlsxChartSpace := xlsxChartSpace{ @@ -562,7 +573,7 @@ func (f *File) addChart(formatSet *formatChart) { f.saveFileList(media, chart) } -// drawBaseChart provides function to draw the c:plotArea element for bar, +// drawBaseChart provides a function to draw the c:plotArea element for bar, // and column series charts by given format sets. func (f *File) drawBaseChart(formatSet *formatChart) *cPlotArea { c := cCharts{ @@ -659,7 +670,7 @@ func (f *File) drawBaseChart(formatSet *formatChart) *cPlotArea { return charts[formatSet.Type] } -// drawDoughnutChart provides function to draw the c:plotArea element for +// drawDoughnutChart provides a function to draw the c:plotArea element for // doughnut chart by given format sets. func (f *File) drawDoughnutChart(formatSet *formatChart) *cPlotArea { return &cPlotArea{ @@ -673,8 +684,8 @@ func (f *File) drawDoughnutChart(formatSet *formatChart) *cPlotArea { } } -// drawLineChart provides function to draw the c:plotArea element for line chart -// by given format sets. +// drawLineChart provides a function to draw the c:plotArea element for line +// chart by given format sets. func (f *File) drawLineChart(formatSet *formatChart) *cPlotArea { return &cPlotArea{ LineChart: &cCharts{ @@ -699,8 +710,8 @@ func (f *File) drawLineChart(formatSet *formatChart) *cPlotArea { } } -// drawPieChart provides function to draw the c:plotArea element for pie chart -// by given format sets. +// drawPieChart provides a function to draw the c:plotArea element for pie +// chart by given format sets. func (f *File) drawPieChart(formatSet *formatChart) *cPlotArea { return &cPlotArea{ PieChart: &cCharts{ @@ -712,8 +723,8 @@ func (f *File) drawPieChart(formatSet *formatChart) *cPlotArea { } } -// drawPie3DChart provides function to draw the c:plotArea element for 3D pie -// chart by given format sets. +// drawPie3DChart provides a function to draw the c:plotArea element for 3D +// pie chart by given format sets. func (f *File) drawPie3DChart(formatSet *formatChart) *cPlotArea { return &cPlotArea{ Pie3DChart: &cCharts{ @@ -725,7 +736,7 @@ func (f *File) drawPie3DChart(formatSet *formatChart) *cPlotArea { } } -// drawRadarChart provides function to draw the c:plotArea element for radar +// drawRadarChart provides a function to draw the c:plotArea element for radar // chart by given format sets. func (f *File) drawRadarChart(formatSet *formatChart) *cPlotArea { return &cPlotArea{ @@ -748,8 +759,8 @@ func (f *File) drawRadarChart(formatSet *formatChart) *cPlotArea { } } -// drawScatterChart provides function to draw the c:plotArea element for scatter -// chart by given format sets. +// drawScatterChart provides a function to draw the c:plotArea element for +// scatter chart by given format sets. func (f *File) drawScatterChart(formatSet *formatChart) *cPlotArea { return &cPlotArea{ ScatterChart: &cCharts{ @@ -771,8 +782,8 @@ func (f *File) drawScatterChart(formatSet *formatChart) *cPlotArea { } } -// drawChartSeries provides function to draw the c:ser element by given format -// sets. +// drawChartSeries provides a function to draw the c:ser element by given +// format sets. func (f *File) drawChartSeries(formatSet *formatChart) *[]cSer { ser := []cSer{} for k := range formatSet.Series { @@ -797,7 +808,7 @@ func (f *File) drawChartSeries(formatSet *formatChart) *[]cSer { return &ser } -// drawChartSeriesSpPr provides function to draw the c:spPr element by given +// drawChartSeriesSpPr provides a function to draw the c:spPr element by given // format sets. func (f *File) drawChartSeriesSpPr(i int, formatSet *formatChart) *cSpPr { spPrScatter := &cSpPr{ @@ -819,8 +830,8 @@ func (f *File) drawChartSeriesSpPr(i int, formatSet *formatChart) *cSpPr { return chartSeriesSpPr[formatSet.Type] } -// drawChartSeriesDPt provides function to draw the c:dPt element by given data -// index and format sets. +// drawChartSeriesDPt provides a function to draw the c:dPt element by given +// data index and format sets. func (f *File) drawChartSeriesDPt(i int, formatSet *formatChart) []*cDPt { dpt := []*cDPt{{ IDx: &attrValInt{Val: i}, @@ -848,8 +859,8 @@ func (f *File) drawChartSeriesDPt(i int, formatSet *formatChart) []*cDPt { return chartSeriesDPt[formatSet.Type] } -// drawChartSeriesCat provides function to draw the c:cat element by given chart -// series and format sets. +// drawChartSeriesCat provides a function to draw the c:cat element by given +// chart series and format sets. func (f *File) drawChartSeriesCat(v formatChartSeries, formatSet *formatChart) *cCat { cat := &cCat{ StrRef: &cStrRef{ @@ -860,8 +871,8 @@ func (f *File) drawChartSeriesCat(v formatChartSeries, formatSet *formatChart) * return chartSeriesCat[formatSet.Type] } -// drawChartSeriesVal provides function to draw the c:val element by given chart -// series and format sets. +// drawChartSeriesVal provides a function to draw the c:val element by given +// chart series and format sets. func (f *File) drawChartSeriesVal(v formatChartSeries, formatSet *formatChart) *cVal { val := &cVal{ NumRef: &cNumRef{ @@ -872,8 +883,8 @@ func (f *File) drawChartSeriesVal(v formatChartSeries, formatSet *formatChart) * return chartSeriesVal[formatSet.Type] } -// drawChartSeriesMarker provides function to draw the c:marker element by given -// data index and format sets. +// drawChartSeriesMarker provides a function to draw the c:marker element by +// given data index and format sets. func (f *File) drawChartSeriesMarker(i int, formatSet *formatChart) *cMarker { marker := &cMarker{ Symbol: &attrValString{Val: "circle"}, @@ -898,7 +909,7 @@ func (f *File) drawChartSeriesMarker(i int, formatSet *formatChart) *cMarker { return chartSeriesMarker[formatSet.Type] } -// drawChartSeriesXVal provides function to draw the c:xVal element by given +// drawChartSeriesXVal provides a function to draw the c:xVal element by given // chart series and format sets. func (f *File) drawChartSeriesXVal(v formatChartSeries, formatSet *formatChart) *cCat { cat := &cCat{ @@ -910,7 +921,7 @@ func (f *File) drawChartSeriesXVal(v formatChartSeries, formatSet *formatChart) return chartSeriesXVal[formatSet.Type] } -// drawChartSeriesYVal provides function to draw the c:yVal element by given +// drawChartSeriesYVal provides a function to draw the c:yVal element by given // chart series and format sets. func (f *File) drawChartSeriesYVal(v formatChartSeries, formatSet *formatChart) *cVal { val := &cVal{ @@ -922,8 +933,8 @@ func (f *File) drawChartSeriesYVal(v formatChartSeries, formatSet *formatChart) return chartSeriesYVal[formatSet.Type] } -// drawChartDLbls provides function to draw the c:dLbls element by given format -// sets. +// drawChartDLbls provides a function to draw the c:dLbls element by given +// format sets. func (f *File) drawChartDLbls(formatSet *formatChart) *cDLbls { return &cDLbls{ ShowLegendKey: &attrValBool{Val: formatSet.Legend.ShowLegendKey}, @@ -936,15 +947,15 @@ func (f *File) drawChartDLbls(formatSet *formatChart) *cDLbls { } } -// drawChartSeriesDLbls provides function to draw the c:dLbls element by given -// format sets. +// drawChartSeriesDLbls provides a function to draw the c:dLbls element by +// 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} return chartSeriesDLbls[formatSet.Type] } -// drawPlotAreaCatAx provides function to draw the c:catAx element. +// drawPlotAreaCatAx provides a function to draw the c:catAx element. func (f *File) drawPlotAreaCatAx(formatSet *formatChart) []*cAxs { min := &attrValFloat{Val: formatSet.XAxis.Minimum} max := &attrValFloat{Val: formatSet.XAxis.Maximum} @@ -983,7 +994,7 @@ func (f *File) drawPlotAreaCatAx(formatSet *formatChart) []*cAxs { } } -// drawPlotAreaValAx provides function to draw the c:valAx element. +// drawPlotAreaValAx provides a function to draw the c:valAx element. func (f *File) drawPlotAreaValAx(formatSet *formatChart) []*cAxs { min := &attrValFloat{Val: formatSet.YAxis.Minimum} max := &attrValFloat{Val: formatSet.YAxis.Maximum} @@ -1019,7 +1030,7 @@ func (f *File) drawPlotAreaValAx(formatSet *formatChart) []*cAxs { } } -// drawPlotAreaSpPr provides function to draw the c:spPr element. +// drawPlotAreaSpPr provides a function to draw the c:spPr element. func (f *File) drawPlotAreaSpPr() *cSpPr { return &cSpPr{ Ln: &aLn{ @@ -1038,7 +1049,7 @@ func (f *File) drawPlotAreaSpPr() *cSpPr { } } -// drawPlotAreaTxPr provides function to draw the c:txPr element. +// drawPlotAreaTxPr provides a function to draw the c:txPr element. func (f *File) drawPlotAreaTxPr() *cTxPr { return &cTxPr{ BodyPr: aBodyPr{ @@ -1077,8 +1088,8 @@ func (f *File) drawPlotAreaTxPr() *cTxPr { } } -// drawingParser provides function to parse drawingXML. In order to solve the -// problem that the label structure is changed after serialization and +// drawingParser provides a function to parse drawingXML. In order to solve +// the problem that the label structure is changed after serialization and // deserialization, two different structures: decodeWsDr and encodeWsDr are // defined. func (f *File) drawingParser(drawingXML string, content *xlsxWsDr) int { @@ -1105,8 +1116,8 @@ func (f *File) drawingParser(drawingXML string, content *xlsxWsDr) int { return cNvPrID } -// addDrawingChart provides function to add chart graphic frame by given sheet, -// drawingXML, cell, width, height, relationship index and format sets. +// addDrawingChart provides a function to add chart graphic frame by given +// sheet, drawingXML, cell, width, height, relationship index and format sets. func (f *File) addDrawingChart(sheet, drawingXML, cell string, width, height, rID int, formatSet *formatPicture) { cell = strings.ToUpper(cell) fromCol := string(strings.Map(letterOnlyMapF, cell)) |