Skip to content

Legends in charts do not support font settings #2169

Open
@jebirch

Description

@jebirch

Description

This is maybe a feature request - I am not sure. But it is not possible to change the font of the legend texts in charts.

It can easily be resolved by adding these few lines:

drawing.go:
87,100d86
<                               TxPr: &cTxPr{
<                                       BodyPr: aBodyPr{
<                                               Rot:              0,
<                                               SpcFirstLastPara: true,
<                                               VertOverflow:     "ellipsis",
<                                               Vert:             "horz",
<                                               Wrap:             "square",
<                                               Anchor:           "ctr",
<                                               AnchorCtr:        true,
<                                       },
<                                       P: aP{
<                                               PPr: &aPPr{DefRPr: aRPr{}},
<                                       },
<                               },
184,186d169
<       } else if xlsxChartSpace.Chart.Legend != nil && xlsxChartSpace.Chart.Legend.TxPr != nil {
<               // Apply font settings to legend
<               drawChartFont(&opts.Legend.Font, &xlsxChartSpace.Chart.Legend.TxPr.P.PPr.DefRPr)

xmlChart.go:
614d613
<       Font          Font

Steps to reproduce the issue

It is not possible to specify font in legend like i.e. this:
Legend: excelize.ChartLegend{Position: "bottom", Font: excelize.Font{Family: "Aptos", Color: "#3E3E3E", Size: 10}}

Describe the results you received

Font is not valid tag

Describe the results you expected

That I can specify the font tag in legeng

Go version

1.24.4

Excelize version or commit ID

38f11c4

Environment

IDE

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions