JohnCoene / echarts4r

🐳 ECharts 5 for R
http://echarts4r.john-coene.com/
Other
595 stars 81 forks source link

`bottom` argument of `e_legend` does not work ? #443

Closed GillesSanMartin closed 2 years ago

GillesSanMartin commented 2 years ago

In the following reproducible example, nothing seems to happen when I change de value of the bottom argument of e_legend function. If I change the top argument value, the legend moves away from the top of the graph as expected.

library(dplyr)
library(echarts4r)

df <- data.frame(
    Letters = LETTERS, 
    X = rnorm(26), 
    Y = rnorm(26)
)

df |> 
    group_by(Letters) |> 
    e_chart(x = X) |> 
    e_scatter(serie = Y, symbol_size = 10) |> 
    e_grid(left = '15%') |> 
    e_legend(orient = 'vertical', 
             left = '2%', 
             top = '20%', 
             bottom = '70%' # does not work ??
    )

sessionInfo output :

R version 4.2.1 (2022-06-23)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.20.so

locale:
 [1] LC_CTYPE=fr_BE.UTF-8       LC_NUMERIC=C               LC_TIME=fr_BE.UTF-8        LC_COLLATE=fr_BE.UTF-8    
 [5] LC_MONETARY=fr_BE.UTF-8    LC_MESSAGES=fr_BE.UTF-8    LC_PAPER=fr_BE.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=fr_BE.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] echarts4r_0.4.4 dplyr_1.0.9    
JohnCoene commented 2 years ago

You have to use either top or bottom not both. What you trying to achieve?

GillesSanMartin commented 2 years ago

Sorry, I thought these options should be used to define the margins (as often in R) not the position. What I was looking for was a way to add some withe space at the bottom of the legend because in my real life example, the last element of the legend was masked (after selector buttons)

This is what I was looking for :

df |> 
    group_by(Letters) |> 
    e_chart(x = X) |> 
    e_scatter(serie = Y, symbol_size = 10) |> 
    e_grid(left = '20%') |> 
    e_legend(orient = 'vertical', 
             left = '2%', 
             padding = c(50,5,50,5), 
             selector = list(  
                 list(type = 'inverse', title = 'Invert'),
                 list(type = 'all', title = 'Reset'))
    )

Sorry for the unnecessary disturbance and thank you for developing such a great package !

JohnCoene commented 2 years ago

No worries, don't apologise :)