Skip to content

Commit

Permalink
fix: text pos in text.js
Browse files Browse the repository at this point in the history
  • Loading branch information
neocarto committed Jan 31, 2022
1 parent 0928acf commit c911e68
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,6 @@ bertin.draw({
text: "This is my text",
position: "bottomright",
fontSize: 20,
baseline: "middle",
frame_stroke: "red",
margin: 4
}
Expand All @@ -698,7 +697,6 @@ bertin.draw({
- <b>fontStyle</b>: font style. "normal", "italic", "oblique" (default: "normal")
- <b>margin</b>: margin around the text (default: 0)
- <b>anchor</b>: text anchor. start, middle, end (default: "start")
- <b>baseline</b>: alignment baseline. "baseline", "middle", "hanging" (default:"hanging")
- <b>fill</b>: text color (default: "#474342")
- <b>stroke</b>: stroke color (default: "none")
- <b>frame_fill</b>: frame background color (default:"none")
Expand Down
4 changes: 1 addition & 3 deletions src/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,14 @@ export function addtext(selection, width, height, options = {}){
.data(txt)
.join("text")
.attr("x", x + margin_x)
//.attr("y", y - +delta + margin_y) // better but don't work with Forefox
.attr("y", y - +delta + margin_y + (fontSize * 3) / 4) // because alignment-baseline not implemented on Firefox
.attr("y", y - margin - delta + margin_y + fontsize)
.attr("font-size", `${fontSize}px`)
.attr("font-style", fontStyle)
.attr("text-decoration", textDecoration)
.attr("font-weight", fontWeight)
.attr("font-family", fontFamily)
.attr("dy", (d, i) => i * fontSize)
.attr("text-anchor", anchor)
//.attr("alignment-baseline", "hanging") // better but don't work with Forefox
.attr("fill", fill)
.attr("stroke", stroke)
.text((d) => d);
Expand Down

0 comments on commit c911e68

Please sign in to comment.