Skip to content

Commit

Permalink
fix example e_mark
Browse files Browse the repository at this point in the history
  • Loading branch information
helgasoft committed Dec 21, 2020
1 parent 1c281df commit 6f35db3
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 70 deletions.
3 changes: 2 additions & 1 deletion R/add_.R
Expand Up @@ -2239,9 +2239,10 @@ e_error_bar_ <- function (e, lower, upper,
else { # no name - choose bar or line but not both
info <- length(unlist(lapply(ser, function(x) grep('bar', x))))
if (info==0) info <- length(unlist(lapply(ser, function(x) grep('line', x))))
if (info==0) info <- length(unlist(lapply(ser, function(x) grep('scatter', x))))
}

if (info==0) return(e) # no bars/lines, nothing to attach to, sorry, bye
if (info==0) return(e) # no bars/lines/scatter, nothing to attach to

# save minimal info to be read by renderErrorBar2
# renderers.js works in a very isolated environment, so we send data thru sessionStorage
Expand Down
46 changes: 24 additions & 22 deletions R/mark.R
Expand Up @@ -197,7 +197,7 @@ e_mark_area <- function(e, serie = NULL, data = NULL, ..., title = NULL, title_p
e
}

#' Mark points,lines,areas usable thru echarts4rProxy (by Helgasoft)
#' Use mark points/lines/areas with echarts4rProxy
#'
#' @inheritParams e_bar
#' @param type Type of mark: 'point','line' or 'area', defaults to 'point'.
Expand All @@ -208,35 +208,36 @@ e_mark_area <- function(e, serie = NULL, data = NULL, ..., title = NULL, title_p
#' @details Allows the three type of marks to work with echarts4rProxy
#'
#' @examples
#' \dontrun{
#' library(shiny); library(dplyr); library(echarts4r)
#' ui = fluidPage(
#' fluidRow( column( 3, actionButton("pxy", "Marks")),
#' column( 3, checkboxInput("tln", "Timeline", value=FALSE) )),
#'
#' library(shiny); library(dplyr);
#' ui <- fluidPage(
#' fluidRow( column( 3, actionButton("pxy", "Marks")),
#' column( 3, checkboxInput("tln", "Timeline", value=FALSE))),
#' echarts4rOutput("plot")
#' )
#' server = function(input, output) {
#' server <- function(input, output) {
#' data(EuStockMarkets)
#' bb <- as.data.frame(EuStockMarkets) %>% slice_head(n=150) %>% mutate(day=1:n())
#' output$plot <- renderEcharts4r({ react() })
#' observeEvent(input$pxy, {
#' echarts4rProxy("plot", data=NULL) %>%
#' e_mark( type='line', serie_index=1,
#' data = list(type='average'),
#' lineStyle = list(type='dashed', color='cyan')) %>%
#' data = list(type='average'),
#' lineStyle = list(type='dashed', color='cyan')) %>%
#' e_mark( serie_index=2,
#' data = list(xAxis=bb$day[60], yAxis=bb$SMI[60], value='pnt')) %>%
#' data = list(xAxis=bb$day[60],
#' yAxis=bb$SMI[60], value='pnt')) %>%
#' e_mark( type='line', serie_index=2,
#' data = list(list(xAxis=bb$day[10], yAxis=bb$SMI[10]),
#' list(xAxis=bb$day[37], yAxis=bb$SMI[37]) ),
#' lineStyle = list(type='solid', color='yellow', width=2)) %>%
#' data = list(list(xAxis=bb$day[10], yAxis=bb$SMI[10]),
#' list(xAxis=bb$day[37], yAxis=bb$SMI[37]) ),
#' lineStyle = list(type='solid', color='yellow')) %>%
#' e_mark( type='area', serie_index=1,
#' data = list(
#' list(xAxis = bb$day[95]),
#' list(xAxis = bb$day[105])
#' ),
#' itemStyle = list(color='lightblue'),
#' label = list(formatter='X-area', position='middle')
#' data = list(
#' list(xAxis = bb$day[95]),
#' list(xAxis = bb$day[105])
#' ),
#' itemStyle = list(color='lightblue'),
#' label = list(formatter='X-area', position='middle')
#' ) %>%
#' e_merge()
#' })
Expand All @@ -246,14 +247,15 @@ e_mark_area <- function(e, serie = NULL, data = NULL, ..., title = NULL, title_p
#' tmp %>%
#' e_charts(day, backgroundColor="#181818",
#' legend=list(textStyle=list(color='#aaa')),
#' timeline=input$tln) %>%
#' timeline=input$tln) %>%
#' e_y_axis(scale=TRUE, axisLabel=list(color='#aaa')) %>%
#' e_line(CAC, symbol='none', color="#ff33b8") %>%
#' e_line(SMI, symbol='none', color="green")
#' })
#' }
#' shinyApp(ui, server)
#'}
#' if (interactive()) {
#' shinyApp(ui, server)
#' }
#'
#' @name e_mark
#' @export
Expand Down
95 changes: 48 additions & 47 deletions man/e_mark.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6f35db3

Please sign in to comment.