dygraphs icon indicating copy to clipboard operation
dygraphs copied to clipboard

Barplot seems to be cutting off boundaries

Open mgahan opened this issue 6 years ago • 1 comments

Hey everyone,

This is such as great package! Thanks so much for all the work. I have noticed that when I use the dyBarChart function, it seems to cutoff the chart at the edges. I am not sure if there is a workaround available.

Reproducible example

Bring in libraries

library(dygraphs) #dygraphs_1.1.1.6 
library(data.table) #data.table_1.11.4

Fake dataset

dat <- structure(list(Date = structure(c(17763, 17764, 17765, 17766, 
17767, 17768, 17769), class = "Date"), Col1 = c(794L, 838L, 674L, 
955L, 784L, 744L, 915L), Col2 = c(308L, 289L, 380L, 598L, 228L, 
794L, 1186L), Col3 = c(152L, 186L, 217L, 399L, 780L, 690L, 891L
)), .Names = c("Date", "Col1", "Col2", "Col3"), row.names = c(NA, 
-7L), class = "data.frame")
setDT(dat)

Barplot example

dygraph(dat) %>% dyBarChart()

dygraph_cutoff

Thanks, Mike

mgahan avatar Aug 31 '18 17:08 mgahan

Hi Mike,

I came across the same problem. Here's one possible fix. Hope this helps, even though it's been a while.

You can add extra space around the values using "rangePad", which reveals more stuff around the cut-off. Adjust the value (pixels) if needed.

dygraph(dat) %>% dyBarChart() %>% dyOptions(rangePad = 10)

ps. dyGraph is definitely in need of maintenance. Otherwise we'll have to dig into the js files, way too much work for some graphing.

ShengningEZhang avatar Aug 11 '20 17:08 ShengningEZhang