This file contains hidden or 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
| cns <- countrycode::codelist$country.name.en | |
| cns <- data.frame( | |
| name = cns, | |
| value = round(runif(length(cns), 1, 100), 2) | |
| ) | |
| library(echarty) | |
| p <- ec.init(load= 'world') | |
| p$x$opts <- list( | |
| series= list(list( |
This file contains hidden or 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
| #'----------------- Interactive charts with echarty and Shiny ------------------- | |
| #' this code not maintained, see latest version in demo(eshiny, package='echarty') | |
| library(shiny) | |
| library(dplyr) | |
| library(echarty) | |
| base_df <- data.frame(ValX = c("A", "B", "C"), ValY = 1:3) | |
| boxplot_df <- data.frame(ValX = sample(LETTERS[1:3], size = 20, replace = TRUE), | |
| ValY = rnorm(20)) |
This file contains hidden or 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
| #' data from https://github.com/tungmilan | |
| #' see Hierarchies in https://helgasoft.github.io/echarty/uc3.html | |
| DF <- data.frame( | |
| parents = c("Mid Stream","Mid Stream","Mid Stream","Mid Stream", | |
| "Mid Stream","Mid Stream","Mid Stream","Mid Stream", | |
| "Mid Stream","Mid Stream","Mid Stream","Mid Stream", | |
| "Low Stream","Low Stream", | |
| "Low Stream","Low Stream", | |
| "Low Stream","Mac River","Mac River","Mac River", |
This file contains hidden or 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
| #' replace chart series interactively in Shiny | |
| #' idea from https://github.com/EKtheSage | |
| library(shiny) | |
| library(dplyr) | |
| library(echarty) | |
| ui <- fluidPage( titlePanel("echarty + Shiny"), | |
| radioButtons('yvars', | |
| label = 'Select a Y Variable to Plot', | |
| selected = 'Sepal.Width', |
This file contains hidden or 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) | |
| flights <- read.csv('https://raw.githubusercontent.com/plotly/datasets/master/2011_february_aa_flight_paths.csv') | |
| df <- head(flights) %>% relocate(start_lon, start_lat, end_lon) %>% | |
| group_by(airport1) %>% group_split() | |
| map.center <- c(mean(flights$start_lon), mean(flights$start_lat)) | |
| options <- lapply(df, function(y) { | |
| series <- list( | |
| list(type='scatter', coordinateSystem='geo', | |
| data = ec.data(y, 'values'), symbolSize = 8), |
This file contains hidden or 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. --------------- ECharts heatmap with categorical data, like ggplot2::geom_tile | |
| v <- LETTERS[1:10] | |
| set.seed(2021) | |
| matrix <- data.frame( | |
| x = sample(v, 300, replace = TRUE), | |
| y = sample(v, 300, replace = TRUE), | |
| z = sample(LETTERS[1:3], 300, replace = TRUE), |
This file contains hidden or 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
| sankey <- data.frame( | |
| stringsAsFactors = TRUE, | |
| source = c("Objetivo 1", | |
| "Objetivo 2","Objetivo 3","Objetivo 4", | |
| "Objetivo 1","Objetivo 2","Objetivo 3", | |
| "Objetivo 4","Objetivo 1","Objetivo 2","Objetivo 3", | |
| "Objetivo 4","Objetivo 1","Objetivo 2", | |
| "Objetivo 3"), | |
| target = c("ODS 17: Alianzas para lograr los objetivos", | |
| "ODS 10: Reducción de las desigualdades", |
This file contains hidden or 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
| #' echarty demo for marmap | |
| library(shiny) | |
| library(shinydashboard) | |
| library(shinybusy) | |
| library(echarty) | |
| library(marmap) | |
| ui = dashboardPage(title='marmap', dashboardHeader(title='Bathymetry Demo'), | |
| sidebar = dashboardSidebar( | |
| fluidRow( column(12, |
This file contains hidden or 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(stringr) | |
| library(echarty) | |
| library(rclipboard) # for clipboard Copy button | |
| library(formatR) | |
| if (FALSE) { # notes | |
| #' problem plot with Chinese chars: | |
| #' text='<U+6F0F><U+6597><U+56FE>' > Sys.getlocale() |
This file contains hidden or 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
| # ------ 1) prepare data | |
| library(tibble) | |
| dim <- 12500 # sample data half-quantity | |
| slip <- if (dim %% 2) 0.1 else -0.1 | |
| setData <- function(offset) { | |
| t <- tibble(x = runif(dim, max=10), | |
| y = offset + sin(x) - x * slip * runif(dim)) | |
| round(t,3) | |
| } |