Replies: 2 comments
-
Thanks for your feedback. This library only support label position in "Best Fit", I'll consider add support for change this setting later. |
Beta Was this translation helpful? Give feedback.
0 replies
-
This library now support set the data labels position for chart (#1755), please upgrade to the master branch code, and this feature will be released in the next version. Now you can set the data labels position like this: package main
import (
"fmt"
"github.com/xuri/excelize/v2"
)
func main() {
f := excelize.NewFile()
defer func() {
if err := f.Close(); err != nil {
fmt.Println(err)
}
}()
for idx, row := range [][]interface{}{
{"Apple", "Orange", "Pear"},
{2, 3, 3},
} {
cell, err := excelize.CoordinatesToCellName(1, idx+1)
if err != nil {
fmt.Println(err)
return
}
if err := f.SetSheetRow("Sheet1", cell, &row); err != nil {
fmt.Println(err)
return
}
}
if err := f.AddChart("Sheet1", "E1", &excelize.Chart{
Type: excelize.Pie,
Series: []excelize.ChartSeries{
{
Name: "Amount",
Categories: "Sheet1!$A$1:$C$1",
Values: "Sheet1!$A$2:$C$2",
DataLabelPosition: excelize.ChartDataLabelsPositionOutsideEnd,
},
},
Format: excelize.GraphicOptions{
OffsetX: 15,
OffsetY: 10,
},
Title: []excelize.RichTextRun{
{
Text: "Fruit Pie Chart",
},
},
PlotArea: excelize.ChartPlotArea{
ShowPercent: true,
},
}); err != nil {
fmt.Println(err)
return
}
// Save workbook
if err := f.SaveAs("Book1.xlsx"); err != nil {
fmt.Println(err)
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
current code
current effect
the effect i want
Beta Was this translation helpful? Give feedback.
All reactions