This closes #2052, support to sets the format of the chart series data label
- Add new field DataLabel in the ChartSeries data type
This commit is contained in:
parent
9934bf5c86
commit
3f6ecffcca
4
cell.go
4
cell.go
|
@ -1214,8 +1214,8 @@ func setRichText(runs []RichTextRun) ([]xlsxR, error) {
|
|||
}
|
||||
|
||||
// SetCellRichText provides a function to set cell with rich text by given
|
||||
// worksheet. For example, set rich text on the A1 cell of the worksheet named
|
||||
// Sheet1:
|
||||
// worksheet name, cell reference and rich text runs. For example, set rich text
|
||||
// on the A1 cell of the worksheet named Sheet1:
|
||||
//
|
||||
// package main
|
||||
//
|
||||
|
|
3
chart.go
3
chart.go
|
@ -748,6 +748,7 @@ func (opts *Chart) parseTitle() {
|
|||
// Fill
|
||||
// Line
|
||||
// Marker
|
||||
// DataLabel
|
||||
// DataLabelPosition
|
||||
//
|
||||
// Name: Set the name for the series. The name is displayed in the chart legend
|
||||
|
@ -791,6 +792,8 @@ func (opts *Chart) parseTitle() {
|
|||
// x
|
||||
// auto
|
||||
//
|
||||
// DataLabel: This sets the format of the chart series data label.
|
||||
//
|
||||
// DataLabelPosition: This sets the position of the chart series data label.
|
||||
//
|
||||
// Set properties of the chart legend. The options that can be set are:
|
||||
|
|
|
@ -1028,6 +1028,10 @@ func (f *File) drawChartSeriesDLbls(i int, opts *Chart) *cDLbls {
|
|||
dLbls.DLblPos = &attrValString{Val: stringPtr(chartDataLabelsPositionTypes[opts.Series[i].DataLabelPosition])}
|
||||
}
|
||||
}
|
||||
dLbl := opts.Series[i].DataLabel
|
||||
dLbls.SpPr = f.drawShapeFill(dLbl.Fill, dLbls.SpPr)
|
||||
dLbls.TxPr = &cTxPr{BodyPr: aBodyPr{}, P: aP{PPr: &aPPr{DefRPr: aRPr{}}}}
|
||||
drawChartFont(&dLbl.Font, &dLbls.TxPr.P.PPr.DefRPr)
|
||||
return dLbls
|
||||
}
|
||||
|
||||
|
|
10
xmlChart.go
10
xmlChart.go
|
@ -484,6 +484,8 @@ type cNumCache struct {
|
|||
// the specific formatting and positioning settings.
|
||||
type cDLbls struct {
|
||||
NumFmt *cNumFmt `xml:"numFmt"`
|
||||
SpPr *cSpPr `xml:"spPr"`
|
||||
TxPr *cTxPr `xml:"txPr"`
|
||||
DLblPos *attrValString `xml:"dLblPos"`
|
||||
ShowLegendKey *attrValBool `xml:"showLegendKey"`
|
||||
ShowVal *attrValBool `xml:"showVal"`
|
||||
|
@ -610,6 +612,13 @@ type ChartLine struct {
|
|||
Width float64
|
||||
}
|
||||
|
||||
// ChartDataLabel directly maps the format settings of the chart labels.
|
||||
type ChartDataLabel struct {
|
||||
Alignment Alignment
|
||||
Font Font
|
||||
Fill Fill
|
||||
}
|
||||
|
||||
// ChartSeries directly maps the format settings of the chart series.
|
||||
type ChartSeries struct {
|
||||
Name string
|
||||
|
@ -619,5 +628,6 @@ type ChartSeries struct {
|
|||
Fill Fill
|
||||
Line ChartLine
|
||||
Marker ChartMarker
|
||||
DataLabel ChartDataLabel
|
||||
DataLabelPosition ChartDataLabelPositionType
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue