Skip to content

Commit

Permalink
fix #4370; ref #4516; hide total label if it is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
junedchhipa committed Sep 18, 2024
1 parent e524061 commit 4ad53be
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/charts/Pie.js
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,9 @@ class Pie {
dataLabelsGroup.node.style.opacity = opts.opacity

let x = opts.centerX
let y = opts.centerY
let y = !this.donutDataLabels.total.label
? opts.centerY - opts.centerY / 6
: opts.centerY

let labelColor, valueColor

Expand Down Expand Up @@ -821,7 +823,9 @@ class Pie {
labelFontSize = dataLabelsConfig.total.fontSize
labelFontFamily = dataLabelsConfig.total.fontFamily
labelFontWeight = dataLabelsConfig.total.fontWeight
name = dataLabelsConfig.total.label
name = !this.donutDataLabels.total.label
? ''
: dataLabelsConfig.total.label
val = dataLabelsConfig.total.formatter(w)
} else {
if (w.globals.series.length === 1) {
Expand Down Expand Up @@ -917,7 +921,9 @@ class Pie {
}

const isTotal = name === labelsConfig.total.label
name = labelsConfig.name.formatter(name, isTotal, w)
name = !this.donutDataLabels.total.label
? ''
: labelsConfig.name.formatter(name, isTotal, w)

if (elLabel !== null) {
elLabel.textContent = name
Expand Down

0 comments on commit 4ad53be

Please sign in to comment.