1

I am trying to construct a pareto chart with echarts4R. Everything seems to work, however I can't figure out how to plot one horizontal line departing from the second y-axis on the right at the 80% level. Now it draws two horizontal lines departing both from the first y-axis at the respective 80 levels. Another option would be to have a single dot on the cumm.perc. line at 80%, indicating where this line reaches the 80% level. I also wonder how to get the % symbol on the second y-axis and how to label the second y-axis with e_axis_labels. (btw, I don't know java so I am looking for a solution within echarts4r)

Below an image showing the two lines departing from the left y-axis, where I would like 1 line departing from the right y-axis (the green one)

enter image description here

library(tidyverse)
library(echarts4r)

Data4Pareto <- data.frame(
  KPI = c("Price", "Delivery","Quality","Packaging", "Support"),
  Complaints= c(15,100,15,120,20)) 

Data4Pareto |>
  arrange(desc(Complaints)) |>
  mutate(cumm.perc. = (cumsum(Complaints)/sum(Complaints) * 100)) |>
  e_charts(KPI) |>
  e_bar(Complaints) |>
  e_line(cumm.perc., y_index = 1) |>
  e_axis_labels(y = "Complaints", x = "KPI") |>
  e_mark_line(data = list(yAxis = 80),
              y_index = 1, 
              symbol = "none", 
              lineStyle = list(type = 'solid'), 
              title = "80% threshold") |>
  e_tooltip(trigger = "axis")|>
  e_title("Pareto Chart") |>
  e_legend(FALSE) |>
  e_theme("chalk")
Kensho
  • 43
  • 5
  • It would be helpful if you added a screenshot of the current result and maybe drawed by hand what it should be? Thanks! – rdatasculptor Nov 27 '22 at 16:49
  • Thx, I did, it is about the e_mark_line code. y_index = 1 is the reference for the second y-axis (default = 0 for the y-axis on the left). – Kensho Nov 27 '22 at 17:33
  • Thanks for adding the chart! If I understand correctly aren't you helped by just moving the label of the mark line to the start instead of the end of the line? You can do this by adding `label = list(position = "start")` as an argument to the `e_mark_line()` function. – rdatasculptor Nov 28 '22 at 08:56

0 Answers0