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

e_gauge: remove plot area margins #568

Open
micboat opened this issue Sep 10, 2023 · 3 comments
Open

e_gauge: remove plot area margins #568

micboat opened this issue Sep 10, 2023 · 3 comments

Comments

@micboat
Copy link

micboat commented Sep 10, 2023

Hi is there any way to completely remove or at least reduce the margins from e_gauge plots? the space between the gauage plots and the rest of the narrative in my quarto document is too noticeable.

I tried setting e_grid but it doesnt seem to apply.

e_charts() %>%
e_y_axis(gridIndex = 0, min=0,max=100) %>%
e_gauge(1.01, "LoA", min = 0, max = 2, splitNumber = 20,
axisLine = list(
lineStyle = list(
color = list(
c(0.4, "red"),
c(0.45, "yellow"),
c(0.55, "green"),
c(0.6, "yellow"),
c(20/20, "red")
)
)
))

Am trying to set up 6 gauges (2 rows 3 cols) compacted but the margins makes that impossible. I tried the e_arrange but it didnt help either
Screenshot 2023-09-09 at 9 15 15 PM

@rdatasculptor
Copy link
Contributor

@micboat can you add what you tried with e_grid modifications? Thanks!

@micboat
Copy link
Author

micboat commented Sep 11, 2023

@rdatasculptor I tested your approach. Couldn't get the labels on there so I ended up creating each gauge and using combinewidgets to display them. Each chart had different metrics customization. But this is how far I got with your recommendation:

Load the library

librarian::shelf(echarty, data.table)

df <- data.table(
Metric = c('LoA', 'CoD', 'PRB', 'PRD', 'MKI', 'RRI'),
Estimate = c(1.003, 9.14, -0.041, 1.012, 0.881, 0.065),
Min = c(0, 0, -0.5, 0.5, 0.5, 0),
Max = c(2, 25, 0.5, 1.5, 1.5, 1),
Split_no = c(10, 10, 10, 10, 10, 10),
Colorlist = list(
list(
c(0.4, "red"),
c(0.45, "yellow"),
c(0.55, "green"),
c(0.6, "yellow"),
c(1, "red")
),
list(
c(4/25, "red"),
c(5/25, "yellow"),
c(10/25, "green"),
c(12/25, "yellow"),
c(25/25, "red")
),
list(
c(8/20, "red"),
c(9/20, "yellow"),
c(11/20, "green"),
c(12/20, "yellow"),
c(20/20, "red")
),
list(
c(8/20, "red"),
c(9/20, "yellow"),
c(11/20, "green"),
c(12/20, "yellow"),
c(20/20, "red")
),
list(
c(8/20, "red"),
c(9/20, "yellow"),
c(11/20, "green"),
c(12/20, "yellow"),
c(20/20, "red")
),
list(
c(0.10, "#006400"),
c(0.25, "#7fbf7f"),
c(0.50, "#FFFF00"),
c(0.75, "#FFA07A"),
c(10/10, "red")
)
)
)

tmp <- lapply(ec.data(df, 'names'), function(c) { # ec.data() converts data.frame into named list
ec.init(height= '40vh', grid= list(left=0, right=0, top=0, bottom=0, show=T),
series= list(list(type= 'gauge',
data= list(c$Estimate),
label=c$Metric,
radius='95%',
min= c$Min,
max= c$Max,
splitNumber= c$Split_no, axisLine= list(
lineStyle= list( color= c$Colorlist )
)
))
)
})
ec.util(cmd= 'layout', charts= tmp, cols= 3)

@rdatasculptor
Copy link
Contributor

Thanks! I think you put the wrong script in your answer. That's {echarty}, not {echarts4r} :).

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