Go language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
修订版 | cb0c1b012b55be6feccb99e66b7d9cae2c45e72f (tree) |
---|---|
时间 | 2023-02-19 01:18:11 |
作者 | xuri <xuri.me@gmai...> |
Commiter | xuri |
Support specifies the values in second plot for the bar/pie of pie chart
- Upgrade dependencies package golang.org/x/image to 0.5.0
- Update unit tests
@@ -751,6 +751,7 @@ func parseChartOptions(opts *Chart) (*Chart, error) { | ||
751 | 751 | // Set the position of the chart plot area by PlotArea. The properties that can |
752 | 752 | // be set are: |
753 | 753 | // |
754 | +// SecondPlotValues | |
754 | 755 | // ShowBubbleSize |
755 | 756 | // ShowCatName |
756 | 757 | // ShowLeaderLines |
@@ -758,6 +759,9 @@ func parseChartOptions(opts *Chart) (*Chart, error) { | ||
758 | 759 | // ShowSerName |
759 | 760 | // ShowVal |
760 | 761 | // |
762 | +// SecondPlotValues: Specifies the values in second plot for the 'pieOfPie' and | |
763 | +// 'barOfPie' chart. | |
764 | +// | |
761 | 765 | // ShowBubbleSize: Specifies the bubble size shall be shown in a data label. The |
762 | 766 | // 'ShowBubbleSize' property is optional. The default value is false. |
763 | 767 | // |
@@ -186,12 +186,13 @@ func TestAddChart(t *testing.T) { | ||
186 | 186 | } |
187 | 187 | legend := ChartLegend{Position: "left", ShowLegendKey: false} |
188 | 188 | plotArea := ChartPlotArea{ |
189 | - ShowBubbleSize: true, | |
190 | - ShowCatName: true, | |
191 | - ShowLeaderLines: false, | |
192 | - ShowPercent: true, | |
193 | - ShowSerName: true, | |
194 | - ShowVal: true, | |
189 | + SecondPlotValues: 3, | |
190 | + ShowBubbleSize: true, | |
191 | + ShowCatName: true, | |
192 | + ShowLeaderLines: false, | |
193 | + ShowPercent: true, | |
194 | + ShowSerName: true, | |
195 | + ShowVal: true, | |
195 | 196 | } |
196 | 197 | for _, c := range []struct { |
197 | 198 | sheetName, cell string |
@@ -602,6 +602,10 @@ func (f *File) drawPie3DChart(opts *Chart) *cPlotArea { | ||
602 | 602 | // drawPieOfPieChart provides a function to draw the c:plotArea element for |
603 | 603 | // pie chart by given format sets. |
604 | 604 | func (f *File) drawPieOfPieChart(opts *Chart) *cPlotArea { |
605 | + var splitPos *attrValInt | |
606 | + if opts.PlotArea.SecondPlotValues > 0 { | |
607 | + splitPos = &attrValInt{Val: intPtr(opts.PlotArea.SecondPlotValues)} | |
608 | + } | |
605 | 609 | return &cPlotArea{ |
606 | 610 | OfPieChart: &cCharts{ |
607 | 611 | OfPieType: &attrValString{ |
@@ -611,6 +615,7 @@ func (f *File) drawPieOfPieChart(opts *Chart) *cPlotArea { | ||
611 | 615 | Val: opts.VaryColors, |
612 | 616 | }, |
613 | 617 | Ser: f.drawChartSeries(opts), |
618 | + SplitPos: splitPos, | |
614 | 619 | SerLines: &attrValString{}, |
615 | 620 | }, |
616 | 621 | } |
@@ -619,6 +624,10 @@ func (f *File) drawPieOfPieChart(opts *Chart) *cPlotArea { | ||
619 | 624 | // drawBarOfPieChart provides a function to draw the c:plotArea element for |
620 | 625 | // pie chart by given format sets. |
621 | 626 | func (f *File) drawBarOfPieChart(opts *Chart) *cPlotArea { |
627 | + var splitPos *attrValInt | |
628 | + if opts.PlotArea.SecondPlotValues > 0 { | |
629 | + splitPos = &attrValInt{Val: intPtr(opts.PlotArea.SecondPlotValues)} | |
630 | + } | |
622 | 631 | return &cPlotArea{ |
623 | 632 | OfPieChart: &cCharts{ |
624 | 633 | OfPieType: &attrValString{ |
@@ -627,6 +636,7 @@ func (f *File) drawBarOfPieChart(opts *Chart) *cPlotArea { | ||
627 | 636 | VaryColors: &attrValBool{ |
628 | 637 | Val: opts.VaryColors, |
629 | 638 | }, |
639 | + SplitPos: splitPos, | |
630 | 640 | Ser: f.drawChartSeries(opts), |
631 | 641 | SerLines: &attrValString{}, |
632 | 642 | }, |
@@ -9,7 +9,7 @@ require ( | ||
9 | 9 | github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 |
10 | 10 | github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 |
11 | 11 | golang.org/x/crypto v0.5.0 |
12 | - golang.org/x/image v0.0.0-20220902085622-e7cb96979f69 | |
12 | + golang.org/x/image v0.5.0 | |
13 | 13 | golang.org/x/net v0.7.0 |
14 | 14 | golang.org/x/text v0.7.0 |
15 | 15 | ) |
@@ -24,8 +24,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk | ||
24 | 24 | golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= |
25 | 25 | golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= |
26 | 26 | golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= |
27 | -golang.org/x/image v0.0.0-20220902085622-e7cb96979f69 h1:Lj6HJGCSn5AjxRAH2+r35Mir4icalbqku+CLUtjnvXY= | |
28 | -golang.org/x/image v0.0.0-20220902085622-e7cb96979f69/go.mod h1:doUCurBvlfPMKfmIpRIywoHmhN3VyhnoFDbvIEWF4hY= | |
27 | +golang.org/x/image v0.5.0 h1:5JMiNunQeQw++mMOz48/ISeNu3Iweh/JaZU8ZLqHRrI= | |
28 | +golang.org/x/image v0.5.0/go.mod h1:FVC7BI/5Ym8R25iw5OLsgshdUBbT1h5jZTpA+mvAdZ4= | |
29 | 29 | golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= |
30 | 30 | golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |
31 | 31 | golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= |
@@ -333,6 +333,7 @@ type cCharts struct { | ||
333 | 333 | VaryColors *attrValBool `xml:"varyColors"` |
334 | 334 | Wireframe *attrValBool `xml:"wireframe"` |
335 | 335 | Ser *[]cSer `xml:"ser"` |
336 | + SplitPos *attrValInt `xml:"splitPos"` | |
336 | 337 | SerLines *attrValString `xml:"serLines"` |
337 | 338 | DLbls *cDLbls `xml:"dLbls"` |
338 | 339 | Shape *attrValString `xml:"shape"` |
@@ -540,12 +541,13 @@ type ChartDimension struct { | ||
540 | 541 | |
541 | 542 | // ChartPlotArea directly maps the format settings of the plot area. |
542 | 543 | type ChartPlotArea struct { |
543 | - ShowBubbleSize bool | |
544 | - ShowCatName bool | |
545 | - ShowLeaderLines bool | |
546 | - ShowPercent bool | |
547 | - ShowSerName bool | |
548 | - ShowVal bool | |
544 | + SecondPlotValues int | |
545 | + ShowBubbleSize bool | |
546 | + ShowCatName bool | |
547 | + ShowLeaderLines bool | |
548 | + ShowPercent bool | |
549 | + ShowSerName bool | |
550 | + ShowVal bool | |
549 | 551 | } |
550 | 552 | |
551 | 553 | // Chart directly maps the format settings of the chart. |