cetz-package / cetz

CeTZ: ein Typst Zeichenpaket - A library for drawing stuff with Typst.
https://cetz-package.github.io
GNU Lesser General Public License v3.0
885 stars 36 forks source link

bar-width has no effect for columnchart or barchart in v0.2.2 #569

Closed jonathanharg closed 6 months ago

jonathanharg commented 6 months ago

The bar-width has had no effect on the width of bars in barcharts or columncharts since version 0.1.2.

//#import "@preview/cetz:0.1.2": version, canvas, chart, draw
#import "@preview/cetz:0.2.2": version, canvas, chart, draw

#set page(width: auto, height: auto, margin: .5cm)

#let data = (
 ("fib", 7.08969110532192),
 ("fib-loop", 46.15384615384615),
 ("pidigit", 33.333333333333336),
 ("leibniz", 1.3353464183861767),
 ("fannkuchredux", 15.151195591995995),
 ("matrix", 46.34146341463414),
)

#canvas({
    chart.columnchart(
      x-label: [Typst v#sys.version CeTZ v#version],
      bar-width: 0.1,
      size: (16, 10),
      data)
})

#set page(width: auto, height: auto, margin: .5cm)

#let data = (
 ("fib", 7.08969110532192),
 ("fib-loop", 46.15384615384615),
 ("pidigit", 33.333333333333336),
 ("leibniz", 1.3353464183861767),
 ("fannkuchredux", 15.151195591995995),
 ("matrix", 46.34146341463414),
)

#canvas({
    chart.columnchart(
      x-label: [Typst v#sys.version CeTZ v#version],
      bar-width: 0.1,
      size: (16, 10),
      data)
})

Test v0 1 2 Test v0 2 2

johannes-wolf commented 6 months ago

It works via set-style: set-style(columnchart: (bar-width: .2)). The columnchart and barchart functions no longer have a bar-width argument, but pass all (unspecified) named arguments down to plot.plot.

There is currently some inconsistency when to use set-style and when not (for the plot and chart API).