Description Details Methods Examples
The Badge class is used to create badges.
The Badge class is used to create badges.
It is likely easier to use the create_badge
to create the badge svg in a single step.
new()
Badge constructor
Used to create badge object.
Badge$new( label, value, color = "#4c1", num_padding_chars = 0.5, thresholds = NULL, font_name = "DejaVu Sans,Verdana,Geneva,sans-serif", font_size = 11, label_text_color = "#fff", value_text_color = "#fff", svg_template_path = NULL )
label
left hand side of badge, e.g. "pipeline" in pipeline status badge
value
right hand side of badge, e.g. "passing" in pipeline status badge
color
to view available colors:
config::get("colors", file = anybadger:::get_sys("config.yml"))
alternatively you can also pass in the hex of your desired color. For instance,
"#fe7d37" or "orange", either is accepted.
num_padding_chars
NULL, can be passed in, but calculated automatically based on text length
thresholds
TODO, thresholds are not implemented yet, coming soon!
font_name
NULL, valid svg font will work, but sizing might be off
font_size
NULL, if passng custom svg font
label_text_color
NULL, set this to change the label text color
value_text_color
NULL, set this to change the value text color
svg_template_path
NULL, to use a different template in svg (not recommended)
NULL
tmp <- tempfile() b <- Badge$new(label = "Pipeline", value = "Passing") b$create_svg(tmp)
create_svg()
Fills in the svg template
Badge$create_svg(path = "default_badge.svg")
path
file path to save badge svg to
invisibly returns the svg text
tmp <- tempfile() b <- Badge$new(label = "Any", value = "Badger") b$create_svg(tmp)
clone()
The objects of this class are cloneable with this method.
Badge$clone(deep = FALSE)
deep
Whether to make a deep clone.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## ------------------------------------------------
## Method `Badge$new`
## ------------------------------------------------
tmp <- tempfile()
b <- Badge$new(label = "Pipeline",
value = "Passing")
b$create_svg(tmp)
## ------------------------------------------------
## Method `Badge$create_svg`
## ------------------------------------------------
tmp <- tempfile()
b <- Badge$new(label = "Any",
value = "Badger")
b$create_svg(tmp)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.