Element.Txt¶
Generates a <text> SVG element
| Name | Type | Required | Description |
|---|---|---|---|
| x | STRING | The x position of the text | |
| y | STRING | The y position of the text | |
| txt | STRING | The text content | |
| dx | STRING | x offset from position | |
| dy | STRING | y offset from position | |
| attributes | STRING | Direct SVG attributes to apply (e.g., "text-anchor='middle' dominant-baseline='middle'"), can generate with DaxLib.SVG.Attr.* or manually |
|
| transforms | STRING | Additional transforms (e.g. "scale(1.2) translate(10,10)") (can be generated with DaxLib.SVG.Transforms) |
STRING <text> element
DaxLib.SVG.SVG(
500, // width
100, // height
"0 0 100 20", // viewbox
DaxLib.SVG.Element.Txt(
10, // x
10, // y
"DaxLib", // txt
0, // dx
0, // dy
DaxLib.SVG.Attr.Txt(
"Arial", // fontFamily
12, // fontSize
BLANK(), // fontWeight
BLANK(), // fontStyle
BLANK(), // textAnchor
BLANK(), // baseline
BLANK(), // textDecoration
BLANK(), // letterSpacing
BLANK() // wordSpacing
), // attributes
BLANK() // transforms
), // contents
BLANK() // sortValue
)
function 'DaxLib.SVG.Element.Txt' =
(
x: STRING,
y: STRING,
txt: STRING,
dx: STRING,
dy: STRING,
attributes: STRING,
transforms: STRING
) =>
"<text" &
" x='" & x & "'" &
" y='" & y & "'" &
IF(NOT ISBLANK( dx ), " dx='" & dx & "'" ) &
IF(NOT ISBLANK( dy ), " dy='" & dy & "'" ) &
IF( NOT ISBLANK( attributes ), " " & attributes & " " ) &
IF( NOT ISBLANK( transforms ), " transform='" & transforms & "'" ) &
">" & txt &
"</text>"