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
pull/2/head
xuri 2 years ago
parent 21ec143778
commit cb0c1b012b
No known key found for this signature in database
GPG Key ID: BA5E5BB1C948EDF7

@ -751,6 +751,7 @@ func parseChartOptions(opts *Chart) (*Chart, error) {
// Set the position of the chart plot area by PlotArea. The properties that can // Set the position of the chart plot area by PlotArea. The properties that can
// be set are: // be set are:
// //
// SecondPlotValues
// ShowBubbleSize // ShowBubbleSize
// ShowCatName // ShowCatName
// ShowLeaderLines // ShowLeaderLines
@ -758,6 +759,9 @@ func parseChartOptions(opts *Chart) (*Chart, error) {
// ShowSerName // ShowSerName
// ShowVal // ShowVal
// //
// SecondPlotValues: Specifies the values in second plot for the 'pieOfPie' and
// 'barOfPie' chart.
//
// ShowBubbleSize: Specifies the bubble size shall be shown in a data label. The // ShowBubbleSize: Specifies the bubble size shall be shown in a data label. The
// 'ShowBubbleSize' property is optional. The default value is false. // 'ShowBubbleSize' property is optional. The default value is false.
// //

@ -186,6 +186,7 @@ func TestAddChart(t *testing.T) {
} }
legend := ChartLegend{Position: "left", ShowLegendKey: false} legend := ChartLegend{Position: "left", ShowLegendKey: false}
plotArea := ChartPlotArea{ plotArea := ChartPlotArea{
SecondPlotValues: 3,
ShowBubbleSize: true, ShowBubbleSize: true,
ShowCatName: true, ShowCatName: true,
ShowLeaderLines: false, ShowLeaderLines: false,

@ -602,6 +602,10 @@ func (f *File) drawPie3DChart(opts *Chart) *cPlotArea {
// drawPieOfPieChart provides a function to draw the c:plotArea element for // drawPieOfPieChart provides a function to draw the c:plotArea element for
// pie chart by given format sets. // pie chart by given format sets.
func (f *File) drawPieOfPieChart(opts *Chart) *cPlotArea { func (f *File) drawPieOfPieChart(opts *Chart) *cPlotArea {
var splitPos *attrValInt
if opts.PlotArea.SecondPlotValues > 0 {
splitPos = &attrValInt{Val: intPtr(opts.PlotArea.SecondPlotValues)}
}
return &cPlotArea{ return &cPlotArea{
OfPieChart: &cCharts{ OfPieChart: &cCharts{
OfPieType: &attrValString{ OfPieType: &attrValString{
@ -611,6 +615,7 @@ func (f *File) drawPieOfPieChart(opts *Chart) *cPlotArea {
Val: opts.VaryColors, Val: opts.VaryColors,
}, },
Ser: f.drawChartSeries(opts), Ser: f.drawChartSeries(opts),
SplitPos: splitPos,
SerLines: &attrValString{}, SerLines: &attrValString{},
}, },
} }
@ -619,6 +624,10 @@ func (f *File) drawPieOfPieChart(opts *Chart) *cPlotArea {
// drawBarOfPieChart provides a function to draw the c:plotArea element for // drawBarOfPieChart provides a function to draw the c:plotArea element for
// pie chart by given format sets. // pie chart by given format sets.
func (f *File) drawBarOfPieChart(opts *Chart) *cPlotArea { func (f *File) drawBarOfPieChart(opts *Chart) *cPlotArea {
var splitPos *attrValInt
if opts.PlotArea.SecondPlotValues > 0 {
splitPos = &attrValInt{Val: intPtr(opts.PlotArea.SecondPlotValues)}
}
return &cPlotArea{ return &cPlotArea{
OfPieChart: &cCharts{ OfPieChart: &cCharts{
OfPieType: &attrValString{ OfPieType: &attrValString{
@ -627,6 +636,7 @@ func (f *File) drawBarOfPieChart(opts *Chart) *cPlotArea {
VaryColors: &attrValBool{ VaryColors: &attrValBool{
Val: opts.VaryColors, Val: opts.VaryColors,
}, },
SplitPos: splitPos,
Ser: f.drawChartSeries(opts), Ser: f.drawChartSeries(opts),
SerLines: &attrValString{}, SerLines: &attrValString{},
}, },

@ -9,7 +9,7 @@ require (
github.com/xuri/efp v0.0.0-20220603152613-6918739fd470 github.com/xuri/efp v0.0.0-20220603152613-6918739fd470
github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22 github.com/xuri/nfp v0.0.0-20220409054826-5e722a1d9e22
golang.org/x/crypto v0.5.0 golang.org/x/crypto v0.5.0
golang.org/x/image v0.0.0-20220902085622-e7cb96979f69 golang.org/x/image v0.5.0
golang.org/x/net v0.7.0 golang.org/x/net v0.7.0
golang.org/x/text v0.7.0 golang.org/x/text v0.7.0
) )

@ -24,8 +24,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE= golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU= golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
golang.org/x/image v0.0.0-20220902085622-e7cb96979f69 h1:Lj6HJGCSn5AjxRAH2+r35Mir4icalbqku+CLUtjnvXY= golang.org/x/image v0.5.0 h1:5JMiNunQeQw++mMOz48/ISeNu3Iweh/JaZU8ZLqHRrI=
golang.org/x/image v0.0.0-20220902085622-e7cb96979f69/go.mod h1:doUCurBvlfPMKfmIpRIywoHmhN3VyhnoFDbvIEWF4hY= golang.org/x/image v0.5.0/go.mod h1:FVC7BI/5Ym8R25iw5OLsgshdUBbT1h5jZTpA+mvAdZ4=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=

@ -333,6 +333,7 @@ type cCharts struct {
VaryColors *attrValBool `xml:"varyColors"` VaryColors *attrValBool `xml:"varyColors"`
Wireframe *attrValBool `xml:"wireframe"` Wireframe *attrValBool `xml:"wireframe"`
Ser *[]cSer `xml:"ser"` Ser *[]cSer `xml:"ser"`
SplitPos *attrValInt `xml:"splitPos"`
SerLines *attrValString `xml:"serLines"` SerLines *attrValString `xml:"serLines"`
DLbls *cDLbls `xml:"dLbls"` DLbls *cDLbls `xml:"dLbls"`
Shape *attrValString `xml:"shape"` Shape *attrValString `xml:"shape"`
@ -540,6 +541,7 @@ type ChartDimension struct {
// ChartPlotArea directly maps the format settings of the plot area. // ChartPlotArea directly maps the format settings of the plot area.
type ChartPlotArea struct { type ChartPlotArea struct {
SecondPlotValues int
ShowBubbleSize bool ShowBubbleSize bool
ShowCatName bool ShowCatName bool
ShowLeaderLines bool ShowLeaderLines bool

Loading…
Cancel
Save