Skip to content

Commit

Permalink
fix: replace int() with float() in typst template
Browse files Browse the repository at this point in the history
  • Loading branch information
juba committed Sep 12, 2024
1 parent 0a649dc commit 83cad90
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- `Plot.plot()` performance should now be equivalent to the one of a generator object
- New shortcut syntax `Plot.line(...).plot()` is now available (#18, thanks @harrylojames)
- Bugfix: typst error with certain decimal padding values.

## pyobsplot 0.5.0

Expand Down
14 changes: 7 additions & 7 deletions src/pyobsplot/static/template.typ
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
spacing: .2em,
image.decode(
encode-xml(elem.children.first()),
width: 1in * int(elem.children.first().attrs.width) / dpi,
height: 1in * int(elem.children.first().attrs.width) /dpi
width: 1in * float(elem.children.first().attrs.width) / dpi,
height: 1in * float(elem.children.first().attrs.width) /dpi
),
text(elem.children.last(), size: 1in * 10/dpi)
)
Expand All @@ -68,11 +68,11 @@
let legends = figuresvgs
.filter(svg => "ramp" in svg.attrs.class)
.map(svg => (..svg, attrs: (..svg.attrs,
width: str(int(svg.attrs.width) + 2*legend-padding),
viewbox: "-"+str(legend-padding)+" 0 "+str(int(svg.attrs.width)+legend-padding)+" "+str(int(svg.attrs.height)))
width: str(float(svg.attrs.width) + 2*legend-padding),
viewbox: "-"+str(legend-padding)+" 0 "+str(float(svg.attrs.width)+legend-padding)+" "+str(float(svg.attrs.height)))
))
let mainfigure = figuresvgs.find(svg => "ramp" not in svg.attrs.class)
let figurewidth = calc.max(..figuresvgs.map(svg => int(svg.attrs.width)))
let figurewidth = calc.max(..figuresvgs.map(svg => float(svg.attrs.width)))

set page(
width: 1in*figurewidth/dpi + 2*margin,
Expand All @@ -96,8 +96,8 @@
v(1in * 8/dpi)
},
..figure.children.filter(e => e.tag == "div").map(swatch),
..legends.map(svg => image.decode(encode-xml(svg), height: 1in * int(svg.attrs.height) / dpi)),
image.decode(encode-xml(mainfigure), height: 1in * int(mainfigure.attrs.height) / dpi),
..legends.map(svg => image.decode(encode-xml(svg), height: 1in * float(svg.attrs.height) / dpi)),
image.decode(encode-xml(mainfigure), height: 1in * float(mainfigure.attrs.height) / dpi),
if (caption != none) {
set text(size: 1in * 13/dpi, fill: rgb(caption_color), weight: 500)
text(caption.children.first())
Expand Down

0 comments on commit 83cad90

Please sign in to comment.