JohnCoene / echarts4r

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

Questions: Color Multiple Categories of Boxplot #361

Open rleyvasal opened 3 years ago

rleyvasal commented 3 years ago

Questions:

  1. How to color different categories of boxplots?

  2. Is there a way use color to fill the box plot as shown on apache website? https://echarts.apache.org/examples/en/editor.html?c=data-transform-aggregate

multiple_category_boxplot
rdatasculptor commented 3 years ago

Have you tried something like a color column in your data frame and then use e_add(color=color)?

rleyvasal commented 3 years ago

I tried , the following and it does not work: e_add(color = c('blue', 'green','yellow'))

also, the following code colors every boxplot blue (not different colors):

e_color(c('blue', 'green','yellow'))

rdatasculptor commented 3 years ago

Okay, I took a real look.

According to the documentation I expected the way to do go should be this:

mtcars |> e_charts() |>
 e_boxplot(disp, itemStyle = list(color = "blue")) |>
 e_boxplot(hp, itemStyle = list(color ="green")) |>
 e_boxplot(mpg, itemStyle = list(color = "yellow")) |>
 e_tooltip(trigger = "axis")

But then all the boxplots turn blue. So at least one color seems right that way :)