cetz-plot icon indicating copy to clipboard operation
cetz-plot copied to clipboard

Piechart labels overflowing.

Open Uhrbaan opened this issue 4 months ago • 0 comments

Consider the following code (a slight modification from the gallery piechart example)

#import "@preview/cetz:0.4.0"
#import "@preview/cetz-plot:0.1.2": chart

// changed width from auto -> 15cm
#set page(width: 15cm, height: auto, margin: .5cm)

#let data = (
  ([Belgium],     24),
  ([Germany],     31),
  ([Greece],      18),
  ([Spain],       21),
  ([France],      23),
  ([Hungary],     18),
  ([Netherlands], 27),
  ([Romania],     17),
  ([Finland],     26),
  ([Turkey],      13),
)

#cetz.canvas({
  let colors = gradient.linear(red, blue, green, yellow)

  chart.piechart(
    data,
    value-key: 1,
    label-key: 0, // changed label-key from none -> 0
    radius: 4,
    slice-style: colors,
    inner-radius: 1,
    outset: 3,
    inner-label: (content: (value, label) => [#text(white, str(value))], radius: 110%),
    outer-label: (content: "%", radius: 110%))
})

With its output: Image

Issue

While the piechart renders normally, the text underneath does not break into new lines, causing the labels to overflow, and the piechart to be off-centered.

Is there a good work-around for this issue ? Or did I overlook a configuration option ?

Thanks ! And thank you for this amazing package !

Uhrbaan avatar Jul 31 '25 15:07 Uhrbaan