diff options
author | Eugene Dzhurinsky <jdevelop@gmail.com> | 2018-05-09 07:44:04 -0400 |
---|---|---|
committer | Eugene Dzhurinsky <jdevelop@gmail.com> | 2018-05-09 08:13:20 -0400 |
commit | 1787c3533b7ae5070001982b282cdeeab1b42e12 (patch) | |
tree | 6f4410ac3e3e700a3a431695d1be01906a1e9b71 /chart.go | |
parent | e09e47d9883c6d5928e59b8de1a49499d51cb4c8 (diff) |
Use format string for chart dimension.
Signed-off-by: Eugene Dzhurinsky <jdevelop@gmail.com>
Diffstat (limited to 'chart.go')
-rw-r--r-- | chart.go | 42 |
1 files changed, 6 insertions, 36 deletions
@@ -194,6 +194,10 @@ var ( // chart with default value. func parseFormatChartSet(formatSet string) *formatChart { format := formatChart{ + Dimension: formatChartDimension{ + Width: 480, + Height: 290, + }, Format: formatPicture{ FPrintsWithSheet: true, FLocksWithSheet: false, @@ -351,13 +355,7 @@ func parseFormatChartSet(formatSet string) *formatChart { // 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. // -func (f *File) AddChart(sheet, cell, format string, opts ...chartOpts) { - - var defOpts = defaultChartOptions - for _, optF := range opts { - optF(&defOpts) - } - +func (f *File) AddChart(sheet, cell, format string) { formatSet := parseFormatChartSet(format) // Read sheet data. xlsx := f.workSheetReader(sheet) @@ -367,40 +365,12 @@ func (f *File) AddChart(sheet, cell, format string, opts ...chartOpts) { drawingXML := "xl/drawings/drawing" + strconv.Itoa(drawingID) + ".xml" drawingID, drawingXML = f.prepareDrawing(xlsx, drawingID, sheet, drawingXML) drawingRID := f.addDrawingRelationships(drawingID, SourceRelationshipChart, "../charts/chart"+strconv.Itoa(chartID)+".xml", "") - f.addDrawingChart(sheet, drawingXML, cell, defOpts.width, defOpts.height, drawingRID, &formatSet.Format) + f.addDrawingChart(sheet, drawingXML, cell, formatSet.Dimension.Width, formatSet.Dimension.Height, drawingRID, &formatSet.Format) f.addChart(formatSet) f.addContentTypePart(chartID, "chart") f.addContentTypePart(drawingID, "drawings") } -type chartOptions struct { - width int - height int -} - -var defaultChartOptions = chartOptions{ - width: 480, - height: 290, -} - -type chartOpts func(opts *chartOptions) - -// ChartWidth sets the chart width. -func ChartWidth(width int) chartOpts { - return func(opts *chartOptions) { - opts.width = width - return - } -} - -// ChartHeight sets the chart height. -func ChartHeight(height int) chartOpts { - return func(opts *chartOptions) { - opts.height = height - return - } -} - // countCharts provides function to get chart files count storage in the // folder xl/charts. func (f *File) countCharts() int { |