Comments (5)
Yes, I understand. And thanks for putting me in the direction of the inspect-functions!
And last but not least, thank you for all the effort you put in echarty
! I can clearly see its power and its additional value compared to echarts4r
from echarty.
Aah, trailblazing, love it 🥇 , and going straight to crosstalk - ambitious!
However... crosstalk is communication between htmlwidgets and is not 'recorded' in the exported JSON.
Also, echarty implements crosstalk thru ECharts dataset which is not supported by echarts4r.
So I do not see a way of adding somehow crosstalk capabilities to echarts4r via echarty.
But your idea opens other possibilities of graphical integration.
Here is a playful one - adding lotties to echarts4r charts:
# df <- ...
txt <- df |>
# group_by(year) |>
e_charts(x) |> #, timeline = TRUE) |> # lotties can't be used in timeline (yet)
e_scatter(y) |>
e_loess(y ~ x) |>
e_inspect(json=TRUE, pretty=TRUE)
p4 <- ec.fromJson(txt)
json <- 'https://raw.githubusercontent.com/airbnb/lottie-ios/edf0afcfaf7e0bd37f9311a3502b2981aa8a37f2/Tests/Samples/PinJump.json'
cont <- jsonlite::fromJSON(json, simplifyDataFrame=FALSE)
# set only graphic option in echarty
py <- ec.init(preset=FALSE,
load='https://helgasoft.github.io/echarty/js/lottie-parser.js',
graphic= list(elements= list(
list( type= "group",
# lottie params = info + optional (scale, loop, etc.)
info= cont, scale= 250, # loop= FALSE,
left= 'center', bottom= '20%' #,rotation= -20
)
)) )
# merge p4 & py options
py$x$opts <- append(py$x$opts, p4$x$opts)
py
from echarty.
Combine the two packages is, as you say, a "much too complicated way to go", got to choose one.
echarts4r is user-friendly because it encapsulates a lot of settings internally.
Advanced users however need more control, echarty was born of this necessity.
The idea behind echarty's API is "why encapsulate when we can use the ECharts API directly?".
It is like C# vs C++, different ways of getting it done. A question of preference or necessity.
As a side note: both packages have functions to inspect their final option sent to ECharts.js
library(echarts4r)
cars |> e_charts(speed) |> e_scatter(dist) |> e_inspect(json=TRUE, pretty=TRUE)
library(echarty)
cars |> ec.init() |> ec.inspect() # first 2 columns taken by default as x,y
from echarty.
I think I made a first "integration" of echarts4r
and echarty
... kind of... :)
The chart is made by using echarts4r, but is displayed by using echarty.
library(echarts4r)
library(echarty)
df <- data.frame(
year = c(
rep(2016, 25),
rep(2017, 25),
rep(2018, 25),
rep(2019, 25)
),
x = rnorm(100),
y = rnorm(100),
grp = c(
rep("A", 50),
rep("B", 50)
)
)
## echarts4r
txt <- df |>
group_by(year) |>
e_charts(x, timeline = TRUE) |>
e_scatter(y) |>
e_loess(y ~ x) |>
e_inspect(json=TRUE, pretty=TRUE)
## echarty
ec.fromJson(txt)
And now I am wondering.. Could this potentially be a way for echarts4r users to bring crosstalk features to echarts4r... (Since echarty has crosstalk integration capabilities) somehow... (@JohnCoene).
This obviously doesn't work, but I was thinking of something like this:
library(crosstalk)
sdf <- mtcars %>% rownames_to_column(var='name') %>% relocate(mpg,wt)
sdf <- SharedData$new(sdf)
p <- sdf %>% ec.init(height=500, title=list(text="echarty 2D"))
p$x$opts$xAxis$scale <- TRUE
p$x$opts$yAxis$scale <- TRUE
p$x$opts <- append(p$x$opts, list(
toolbox = list(feature=list(brush=list(ey=''))),
brush = list(brushLink='all', throttleType='debounce'),
dataZoom = list(type='inside'),
tooltip = list(formatter = htmlwidgets::JS("function(params){return params.value[2];}"))
))
p$x$opts$series[[1]] = append(p$x$opts$series[[1]], list(
itemStyle = list(color = htmlwidgets::JS("function(params){
let cyl=params.value[3]; return (cyl==4 ? 'RoyalBlue' : cyl==6 ? 'OrangeRed':'green');}") ),
selectedMode = 'multiple',
select = list(itemStyle=list(color='magenta')),
emphasis = list(focus='self', blurScope='series'), # for brush rcv
blur = list(opacity = 0.2)
))
psjon <- p |> ec.inspect() |> jsonlite::fromJSON()
p2 <- e_charts() |>
e_list(psjon, append = FALSE)
bscols(
list(
filter_slider("hp", "Horsepower", sdf, ~hp, width = "100%")
), p2
)
I guess still something has to be done on the side of echarts4r
, but maybe someone can pick this up or gives this inspiration about how to make this work.
(perhaps a R and htmlwidgets hero-wizard like @timelyportfolio :))
from echarty.
Yesssssss! It opens a whole new world to explore (at least for me it does).
Thanks again @helgasoft!! This is very very inspiring.
(And thank you for the technical explanation of crosstalk)
from echarty.
Related Issues (20)
- charts morphing HOT 1
- replicate ECharts examples - polar HOT 1
- Method for initializing echart with highlighted series applied? HOT 2
- 1.5.0 causes breaks for all data without rownames or non-numeric keys HOT 3
- Mute visualMap color on specific series elements HOT 7
- Each line a different color using `dataset` option HOT 2
- Error: No handler registered mouseover since v1.5.4 HOT 3
- No handler for mouseover HOT 2
- Compressing sparse bars
- 3d scatterplot animations HOT 1
- Separate symbols/custom shapes | Within timeline frames HOT 1
- Regarding geo plots HOT 5
- An exercise in binding charts | river chart with stacked barplot HOT 8
- Legend issue HOT 3
- Features question HOT 10
- Understanding formatter HOT 3
- Combining pie chart with bar chart HOT 17
- Is GL screenshot possible HOT 7
- Possible features: Including more information HOT 5
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 echarty.