1

I would like to change the color of the Text added with e_text_g() to the echarts4r plot.

example

library(echarts4r)
library(tidyverse)
data(cars)
cars

cars %>% count(speed) %>% 
  e_chart(speed) %>% 
  e_bar(n) %>% 
 e_text_g(style = list(text = c("Text i want like to change to red"), # change the color of the text
            fontSize = 20, opacity = .7, color = "red"), left = 75, top = 1) %>% 
            e_text_style(
            color = c("red")
          )


Ian.T
  • 1,016
  • 1
  • 9
  • 19

1 Answers1

0

If you want to change the color of that added text with e_text_g() only you can do this by adding a fill argument,

library(echarts4r)
library(dplyr)
data(cars)


cars %>%
    count(speed) %>%
    e_chart(speed) %>%
    e_bar(n) %>%
    e_text_g(
        style = list(
            text = c("Text i want like to change to red"),
            fontSize = 20,
            opacity = .7,
            fill = "red" # changing color of this text
        ),
        left = 75,
        top = 1
    )

shafee
  • 15,566
  • 3
  • 19
  • 47
  • is there a way to know when to use `color` and when to use `fill`? – Ian.T Jul 07 '22 at 04:30
  • 1
    For going down to details of `echarts4r` you have to check the [`echarts documentation`](https://echarts.apache.org/handbook/en/get-started/). For example to do this, you need to check the docs for [`graphic.elements-text. style`](https://echarts.apache.org/en/option.html#graphic.elements-text.style.fill) – shafee Jul 07 '22 at 04:37