Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.4.0!
CeTZ-Plot requires CeTZ version ≥ 0.4.2!

## Examples
<!-- img width is set so the table gets evenly spaced by GitHubs css -->
Expand Down Expand Up @@ -63,8 +63,8 @@ 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.4.0"
#import "@preview/cetz-plot:0.1.2": plot, chart
#import "@preview/cetz:0.4.2"
#import "@preview/cetz-plot:0.1.3": plot, chart

#cetz.canvas({
// Your plot/chart code goes here
Expand Down
Binary file modified gallery/barchart.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions gallery/barchart.typ
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "@preview/cetz:0.4.0": canvas, draw
#import "@preview/cetz-plot:0.1.2": chart
#import "@preview/cetz:0.4.2": canvas, draw
#import "@preview/cetz-plot:0.1.3": chart

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

Expand Down
2 changes: 1 addition & 1 deletion gallery/bending.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "@preview/cetz:0.4.0" as cetz: draw
#import "@preview/cetz:0.4.2" as cetz: draw
#import "/src/lib.typ": smartart

#set page(width: auto, height: auto, margin: .5cm)
Expand Down
2 changes: 1 addition & 1 deletion gallery/chevron.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "@preview/cetz:0.4.0" as cetz: draw
#import "@preview/cetz:0.4.2" as cetz: draw
#import "/src/lib.typ": smartart

#set page(width: auto, height: auto, margin: .5cm)
Expand Down
2 changes: 1 addition & 1 deletion gallery/circular.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "@preview/cetz:0.4.0" as cetz: draw
#import "@preview/cetz:0.4.2" as cetz: draw
#import "/src/lib.typ": smartart

#set page(width: auto, height: auto, margin: .5cm)
Expand Down
2 changes: 1 addition & 1 deletion gallery/cycles.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "@preview/cetz:0.4.0": canvas, draw
#import "@preview/cetz:0.4.2": canvas, draw
#import "/src/lib.typ": smartart

#set page(width: auto, height: auto, margin: .5cm)
Expand Down
Binary file modified gallery/line.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions gallery/line.typ
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "@preview/cetz:0.4.0": canvas, draw
#import "@preview/cetz-plot:0.1.2": plot
#import "@preview/cetz:0.4.2": canvas, draw
#import "@preview/cetz-plot:0.1.3": plot

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

Expand Down
5 changes: 3 additions & 2 deletions gallery/piechart.typ
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "@preview/cetz:0.4.0"
#import "@preview/cetz-plot:0.1.2": chart
#import "@preview/cetz:0.4.2"
#import "@preview/cetz-plot:0.1.3": chart

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

Expand All @@ -24,6 +24,7 @@
value-key: 1,
label-key: none,
radius: 4,
stroke: none,
slice-style: colors,
inner-radius: 1,
outset: 3,
Expand Down
2 changes: 1 addition & 1 deletion gallery/process.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#import "@preview/cetz:0.4.0" as cetz: draw
#import "@preview/cetz:0.4.2" as cetz: draw
#import "/src/lib.typ": smartart

#set page(width: auto, height: auto, margin: .5cm)
Expand Down
4 changes: 2 additions & 2 deletions gallery/pyramid.typ
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#import "@preview/cetz:0.4.0"
#import "@preview/cetz-plot:0.1.2": chart
#import "@preview/cetz:0.4.2"
#import "@preview/cetz-plot:0.1.3": chart

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

Expand Down
Binary file modified manual.pdf
Binary file not shown.
4 changes: 2 additions & 2 deletions manual.typ
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ 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.4.0"
#import "@preview/cetz-plot:0.1.2"
#import "@preview/cetz:0.4.2"
#import "@preview/cetz-plot:0.1.3"
#cetz.canvas({
import cetz.draw: *
import cetz-plot: *
Expand Down
4 changes: 2 additions & 2 deletions src/axes.typ
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@
draw.move-to(start)
if axis.min > 0 {
add-break(false)
draw.line((rel: size, to: start), end, mark: style.at("mark", default: none))
draw.line((rel: size, to: start), end)
} else if axis.max < 0 {
draw.line(start, (rel: vector.scale(size, -1), to: end))
add-break(true)
}
}, stroke: style.stroke)
}, stroke: style.stroke, mark: style.at("mark", default: none))
} else {
draw.line(start, end, stroke: style.stroke, mark: style.at("mark", default: none))
}
Expand Down
2 changes: 1 addition & 1 deletion src/cetz.typ
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// Import cetz into the root scope. Import cetz by importing this file only!
#import "@preview/cetz:0.4.0": *
#import "@preview/cetz:0.4.2": *
2 changes: 1 addition & 1 deletion src/chart/barchart.typ
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#import "/src/plot.typ"

#let barchart-default-style = (
axes: (tick: (length: 0), grid: (stroke: (dash: "dotted"))),
axes: (tick: (length: 0), grid: (stroke: (dash: "dotted", paint: gray))),
bar-width: .8,
cluster-gap: 0,
error: (
Expand Down
2 changes: 1 addition & 1 deletion src/chart/boxwhisker.typ
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#import "/src/plot.typ"

#let boxwhisker-default-style = (
axes: (tick: (length: 0), grid: (stroke: (dash: "dotted"))),
axes: (tick: (length: 0), grid: (stroke: (dash: "dotted", paint: gray))),
box-width: 0.75,
whisker-width: 0.5,
mark-size: 0.15,
Expand Down
2 changes: 1 addition & 1 deletion src/chart/piechart.typ
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
group(name: name, ctx => {
anchor("default", (0,0))

let style = styles.resolve(ctx,
let style = styles.resolve(ctx.style,
merge: style.named(), root: "piechart", base: default-style)

let gap = style.gap
Expand Down
2 changes: 1 addition & 1 deletion src/chart/pyramid.typ
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
draw.anchor("default", (0, 0))

let style = styles.resolve(
ctx,
ctx.style,
merge: style.named(),
root: "pyramid",
base: default-style
Expand Down
2 changes: 1 addition & 1 deletion src/lib.typ
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#let version = version(0,1,2)
#let version = version(0,1,3)

#import "/src/axes.typ"
#import "/src/plot.typ"
Expand Down
2 changes: 1 addition & 1 deletion src/plot.typ
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
legend-style: (:),
..options
) = draw.group(name: name, ctx => {
draw.assert-version(version(0, 4, 0))
draw.assert-version(version(0, 4, 2))

// Create plot context object
let make-ctx(x, y, size) = {
Expand Down
Binary file modified tests/axes/self/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/chart/boxwhisker/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 16 additions & 15 deletions tests/chart/piechart/test.typ
Original file line number Diff line number Diff line change
Expand Up @@ -9,68 +9,68 @@
// Outset items
#test-case({
import draw: *
piechart(range(1,11), outset: 3, outset-offset: 25%, slice-style: colors)
piechart(range(1,11), outset: 3, outset-offset: 25%, slice-style: colors, stroke: none)
})

// Outset items + inner radius
#test-case({
import draw: *
piechart(range(1,11), outset: 3, inner-radius: .5, outset-offset: 25%, slice-style: colors)
piechart(range(1,11), outset: 3, inner-radius: .5, outset-offset: 25%, slice-style: colors, stroke: none)
})

// Outset items + arc shape
#test-case({
import draw: *
piechart(range(1,5), outset-offset: 25%, slice-style: colors,
start: 0deg, stop: 180deg)
start: 0deg, stop: 180deg, stroke: none)
})

// Outset items + inner radius
#test-case({
import draw: *
piechart(range(1,5), inner-radius: .5, outset-offset: 25%, slice-style: colors,
start: 45deg, stop: 135deg)
start: 45deg, stop: 135deg, stroke: none)
})

// Rotated Values
#test-case({
piechart(range(1,11), slice-style: colors, outer-label: (angle: auto, content: "VALUE"))
piechart(range(1,11), slice-style: colors, outer-label: (angle: auto, content: "VALUE"), stroke: none)
})

// Rotated Percentages
#test-case({
piechart(range(10, 60, step: 10), slice-style: colors, outer-label: (angle: auto, content: "%"))
piechart(range(10, 60, step: 10), slice-style: colors, outer-label: (angle: auto, content: "%"), stroke: none)
})

// Inner Values
#test-case({
piechart(range(1,11), slice-style: colors, inner-label: (content: "VALUE"), radius: 2)
piechart(range(1,11), slice-style: colors, inner-label: (content: "VALUE"), radius: 2, stroke: none)
})

// Inner Percentages
#test-case({
piechart(range(10, 60, step: 10), slice-style: colors, inner-label: (content: "%"), radius: 2)
piechart(range(10, 60, step: 10), slice-style: colors, inner-label: (content: "%"), radius: 2, stroke: none)
})

// Gap as canvas size
#test-case({
piechart(range(1,11), gap: .1, slice-style: colors)
piechart(range(1,11), gap: .1, slice-style: colors, stroke: none)
})

// Gap as canvas size + inner radius
#test-case({
piechart(range(1,11), gap: .1, inner-radius: .5, slice-style: colors)
piechart(range(1,11), gap: .1, inner-radius: .5, slice-style: colors, stroke: none)
})

// Gap as angle
#test-case({
piechart(range(1,11), gap: 5deg, slice-style: colors, outer-label: (angle: auto))
piechart(range(1,11), gap: 5deg, slice-style: colors, outer-label: (angle: auto), stroke: none)
})

// Anchors
#test-case({
import draw: *
piechart(range(1,11), slice-style: colors, name: "c", inner-radius: .5)
piechart(range(1,11), slice-style: colors, name: "c", inner-radius: .5, stroke: none)
for-each-anchor("c", n => {
circle("c." + n, radius: .05)
})
Expand All @@ -79,7 +79,7 @@
// Keys
#test-case({
piechart(((value: 1, label: [One], o: false),
(value: 1, label: [Two], o: true)), slice-style: colors,
(value: 1, label: [Two], o: true)), slice-style: colors, stroke: none,
value-key: "value", label-key: "label", outer-label: (content: "LABEL", radius: 150%), outset-key: "o")
})

Expand All @@ -93,20 +93,21 @@
(value: 1, label: [Six], o: 10%),
(value: 1, label: [Seven], o: 12%),
(value: 1, label: [Eight], o: 14%),),
stroke: none,
slice-style: colors,
value-key: "value", label-key: "label", outer-label: (content: "LABEL", radius: 150%), outset-key: "o")
})

// Clockwise rotation
#test-case({
import draw: *
piechart(range(1,4), clockwise: true, slice-style: (green, yellow, red))
piechart(range(1,4), clockwise: true, slice-style: (green, yellow, red), stroke: none)
})

// Counter clockwise rotation
#test-case({
import draw: *
piechart(range(1,4), clockwise: false, slice-style: (green, yellow, red))
piechart(range(1,4), clockwise: false, slice-style: (green, yellow, red), stroke: none)
})

// 0 Elements
Expand Down
Binary file modified tests/chart/self/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/broken-axes/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/self/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/plot/violin/ref/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion typst.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cetz-plot"
version = "0.1.2"
version = "0.1.3"
compiler = "0.13.1"
repository = "https://github.com/cetz-package/cetz-plot"
entrypoint = "src/lib.typ"
Expand Down