daattali / timevis

📅 Create interactive timeline visualizations in R
http://daattali.com/shiny/timevis-demo/
Other
652 stars 157 forks source link

stack and stackSubgroups issue - not show all the data #80

Closed Churongxu closed 4 years ago

Churongxu commented 4 years ago

Hi all, I come across a problem when using subgroup and options (stack/stackSubgroups). When I run the following small example, event series 3 only shows 3.1/3.1/3.3/3.6 and 3.4/3.5 disappears. I would like boxes in the same column stack on each other one by one.

timedata <- data.frame( id = 1:12, start = Sys.Date() + c(rep(1,3), rep(22,3), rep(42,6)), end = start +days(20), group = c(rep(1,12)), content = c("event 1.1", "event 1.2", "event 1.3", "event 2.1", "event 2.2", "event 2.3", "event 3.1", "event 3.2", "event 3.3","event 3.4", "event 3.5", "event 3.6"), subgroup = c(1,2,3,1,2,3,1,2,3,4,5,6) )

groups <- data.frame( id = timedata$group, content = timedata$group) %>% as_tibble() %>% unique()

timevis::timevis(data =timedata, groups = groups, options = list(stack = FALSE))

Picture1

daattali commented 4 years ago

I'm not able to run your example code. Please provide fully reproducible code.

Churongxu commented 4 years ago

library(lubridate) library(tidyverse) library(timevis)

start = Sys.Date() + c(rep(1,3), rep(22,3), rep(42,6)) timedata <- data.frame( id = 1:12, start = start, end = start +days(20), group = c(rep(1,12)), content = c("event 1.1", "event 1.2", "event 1.3", "event 2.1", "event 2.2", "event 2.3", "event 3.1", "event 3.2", "event 3.3","event 3.4", "event 3.5", "event 3.6"), subgroup = c(1,2,3,1,2,3,1,2,3,4,5,6) )

groups <- data.frame( id = timedata$group, content = timedata$group) %>% as_tibble() %>% unique()

timevis::timevis(data =timedata, groups = groups, options = list(stack = FALSE))

daattali commented 4 years ago

The boxes "disappear" because they have the exact same dates and same subgroup and you explicitly use code to disable stacking. Change the stack = FALSE to stack = TRUE

Churongxu commented 4 years ago

Actually, I have tried stack in either direction. I even have tried different subgroup frame as belows, the output still looks like this. What I really want is no space in one column, for example, I want event 3 series start from the origin, and there is no space between event 3.3 and 3.4.

subgroup = c(1,1,1,2,2,2,3,3,3,3,3,3) subgroup = c(1,2,3,1,2,3,1,2,3,4,5,6) subgroup = c(1,2,3,4,5,6,7,8,9,10,11,12)

pic

daattali commented 4 years ago

This is what you original code looks like to me when I turn stacking on

image

If this is not what you want, then perhaps what you want is not doable with the library. It certainly doesn't seem like a timevis issue. You can look at the documentation for the javascript library and see if it supports exactly what you're trying to do https://almende.github.io/vis/docs/timeline/ If it's supported in the javascript then it should be doable using timevis as well