diff --git a/cell.go b/cell.go index 0f9db87022..d642d82897 100644 --- a/cell.go +++ b/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 // diff --git a/chart.go b/chart.go index 74c2320cd4..1448c71ed2 100644 --- a/chart.go +++ b/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: diff --git a/drawing.go b/drawing.go index 75e2b6e27c..09f5800868 100644 --- a/drawing.go +++ b/drawing.go @@ -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 } diff --git a/xmlChart.go b/xmlChart.go index 607c4e380f..4c40f1065d 100644 --- a/xmlChart.go +++ b/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 }