Skip to content

Commit

Permalink
doc: Add add-legend to the documentation (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
johannes-wolf authored Nov 1, 2024
2 parents 1425292 + 5c199cd commit 9dc7972
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
Binary file modified manual.pdf
Binary file not shown.
2 changes: 1 addition & 1 deletion manual.typ
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module imported into the namespace.
= Plot

#doc-style.parse-show-module("/src/plot.typ")
#for m in ("line", "bar", "boxwhisker", "contour", "errorbar", "annotation", "formats", "violin") {
#for m in ("line", "bar", "boxwhisker", "contour", "errorbar", "annotation", "formats", "violin", "legend") {
doc-style.parse-show-module("/src/plot/" + m + ".typ")
}

Expand Down
12 changes: 9 additions & 3 deletions src/plot/legend.typ
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
/// - mark: (none,string): Legend mark symbol
/// - mark-style: (none,dictionary): Mark style
/// - mark-size: (number): Mark size
/// - style (styles): Style keys for the single item
/// - ..style (styles): Style keys for the single item
#let item(label, preview, mark: none, mark-style: (:), mark-size: 1, ..style) = {
assert.eq(style.pos().len(), 0,
message: "Unexpected positional arguments")
Expand Down Expand Up @@ -217,8 +217,14 @@
/// If set to `auto`, a straight line is drawn.
///
/// ```example
/// add-legend([Custom item], preview _ => {
/// draw.rect((0,0), (1,1)) // Draw a rect as preview
/// plot.plot(size: (1,1), x-tick-step: none, y-tick-step: none, {
/// plot.add(((0,0), (1,1))) // Some data
/// plot.add-legend([Custom item], preview: () => {
/// import cetz.draw: *
/// circle((.5,.5), radius: .5) // Draw a custom preview
/// // between (0,0) and (1,1)
/// })
/// plot.add-legend([Another item])
/// })
/// ```
#let add-legend(label, preview: auto) = {
Expand Down

0 comments on commit 9dc7972

Please sign in to comment.