diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a275a5..4a6686a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,21 +20,21 @@ jobs: packages: imagemagick cargo parallel version: 1.0 - name: Install just from crates.io - uses: baptiste0928/cargo-install@v2.2.0 + uses: baptiste0928/cargo-install@v3 with: crate: just - name: Install typst-test from github - uses: baptiste0928/cargo-install@v2.2.0 + uses: baptiste0928/cargo-install@v3 with: crate: typst-test git: https://github.com/tingerrr/typst-test.git tag: ci-semi-stable - run: | mkdir -p ~/.local/share/typst/packages/preview/cetz - git clone --depth 1 --branch v0.3.0 https://github.com/cetz-package/cetz.git ~/.local/share/typst/packages/preview/cetz/0.3.0 + git clone --depth 1 --branch v0.3.1 https://github.com/cetz-package/cetz.git ~/.local/share/typst/packages/preview/cetz/0.3.1 - uses: typst-community/setup-typst@v3 with: - typst-version: '0.12.0-rc1' + typst-version: '0.12.0-rc2' cache-dependency-path: src/cetz.typ - run: | just install @local diff --git a/README.md b/README.md index 535dd72..358c057 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ CeTZ-Plot is a library that adds plots and charts to [CeTZ](https://github.com/cetz-package/cetz), a library for drawing with [Typst](https://typst.app). -CeTZ-Plot requires CeTZ version ≥ 0.3.0. +CeTZ-Plot requires CeTZ version ≥ 0.3.1! ## Examples @@ -39,7 +39,7 @@ For information, see the [manual (stable)](https://github.com/cetz-package/cetz- To use this package, simply add the following code to your document: ``` -#import "@preview/cetz:0.3.0" +#import "@preview/cetz:0.3.1" #import "@preview/cetz-plot:0.1.0": plot, chart #cetz.canvas({ diff --git a/gallery/barchart.png b/gallery/barchart.png index 00098be..f4b4c62 100644 Binary files a/gallery/barchart.png and b/gallery/barchart.png differ diff --git a/gallery/barchart.typ b/gallery/barchart.typ index b75866d..0098c07 100644 --- a/gallery/barchart.typ +++ b/gallery/barchart.typ @@ -1,4 +1,4 @@ -#import "@preview/cetz:0.3.0": canvas, draw +#import "@preview/cetz:0.3.1": canvas, draw #import "@preview/cetz-plot:0.1.0": chart #set page(width: auto, height: auto, margin: .5cm) diff --git a/gallery/line.png b/gallery/line.png index c55f0fd..eac1dff 100644 Binary files a/gallery/line.png and b/gallery/line.png differ diff --git a/gallery/line.typ b/gallery/line.typ index 9995732..d663292 100644 --- a/gallery/line.typ +++ b/gallery/line.typ @@ -1,4 +1,4 @@ -#import "@preview/cetz:0.3.0": canvas, draw +#import "@preview/cetz:0.3.1": canvas, draw #import "@preview/cetz-plot:0.1.0": plot #set page(width: auto, height: auto, margin: .5cm) diff --git a/gallery/piechart.png b/gallery/piechart.png index 217a16b..8d0053a 100644 Binary files a/gallery/piechart.png and b/gallery/piechart.png differ diff --git a/gallery/piechart.typ b/gallery/piechart.typ index 1c4a299..3d6529c 100644 --- a/gallery/piechart.typ +++ b/gallery/piechart.typ @@ -1,4 +1,4 @@ -#import "@preview/cetz:0.3.0" +#import "@preview/cetz:0.3.1" #import "@preview/cetz-plot:0.1.0": chart #set page(width: auto, height: auto, margin: .5cm) diff --git a/manual.pdf b/manual.pdf index 9a04589..7ef21b7 100644 Binary files a/manual.pdf and b/manual.pdf differ diff --git a/manual.typ b/manual.typ index a6fff2f..8ea2b78 100644 --- a/manual.typ +++ b/manual.typ @@ -3,7 +3,7 @@ #import "/doc/example.typ": example #import "/doc/style.typ" as doc-style #import "/src/lib.typ": * -#import "@preview/tidy:0.2.0" +#import "@preview/tidy:0.3.0" // Usage: @@ -39,7 +39,7 @@ CeTZ-Plot is a simple plotting library for use with CeTZ. This is the minimal starting point: #pad(left: 1em)[```typ -#import "@preview/cetz:0.3.0" +#import "@preview/cetz:0.3.1" #import "@preview/cetz-plot:0.1.0" #cetz.canvas({ import cetz.draw: * diff --git a/src/axes.typ b/src/axes.typ index 1d172c9..36a5dad 100644 --- a/src/axes.typ +++ b/src/axes.typ @@ -1,8 +1,6 @@ #import "/src/cetz.typ": util, draw, vector, matrix, styles, process, drawable, path-util, process #import "/src/plot/formats.typ" -#let typst-content = content - /// Default axis style /// /// #show-parameter-block("tick-limit", "int", default: 100, [Upper major tick limit.]) @@ -243,11 +241,11 @@ // to content! Typst has negative zero floats. if value == 0 { value = 0 } - if type(value) != typst-content { + if type(value) != std.content { let format = tic-options.at("format", default: "float") if format == none { value = [] - } else if type(format) == typst-content { + } else if type(format) == std.content { value = format } else if type(format) == function { value = (format)(value) @@ -256,7 +254,7 @@ } else { value = formats.decimal(value, digits: tic-options.at("decimals", default: 2)) } - } else if type(value) != typst-content { + } else if type(value) != std.content { value = str(value) } @@ -902,7 +900,7 @@ if shared-zero { let pt = (rel: (-style.tick.label.offset, -style.tick.label.offset), to: (y-x, x-y)) - let zero = if type(style.shared-zero) == typst-content { + let zero = if type(style.shared-zero) == std.content { style.shared-zero } else { $0$ diff --git a/src/cetz.typ b/src/cetz.typ index 5b990cc..8772069 100644 --- a/src/cetz.typ +++ b/src/cetz.typ @@ -1,2 +1,2 @@ // Import cetz into the root scope. Import cetz by importing this file only! -#import "@preview/cetz:0.3.0": * +#import "@preview/cetz:0.3.1": * diff --git a/src/plot.typ b/src/plot.typ index acf36aa..1436f70 100644 --- a/src/plot.typ +++ b/src/plot.typ @@ -204,7 +204,7 @@ legend-style: (:), ..options ) = draw.group(name: name, ctx => { - draw.assert-version(version(0, 3, 0)) + draw.assert-version(version(0, 3, 1)) // Create plot context object let make-ctx(x, y, size) = { @@ -450,7 +450,14 @@ }) if "mark" in d and d.mark != none { - draw.group({ + draw.scope({ + if y.horizontal { + draw.set-ctx(ctx => { + ctx.transform = matrix.swap-cols(ctx.transform, 0, 1) + return ctx + }) + } + draw.set-style(..d.style, ..d.mark-style) mark.draw-mark(d.data, x, y, d.mark, d.mark-size, size) }) diff --git a/src/plot/boxwhisker.typ b/src/plot/boxwhisker.typ index facaa94..84f0521 100644 --- a/src/plot/boxwhisker.typ +++ b/src/plot/boxwhisker.typ @@ -110,6 +110,7 @@ ) + (if "outliers" in data { ( type: "boxwhisker-outliers", data: data.outliers.map(it => (data.x, it)), + axes: axes, mark: mark, mark-size: mark-size, mark-style: (:) diff --git a/src/plot/formats.typ b/src/plot/formats.typ index 60a12f7..380d1a2 100644 --- a/src/plot/formats.typ +++ b/src/plot/formats.typ @@ -1,6 +1,3 @@ -// Temporary fix Typst measure bug -#let _block-eq(body) = math.equation(block: true, numbering: none, body) - // Compare two floats #let _compare(a, b, eps: 1e-6) = { return calc.abs(a - b) <= eps @@ -59,7 +56,7 @@ /// - eps (number): Epsilon used for comparison /// -> Content if a matching fraction could be found or none #let fraction(value, denom: auto, eps: 1e-6) = { - return _block-eq(_find-fraction(value, denom: denom, eps: eps)) + return _find-fraction(value, denom: denom, eps: eps) } /// Multiple of tick formatter @@ -88,24 +85,24 @@ /// -> Content if a matching fraction could be found or none #let multiple-of(value, factor: calc.pi, symbol: $pi$, fraction: true, digits: 2, eps: 1e-6, prefix: [], suffix: []) = { if _compare(value, 0, eps: eps) { - return _block-eq($0$) + return $0$ } let a = value / factor if _compare(a, 1, eps: eps) { - return _block-eq(prefix + symbol + suffix) + return prefix + symbol + suffix } else if _compare(a, -1, eps: eps) { - return _block-eq(prefix + $-$ + symbol + suffix) + return prefix + $-$ + symbol + suffix } if fraction != none { let frac = _find-fraction(a, denom: if fraction == true { auto } else { fraction }) if frac != none { - return _block-eq(prefix + frac + symbol + suffix) + return prefix + frac + symbol + suffix } } - return _block-eq(prefix + $#calc.round(a, digits: digits)$ + symbol + suffix) + return prefix + $#calc.round(a, digits: digits)$ + symbol + suffix } /// Scientific notation tick formatter @@ -140,10 +137,10 @@ value = calc.round(value, digits: digits) if exponent <= -1 or exponent >= 1 { - return _block-eq(prefix + $#value times 10^#exponent$ + suffix) + return prefix + $#value times 10^#exponent$ + suffix } - return _block-eq(prefix + $#value$ + suffix) + return prefix + $#value$ + suffix } /// Rounded decimal number formatter @@ -163,5 +160,5 @@ /// - suffix (content): Content to append /// -> Content #let decimal(value, digits: 2, prefix: [], suffix: []) = { - _block-eq(prefix + $#calc.round(value, digits: digits)$ + suffix) + prefix + $#calc.round(value, digits: digits)$ + suffix } diff --git a/src/plot/util.typ b/src/plot/util.typ index 2fd1f20..5c59c80 100644 --- a/src/plot/util.typ +++ b/src/plot/util.typ @@ -290,7 +290,7 @@ for (name, axis) in axis-dict { if not "ticks" in axis { axis.ticks = () } - axis.label = get-axis-option(name, "label", math.equation(block: true, numbering: none, $#name$)) + axis.label = get-axis-option(name, "label", $#name$) // Configure axis bounds axis.min = get-axis-option(name, "min", axis.min) diff --git a/tests/axes/log-mode/ref/1.png b/tests/axes/log-mode/ref/1.png index ee22129..409c2c3 100644 Binary files a/tests/axes/log-mode/ref/1.png and b/tests/axes/log-mode/ref/1.png differ diff --git a/tests/axes/ref/1.png b/tests/axes/ref/1.png index 816f0ad..fbc0603 100644 Binary files a/tests/axes/ref/1.png and b/tests/axes/ref/1.png differ diff --git a/tests/chart/boxwhisker/ref/1.png b/tests/chart/boxwhisker/ref/1.png index db6c1c3..07b311a 100644 Binary files a/tests/chart/boxwhisker/ref/1.png and b/tests/chart/boxwhisker/ref/1.png differ diff --git a/tests/chart/piechart/ref/1.png b/tests/chart/piechart/ref/1.png index d93ab78..b689db0 100644 Binary files a/tests/chart/piechart/ref/1.png and b/tests/chart/piechart/ref/1.png differ diff --git a/tests/chart/ref/1.png b/tests/chart/ref/1.png index b7e9f6d..a9aab7b 100644 Binary files a/tests/chart/ref/1.png and b/tests/chart/ref/1.png differ diff --git a/tests/plot/annotation/ref/1.png b/tests/plot/annotation/ref/1.png index 648e09a..af0ea9d 100644 Binary files a/tests/plot/annotation/ref/1.png and b/tests/plot/annotation/ref/1.png differ diff --git a/tests/plot/bar/ref/1.png b/tests/plot/bar/ref/1.png index e6b181d..307100d 100644 Binary files a/tests/plot/bar/ref/1.png and b/tests/plot/bar/ref/1.png differ diff --git a/tests/plot/boxwhisker/ref/1.png b/tests/plot/boxwhisker/ref/1.png index d5defd9..2f1e16e 100644 Binary files a/tests/plot/boxwhisker/ref/1.png and b/tests/plot/boxwhisker/ref/1.png differ diff --git a/tests/plot/broken-axes/ref/1.png b/tests/plot/broken-axes/ref/1.png index 61ca33a..fcd2e11 100644 Binary files a/tests/plot/broken-axes/ref/1.png and b/tests/plot/broken-axes/ref/1.png differ diff --git a/tests/plot/contour/ref/1.png b/tests/plot/contour/ref/1.png index 4bf2d43..adad8ab 100644 Binary files a/tests/plot/contour/ref/1.png and b/tests/plot/contour/ref/1.png differ diff --git a/tests/plot/equal-axis/ref/1.png b/tests/plot/equal-axis/ref/1.png index 53465b9..7f4196f 100644 Binary files a/tests/plot/equal-axis/ref/1.png and b/tests/plot/equal-axis/ref/1.png differ diff --git a/tests/plot/format/ref/1.png b/tests/plot/format/ref/1.png index e32d4f0..2b5a0ec 100644 Binary files a/tests/plot/format/ref/1.png and b/tests/plot/format/ref/1.png differ diff --git a/tests/plot/grid/ref/1.png b/tests/plot/grid/ref/1.png index 67cfa59..550e9d5 100644 Binary files a/tests/plot/grid/ref/1.png and b/tests/plot/grid/ref/1.png differ diff --git a/tests/plot/hvline/ref/1.png b/tests/plot/hvline/ref/1.png index a4ae53c..24fa4d3 100644 Binary files a/tests/plot/hvline/ref/1.png and b/tests/plot/hvline/ref/1.png differ diff --git a/tests/plot/legend/ref/1.png b/tests/plot/legend/ref/1.png index ddc02da..def865f 100644 Binary files a/tests/plot/legend/ref/1.png and b/tests/plot/legend/ref/1.png differ diff --git a/tests/plot/line/between/ref/1.png b/tests/plot/line/between/ref/1.png index 154da5d..8fba9e2 100644 Binary files a/tests/plot/line/between/ref/1.png and b/tests/plot/line/between/ref/1.png differ diff --git a/tests/plot/line/fill/ref/1.png b/tests/plot/line/fill/ref/1.png index ecb2e9b..09a108f 100644 Binary files a/tests/plot/line/fill/ref/1.png and b/tests/plot/line/fill/ref/1.png differ diff --git a/tests/plot/line/line-type/ref/1.png b/tests/plot/line/line-type/ref/1.png index ec797e7..7814191 100644 Binary files a/tests/plot/line/line-type/ref/1.png and b/tests/plot/line/line-type/ref/1.png differ diff --git a/tests/plot/line/linearization/ref/1.png b/tests/plot/line/linearization/ref/1.png index d1ad132..ea8c022 100644 Binary files a/tests/plot/line/linearization/ref/1.png and b/tests/plot/line/linearization/ref/1.png differ diff --git a/tests/plot/line/mark/ref/1.png b/tests/plot/line/mark/ref/1.png index 30f2a8b..f4e7ca6 100644 Binary files a/tests/plot/line/mark/ref/1.png and b/tests/plot/line/mark/ref/1.png differ diff --git a/tests/plot/line/spline/ref/1.png b/tests/plot/line/spline/ref/1.png index 5140ae2..ba6e25b 100644 Binary files a/tests/plot/line/spline/ref/1.png and b/tests/plot/line/spline/ref/1.png differ diff --git a/tests/plot/marks/ref/1.png b/tests/plot/marks/ref/1.png index 6fb79db..ad6e334 100644 Binary files a/tests/plot/marks/ref/1.png and b/tests/plot/marks/ref/1.png differ diff --git a/tests/plot/mirror-axes/ref/1.png b/tests/plot/mirror-axes/ref/1.png index 81bbbe7..4e7e062 100644 Binary files a/tests/plot/mirror-axes/ref/1.png and b/tests/plot/mirror-axes/ref/1.png differ diff --git a/tests/plot/parametric/ref/1.png b/tests/plot/parametric/ref/1.png index 0b43d8f..18557d3 100644 Binary files a/tests/plot/parametric/ref/1.png and b/tests/plot/parametric/ref/1.png differ diff --git a/tests/plot/ref/1.png b/tests/plot/ref/1.png index 8a921aa..2cfb1b8 100644 Binary files a/tests/plot/ref/1.png and b/tests/plot/ref/1.png differ diff --git a/tests/plot/reverse-axis/ref/1.png b/tests/plot/reverse-axis/ref/1.png index 03f501b..d29c1b6 100644 Binary files a/tests/plot/reverse-axis/ref/1.png and b/tests/plot/reverse-axis/ref/1.png differ diff --git a/tests/plot/vertical/ref/1.png b/tests/plot/vertical/ref/1.png index a6cd6e6..f034306 100644 Binary files a/tests/plot/vertical/ref/1.png and b/tests/plot/vertical/ref/1.png differ diff --git a/tests/plot/vertical/test.typ b/tests/plot/vertical/test.typ index 166670b..ffe61c2 100644 --- a/tests/plot/vertical/test.typ +++ b/tests/plot/vertical/test.typ @@ -8,7 +8,7 @@ plot.plot(size: (10, 10), { - plot.add(domain: (0, 4*calc.pi), calc.sin, axes: ("y", "x")) + plot.add(domain: (0, 4*calc.pi), calc.sin, axes: ("y", "x"), mark: "+") }) }) diff --git a/tests/plot/violin/ref/1.png b/tests/plot/violin/ref/1.png index 819bc03..63e1210 100644 Binary files a/tests/plot/violin/ref/1.png and b/tests/plot/violin/ref/1.png differ