Title: | Mobile Charts |
---|---|
Description: | Create charts optimized for mobile. |
Authors: | John Coene [aut, cre], rinterface [cph] |
Maintainer: | John Coene <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.0.1 |
Built: | 2024-11-23 03:01:58 UTC |
Source: | https://github.com/tanho63/mobileCharts |
Customise axis.
mobile_hide_axis(m) mobile_axis_x(m, ...) mobile_axis_y(m, ...)
mobile_hide_axis(m) mobile_axis_x(m, ...) mobile_axis_y(m, ...)
m |
An object of class |
... |
Named options from the official documentation. |
df <- data.frame( label = c("banana", "apple", "cake"), value = c(50, 30, 20), x = "1" # phoney variable ) mobile(df, aes(x, value, color = label, adjust = stack)) %>% mobile_bar() %>% mobile_coord("polar", transposed = TRUE) %>% mobile_hide_axis()
df <- data.frame( label = c("banana", "apple", "cake"), value = c(50, 30, 20), x = "1" # phoney variable ) mobile(df, aes(x, value, color = label, adjust = stack)) %>% mobile_bar() %>% mobile_coord("polar", transposed = TRUE) %>% mobile_hide_axis()
Add a geometry.
mobile_bar(m, ..., data = NULL, inherit_aes = TRUE) mobile_point(m, ..., data = NULL, inherit_aes = TRUE) mobile_path(m, ..., data = NULL, inherit_aes = TRUE) mobile_line(m, ..., data = NULL, inherit_aes = TRUE) mobile_area(m, ..., data = NULL, inherit_aes = TRUE) mobile_polygon(m, ..., data = NULL, inherit_aes = TRUE) mobile_schema(m, ..., data = NULL, inherit_aes = TRUE)
mobile_bar(m, ..., data = NULL, inherit_aes = TRUE) mobile_point(m, ..., data = NULL, inherit_aes = TRUE) mobile_path(m, ..., data = NULL, inherit_aes = TRUE) mobile_line(m, ..., data = NULL, inherit_aes = TRUE) mobile_area(m, ..., data = NULL, inherit_aes = TRUE) mobile_polygon(m, ..., data = NULL, inherit_aes = TRUE) mobile_schema(m, ..., data = NULL, inherit_aes = TRUE)
m |
An object of class |
... |
Aesthetics. |
data |
A data.frame. |
inherit_aes |
Whether to inherit the aesthetics from |
mobile(cars) %>% mobile_point(aes(speed, dist))
mobile(cars) %>% mobile_point(aes(speed, dist))
Initialise a chart.
mobile(data = NULL, ..., width = NULL, height = NULL, elementId = NULL)
mobile(data = NULL, ..., width = NULL, height = NULL, elementId = NULL)
data |
A data.frame. |
... |
Mobile chart aesthetics. |
width , height
|
Must be a valid CSS unit (like |
elementId |
ID of element holding the mobile chart. |
mobile(cars) %>% mobile_point(aes(speed, dist))
mobile(cars) %>% mobile_point(aes(speed, dist))
Animate various aspects of the chart.
mobile_animate(m, aspect, ...)
mobile_animate(m, aspect, ...)
m |
An object of class |
aspect |
Aspect to animate, see section below for valid values. |
... |
Named options from the official documentation. |
Valid aspect
:
axis-label
axis-grid
axis-tick
axis-line
line
area
bar
path
point
polygon
schema
mobile(cars, aes(speed, dist)) %>% mobile_point() %>% mobile_animate( "point", appear = list( animation = 'fadeIn', duration = 5000 ) )
mobile(cars, aes(speed, dist)) %>% mobile_point() %>% mobile_animate( "point", appear = list( animation = 'fadeIn', duration = 5000 ) )
Change chart coordinates.
mobile_coord(m, type = c("rect", "polar"), ...)
mobile_coord(m, type = c("rect", "polar"), ...)
m |
An object of class |
type |
Type of coordinate, |
... |
Named options from the official documentation. |
mobile(df, aes(label, value, color = label)) %>% mobile_bar() %>% mobile_coord("polar", transposed = TRUE, innerRadius = .7) %>% mobile_hide_axis()
mobile(df, aes(label, value, color = label)) %>% mobile_bar() %>% mobile_coord("polar", transposed = TRUE, innerRadius = .7) %>% mobile_hide_axis()
Add interactions on pan, pinch, bar selection or pie selection.
mobile_interaction(m, interaction, ...)
mobile_interaction(m, interaction, ...)
m |
An object of class |
interaction |
Name of the interaction. |
... |
Named options from the official documentation. |
bar-select
pie-select
pinch
pan
df <- data.frame( x = letters[1:5], y = runif(5) ) mobile(df, aes(x, y)) %>% mobile_bar() %>% mobile_interaction("bar-select") df <- data.frame( x = 1:20, y = runif(20, 1, 10) ) mobile(df, aes(x, y)) %>% mobile_bar() %>% mobile_interaction("pan", limitRange = list(x = list(min = -20, max = 40)))
df <- data.frame( x = letters[1:5], y = runif(5) ) mobile(df, aes(x, y)) %>% mobile_bar() %>% mobile_interaction("bar-select") df <- data.frame( x = 1:20, y = runif(20, 1, 10) ) mobile(df, aes(x, y)) %>% mobile_bar() %>% mobile_interaction("pan", limitRange = list(x = list(min = -20, max = 40)))
Customise the legend of the chart.
mobile_legend(m, ...)
mobile_legend(m, ...)
m |
An object of class |
... |
Named options from the official documentation. |
mobile(cars) %>% mobile_point(aes(speed, dist)) %>% mobile_legend(position = "right")
mobile(cars) %>% mobile_point(aes(speed, dist)) %>% mobile_legend(position = "right")
Pass general options to the chart.
mobile_options(m, padding = "auto", animate = TRUE)
mobile_options(m, padding = "auto", animate = TRUE)
m |
An object of class |
padding |
An integer or a list containing 4 integers
e.g.: |
animate |
Set to |
Add a scrollbar to let user pan charts.
mobile_scroll(m, mode = c("x", "y", "xy"), ...)
mobile_scroll(m, mode = c("x", "y", "xy"), ...)
m |
An object of class |
mode |
Axis to apply scroll to. |
... |
Named options from the official documentation. |
# range for pan lmt <- list(x = list(min = -20, max = 20)) mobile(df, aes(x, y)) %>% mobile_bar() %>% mobile_interaction("pan", limitRange = lmt) %>% mobile_scroll(mode = "x", xStyle = list(offsetY = -5))
# range for pan lmt <- list(x = list(min = -20, max = 20)) mobile(df, aes(x, y)) %>% mobile_bar() %>% mobile_interaction("pan", limitRange = lmt) %>% mobile_scroll(mode = "x", xStyle = list(offsetY = -5))
Add a tooltip. Note that the visualisations being optimized for mobile there is no such thing as hover: tooltips show on click.
mobile_tooltip(m, ...)
mobile_tooltip(m, ...)
m |
An object of class |
... |
Named options from the official documentation. |
mobile(cars) %>% mobile_point(aes(speed, dist)) %>% mobile_tooltip(snap = TRUE)
mobile(cars) %>% mobile_point(aes(speed, dist)) %>% mobile_tooltip(snap = TRUE)
Output and render functions for using mobile within Shiny applications and interactive Rmd documents.
mobileOutput(outputId, width = "100%", height = "400px") render_mobile(expr, env = parent.frame(), quoted = FALSE)
mobileOutput(outputId, width = "100%", height = "400px") render_mobile(expr, env = parent.frame(), quoted = FALSE)
outputId |
output variable to read from |
width , height
|
Must be a valid CSS unit (like |
expr |
An expression that generates a mobile |
env |
The environment in which to evaluate |
quoted |
Is |
Scale variables.
mobile_scale_x(m, ...) mobile_scale_y(m, ...)
mobile_scale_x(m, ...) mobile_scale_y(m, ...)
m |
An object of class |
... |
Named options from the official documentation. |
mobile(cars, aes(speed, dist)) %>% mobile_point() %>% mobile_scale_x(min = -10, tickCount = 20)
mobile(cars, aes(speed, dist)) %>% mobile_point() %>% mobile_scale_x(min = -10, tickCount = 20)
Set a theme
mobile_theme(m, colors, ..., background_color = NULL) mobile_ggplot_theme(m, n = 3, ...)
mobile_theme(m, colors, ..., background_color = NULL) mobile_ggplot_theme(m, n = 3, ...)
m |
An object of class |
colors |
A vector of colors to use as palette. |
... |
Any other options. |
background_color |
Background color of plot,
if |
n |
Number of colors to generate. |