This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://echarts.apache.org/en/api.html#echartsInstance.resize | |
# https://echarts.apache.org/examples/en/editor.html?c=line-easing | |
library(shiny); library(dplyr); library(echarty) | |
ui <- fluidPage( titlePanel("Resize with echarty"), | |
fluidRow(ecs.output('chart')), | |
checkboxInput('toggle900','Toggle Size 900px'), | |
checkboxInput('toggle400','Toggle Size 400px') | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(echarty) | |
ui <- fluidPage( | |
fluidRow( | |
column(8, ecs.output("chart")), | |
column(4, actionButton("bzoom", "Brush"), #verbatimTextOutput('verb')) | |
tableOutput('dats') ) | |
) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# draw regression lines on data groups with echarty | |
# see https://echarts.apache.org/en/option.html#dataset.fromDatasetIndex | |
# see https://echarts.apache.org/en/option.html#series-line.datasetIndex | |
library(echarty); library(dplyr) | |
linecolor <- c('blue','green','brown') # color of regression lines | |
p <- iris %>% group_by(Species) %>% | |
ec.init(js = 'echarts.registerTransform(ecStat.transform.regression);') # load ecStat | |
# add transformations and regression lines to preset scatter groups |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set a custom locale in ECharts with echarty | |
# idea from @williamorim | |
# install.packages("remotes") | |
remotes::install_github("helgasoft/echarty") | |
library(echarty) | |
library(lubridate) | |
df <- data.frame(date=as.Date('2019-12-31') %m+% months(1:13), num=runif(13)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# original code by https://github.com/Camil88 | |
library(shiny) | |
library(dplyr) | |
library(nycflights13) | |
library(shinyWidgets) | |
library(echarty) | |
library(scales) | |
toggle <- FALSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(echarty); library(dplyr) | |
# 1) boxplot with calculation in R --------------------- | |
p <- ec.init() | |
p$x$opts$series <- list( | |
list(type='boxplot', name='mpg', data=list(boxplot.stats(mtcars$mpg)$stats)), | |
list(type='boxplot', name='hp', data=list(boxplot.stats(mtcars$hp)$stats)), | |
list(type='boxplot', name='disp',data=list(boxplot.stats(mtcars$disp)$stats)) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(echarty); library(dplyr) | |
# set first column as X and second as Y to avoid explicitly define them later | |
mydf <- data.frame( | |
Date = c("2021-08-02", "2021-08-03", "2021-08-04", "2021-08-05", "2021-08-06", "2021-08-09", "2021-08-10", "2021-08-11", "2021-08-02", "2021-08-03", "2021-08-04", "2021-08-05", "2021-08-06", "2021-08-09", "2021-08-10", "2021-08-11", "2021-08-02", "2021-08-03", "2021-08-04", "2021-08-05", "2021-08-06", "2021-08-09", "2021-08-10", "2021-08-11", "2021-08-02", "2021-08-03", "2021-08-04", "2021-08-05", "2021-08-06", "2021-08-09", "2021-08-10", "2021-08-11"), | |
CasesPer100K = c(397, 575, 579, 591, 617, 733, 654, 690, 54, 79, 83, 88, 92, 76, 104, 107, 84, 89, 95, 101, 106, 123, 125, 133, 151, 249, 287, 249, 259, 245, 371, 378), | |
State = c("Florida", "Florida", "Florida", "Florida", "Florida", "Florida", "Florida", "Florida", "Massachusetts", "Massachusetts", "Massachusetts", "Massachusetts", "Massachusetts", "Massachusetts", "Massachusetts", "Massachusetts", "New York", "New York", "Ne |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Undocumented feature found for 'gauge' in ECharts (https://echarts.apache.org/en/option.html#series-gauge.type) | |
# Attribute 'encode' is not even mentioned in the docs, but could be used when 'dataset' is present. | |
# All columns listed in 'encode' (like x,y,z) are ignored and first remaining dataset column becomes gauge data. | |
# In example below this 'first remaining' column is 'circumference'. Neat!? | |
library(echarty); library(dplyr) | |
df <- Orange %>% filter(age==1582) %>% mutate(Tree=as.character(Tree)) | |
clr <- c("#eeb422","#382278","#d9534f",'magenta','red') | |
p <- df %>% group_by(Tree) %>% ec.init( preset=FALSE, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#' Area band (confidence bands) is a 'custom' serie with lower and upper boundaries | |
#' When type='polygon', coordinates of the two boundaries are chained into a polygon and displayed as one. | |
#' When type='stack', two (smooth) stacked lines are drawn, one with customizable areaStyle. | |
#' The upper boundary coordinates should be values added on top of the lower boundary coordinates. | |
#' Standard and custom(formatter) tooltips could be used. | |
#' | |
#' ec.init(load='custom') will preset values like dataset, xAxis, etc. | |
#' those could be customized (like xAxis below), and new ones added - like legend and tooltip. | |
library(echarty) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
library(tidyverse) | |
library(echarty) | |
ui <- fluidPage( | |
HTML("Binding two charts on <b>inside zoom</b> only<br /> | |
Tooltips could be bound too, by `axis`<br /> | |
Alternative to ECharts <a href='https://echarts.apache.org/en/api.html#echarts.connect'>connect</a><br /> | |
Solution adapted from <a href='https://github.com/apache/echarts/blob/12f6620c25eb96faa3e9f9fbc13a076c3c8bdbbc/test/connect-manually.html'>this code</a>"), | |
tags$head(tags$script(HTML(" |