Low level API to define graphic elements.
Usage
e_graphic_g(e, ...)
e_group_g(e, ...)
e_image_g(e, ...)
e_text_g(e, ...)
e_rect_g(e, ...)
e_circle_g(e, ...)
e_ring_g(e, ...)
e_sector_g(e, ...)
e_arc_g(e, ...)
e_polygon_g(e, ...)
e_polyline_g(e, ...)
e_line_g(e, ...)
e_bezier_curve_g(e, ...)Arguments
- e
An
echarts4robject as returned bye_chartsor a proxy as returned byecharts4rProxy.- ...
Any other option to pass, check See Also section.
Note
Some elements, i.e.: e_image_g may not display in the RStudio
browwser but will work fine in your browser, R markdown documents and Shiny
applications.
Functions
e_graphic_gto initialise graphics, entirely optional.e_group_gto create group, the children of which will share attributes.e_image_gto a png or jpg image.e_text_gto add text.e_rect_gto add a rectangle.e_circle_gto add a circle.e_ring_gto add a ring.e_sector_ge_arc_gto create an arc.e_polygon_gto create a polygon.e_polyline_gto create a polyline.e_line_gto draw a line.e_bezier_curve_gto draw a quadratic bezier curve or cubic bezier curve.
Examples
# may not work in RStudio viewer
# Open in browser
cars |>
e_charts(speed) |>
e_scatter(dist) |>
e_image_g(
right = 20,
top = 20,
z = -999,
style = list(
image = "https://www.r-project.org/logo/Rlogo.png",
width = 150,
height = 150,
opacity = .6
)
)
anno_text <-
'xAxis represents miles per gallon, yAxis represents weight in tonnes.'
# Position does change depending on window size.
mtcars |>
e_charts(mpg) |>
e_line(wt) |>
e_group_g(
left = '18%',
top = '55%',
children = list(
# Background rectangle
list(
type = 'rect',
z = 100,
left = 'center',
top = 'middle',
shape = list(
width = 240,
height = 70
),
style = list(
fill = '#fff',
stroke = '#555',
lineWidth = 1,
shadowBlur = 8,
shadowOffsetX = 3,
shadowOffsetY = 3,
shadowColor = 'rgba(0,0,0,0.2)'
)
),
# Text element
list(
type = 'text',
z = 100,
left = 'center',
top = 'middle',
style = list(
fill = '#333',
width = 220,
overflow = 'break',
text = anno_text,
font = '14px Microsoft YaHei'
)
)
)
)
#' @seealso \href{https://echarts.apache.org/en/option.html#graphic}{official documentation}
