Comments (7)
Year is numeric here so it's going to be treated as such and start from 0
data |> dplyr::mutate(Year = as.factor(Year)) |> group_by(Country) |> e_chart(Year) |> e_bar(n, stack = "group")
from echarts4r.
You can define the order of the factor levels using factor()
from echarts4r.
Thank you for the detailed post but could you give a minimal reproducible example that does not require download a CSV?
from echarts4r.
Sure. I think this example might work equivalently for now
data<-data.frame(
Country = rep(c("Afghanistan", "Albania", "Angola", "Argentina"), each = 5),
Year = rep(c(2010, 2019, 2017, 2009, 2014), 4),
n = sample(1:100, 20, replace = TRUE),
Deaths = sample(1:1500, 20, replace = TRUE),
Cases = sample(1:2000, 20, replace = TRUE),
lethality = runif(20, min = 0, max = 1),
database_name.x = rep(c("Islamic Republic of Afghanistan", "Republic of Albania", "Republic of Angola", "Argentine Republic"), each = 5),
lat.x = rep(c(33.00, 41.00, -12.50, -34.00), each = 5)
)
from echarts4r.
Interesting. The problem now is that the order of the years is not respected.
from echarts4r.
Why wouldn't something like say,
data|>group_by(Country)|>e_charts(Year)|>
e_bar(n, stack = "group")|>
e_legend(right = 5,top = 80,selector = "inverse",emphasis = list(selectorLabel = list(offset = list(10,0)), focus = "series"),show=TRUE,icon = 'circle',emphasis = list(selectorLabel = list(offset = list(10,0))), align = 'right',type = "scroll",width = 10,orient = "vertical")|>
e_x_axis(min = min(data$Year)-1,max = max(data$Year)+1)|>
e_tooltip()
Not work?
It looks like it almost would, however, the stack isn't perfect. Many countries disappear behind others in this configuration for some reason
from echarts4r.
It seems to work fine...
Or is it breaking down when more countries are added?
library(forcats)
library(dplyr)
data <- data %>% arrange(Year) %>% mutate(Year = fct_inorder(as.character(Year), ordered = T))
data|>group_by(Country)|>e_charts(Year)|>
e_bar(n, stack = "group")|>
e_legend(right = 5,top = 80,selector = "inverse",emphasis = list(selectorLabel = list(offset = list(10,0)), focus = "series"),show=TRUE,icon = 'circle',emphasis = list(selectorLabel = list(offset = list(10,0))), align = 'right',type = "scroll",width = 10,orient = "vertical")|>
e_x_axis(min = min(data$Year)-1,max = max(data$Year)+1)|>
e_tooltip()
from echarts4r.
Related Issues (20)
- timeline with multiple-y-axis setting y axis doesn't work
- timeline with multiple-y-axis setting y axis doesn't work
- e_bar chart combine with e_pie chart HOT 3
- Formatter with ec.clmn HOT 1
- e_river HOT 2
- Race and Waterfalls Charts HOT 6
- 'Cannot find function renderEcharts4r' error in Shiny Quarto document HOT 1
- Problem chaining e_text_g for multiple text placement HOT 2
- Question on shared dataset charts HOT 4
- `e_showtip_p`/ `e_dispatch_action_p` not working in modularized shiny app, attempting to debug with local fork but `debugger` doesn't register in the `addCustomMessageHandler` HOT 2
- How can I change the height and width of the elements (rectangles) on the heat map? HOT 3
- Themes from theme builder needs editing
- Make echarts4r available for webR HOT 1
- [Bug] on example code of Histogram HOT 1
- How to give each grid its own axis maximum? HOT 1
- e_radar not supporting group_by? HOT 1
- Scoring ring HOT 4
- Formatting dataView HOT 2
- margin not working when there are multiple groups of series HOT 10
- leaflet broken HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from echarts4r.