Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use e_text_g and e_image_g at the same time #444

Open
issactoast opened this issue Jul 13, 2022 · 1 comment
Open

use e_text_g and e_image_g at the same time #444

issactoast opened this issue Jul 13, 2022 · 1 comment

Comments

@issactoast
Copy link

Hi, thanks for making this awesome package!

I was trying to use both function; e_text_g and e_image_g, they doesn't work together as follows:

library(tidyverse)
library(echarts4r)

example_df <- data.frame(type = c("a", "b"),
                         value = c(10, 20))

example_df %>% echarts4r::e_charts(type) %>%
    echarts4r::e_bar(value) %>%
    e_draft() %>%
    e_image_g(
        right = 20,
        top = 20,
        z = -999,
        style = list(
            image = "https://www.r-project.org/logo/Rlogo.png",
            width = 150,
            height = 150,
            opacity = .6
        )
    )

Created on 2022-07-13 by the reprex package (v2.0.1)

@rdatasculptor
Copy link
Contributor

rdatasculptor commented Jul 27, 2022

@issactoast

You seem right there seems to be a bug, or at least I can't explain why your approach doesn't work. However you can do what you want if you use e_graphic_g.
Like this:

library(tidyverse)
library(echarts4r)

example_df <- data.frame(type = c("a", "b"),
                         value = c(10, 20))

example_df %>% echarts4r::e_charts(type) %>%
    echarts4r::e_bar(value) %>%
    e_graphic_g(list(
    elements = list(
    list(type = "text",
	     left = "center", top = "center",
	     updateAnimation = list(duration = 100),
	     style = list(fill = "#d3d3d3",
	     text = "DRAFT", 
	     font = paste("120px", "\"STHeiti\", sans-serif"), 
        opacity = 0.4)
		  	  ),
		list(type = "image",
	     right = 20,
        top = 20,
        z = -999,
        style = list(
            image = "https://www.r-project.org/logo/Rlogo.png",
            width = 150,
            height = 150,
            opacity = .6
	  )))))

Enjoy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants