JohnCoene / echarts4r

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

Themes from theme builder needs editing #615

Open Parviainen opened 5 months ago

Parviainen commented 5 months ago

Using the format generate by theme builder does not work out of the box. In the example below, the symbols and line are not changed to squares of size 10 and being smooth. The second example works however. The first example follows the format from the theme builder, the second mimics that from the .js files in echarts4r/htmlwidgets/lib/echarts-4.8.0/themes

library(echarts4r)

df <- data.frame(x = c(1, 2, 3, 4),
                 y = c(0.5, 1, 0.8, 1.4))

df |>
  e_chart(x = x) |>
  e_line(serie = y) |>
  e_theme_custom(theme = '{
                           "lineSmooth": true,
                           "color":["#ff715e","#ffaf51"],
                           "backgroundColor": "#f5f5f5",
                           "symbol": "square",
                           "symbolSize": 10 }')

df |>
  e_chart(x = x) |>
  e_line(serie = y) |>
  e_theme_custom(theme = '{
                           "color":["#ff715e","#ffaf51"],
                           "line": {
                              "smooth": true,
                              "symbol": "square",
                              "symbolSize": 10
                            },
                           "backgroundColor": "#f5f5f5"}')

Session info:

R version 4.3.2 (2023-10-31)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.2.1

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

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

other attached packages:
[1] echarts4r_0.4.5

loaded via a namespace (and not attached):
 [1] vctrs_0.6.5       cli_3.6.2         rlang_1.1.3       promises_1.2.1    generics_0.1.3    shiny_1.8.0       jsonlite_1.8.8    xtable_1.8-4      glue_1.7.0       
[10] htmltools_0.5.7   httpuv_1.6.14     fansi_1.0.6       tibble_3.2.1      ellipsis_0.3.2    fastmap_1.1.1     yaml_2.3.8        lifecycle_1.0.4   compiler_4.3.2   
[19] dplyr_1.1.4       htmlwidgets_1.6.4 Rcpp_1.0.12       pkgconfig_2.0.3   rstudioapi_0.15.0 later_1.3.2       digest_0.6.34     R6_2.5.1          tidyselect_1.2.0 
[28] utf8_1.2.4        pillar_1.9.0      magrittr_2.0.3    tools_4.3.2       mime_0.12        

chart_1 chart_2