JohnCoene / echarts4r

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

funnel chart does not accept nested list parameter #23

Closed happyshows closed 5 years ago

happyshows commented 6 years ago

Hi,

Below code will run into error:

funnel %>% e_charts() %>% e_funnel(value, stage, legend = F, label = list(show = T) )

Warning: 'glue::collapse' is deprecated. Use 'glue_collapse' instead. See help("Deprecated") and help("glue-deprecated"). Error: list(show = T) must evaluate to column positions or names, not a list

while level 1 parameters works fine, like below funnel %>% e_charts() %>% e_funnel(value, stage, legend = F, maxSize = '250%' )

I have tried similar approach in graph which seems to work well:

    e_charts() %>%
      e_graph(name = 'Diagram', roam = T, nodeScaleRatio = 0.5, layout = 'circular', 
              label = list(show = T, color = '#999', offset = c(20,20)),
              symbolSize = 50, focusNodeAdjacency=T, symbol = 'roundRect')
JohnCoene commented 6 years ago

It's some stange behaviour from tidyeval because labels and label closely match. I will investigate that.

In the meantime, it works by naming all arguments explicitely:

funnel <- data.frame(stage = c("View", "Click", "Purchase"), value = c(80, 30, 20))

funnel %>% 
  e_charts() %>% 
  e_funnel(values = value, labels = stage, label = list(show = FALSE))
happyshows commented 6 years ago

cool thanks for the clarification

happyshows commented 6 years ago

I tried with your recommendation, however, it pop up with new error

      funnel %>% 
        e_charts() %>% 
        e_funnel(values = value, labels = stage, legend = F,
                 maxSize = '250%',label = list(show = FALSE))

Error: Can't convert a list to a quosure

JohnCoene commented 6 years ago

Apologies, fiddled a bit with the function, this works after reinstall.

funnel <- data.frame(stage = c("View", "Click", "Purchase"), value = c(80, 30, 20))

funnel %>% 
  e_charts() %>% 
  e_funnel(values = value, labels = stage, label = list(show = FALSE))
JohnCoene commented 5 years ago

I've added a function to deal with nested data such as this, works with any chart type.

funnel <- data.frame(
  stage = c("View", "Click", "Purchase"), 
  value = c(80, 30, 20),
  color = c("blue", "red", "green")
)

funnel %>% 
  e_charts() %>% 
  e_funnel(value, stage) %>% 
  e_add("itemStyle", color)

Example on the website in the advanced section.