daattali / timevis

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

Input format for nestedGroups (if supported) #68

Closed strazto closed 5 years ago

strazto commented 5 years ago

Hi, I noticed you discussed this a while back in #32 , but I couldn't really tell where you landed on it, whether it was an incorporated feature, or whether it could be done, but requires users to parse their list-cols to something json-friendly. Could I please have some clarification on this?

Presently a list col, nestedGroups, seems to be coerced to this format: "c(\"ID1\", \"ID2\")"

If providing a string were to work, I'd assume that '[ "ID1", "ID2"]' might suffice

strazto commented 5 years ago

After investigating a little further, and looking at your attempts to deal with it, I see now that you did attempt a js-side fix by a little extra parsing, but didn't see much results and moved on. The fix might be to force to-string coercion in R, and then parse it back into something .js friendly?

The other user mentioned having to mess up a bunch of your data checks to implement his version. I will try this now, and see how it goes, anyway

strazto commented 5 years ago

Have forked and made a pull request

daattali commented 5 years ago

I see your PR was closed. I never looked into this issue since that very old discussion, so there is nothing new on my end. If you find a simple elegant way to support it, please do submit a PR

strazto commented 5 years ago

I closed it because it wasn't really working the way I expected. I wound up modifying the dataframeToD3 function to pass through nested list columns, which seems to have worked, kind-of. I don't see any nesting in my Rstudio output, nor chrome. When I examine the source of the output widget, I see this: An example nested entry

{
            "group": "1:Ryde",
            "id": "L:7",
            "start": "1995-12-01 17:00:00",
            "end": "1995-12-04 11:00:00",
            "subgroup": "Ryde",
            "content": "W: Ward 2 RYD B: 5 Cat: NA L:7",
            "style": " font-size : 12pt;padding-bottom: 0px;",
            "pid": "1"
        }],

The groups section

        "groups": [{
            "id": "1",
            "content": "1",
            "nestedGroups": ["1:Ryde", "1:Royal North Shore"]
        }, {
            "id": "2",
            "content": "2"
        }, {
            "id": "1:Ryde",
            "content": "1:Ryde"
        }, {
            "id": "1:Royal North Shore",
            "content": "1:Royal North Shore"
        }]

I'm not sure what I'm missing here, though. I'm not particularly experienced in js but I remember from one of your comments elsewhere that usually the tool aims to just pass all the data through to the relevant js library. This data looks an awful lot like how nested group data should, though. Do you have any ideas on this?

strazto commented 5 years ago

I guess the question is, is this just a problem of how to pass a list-col through to the .js api? If so, I think that's solved. I think my real problem is that I'm using vis 16.1, and I don't THINK it supports nesting yet?

daattali commented 5 years ago

Looking at the changelog of visjs, it looks like nested groups was added in v4.18. I'm holding back on updating because of a few issues and I tried reaching out to the devs a few times to get them to address it. Feel free to bug them as well :)

strazto commented 5 years ago

Yeah, that was the magic bullet that made it work. I'll need to clean up my tree a bit before I make a pull request, as I added glue to suggests so I could use it for test error output. I immediately noticed those "issues" - with 4.21 RStudio's viewer seems to just give up entirely. Also, the problem with folding on nests seems to be present.

daattali commented 4 years ago

This will be looked at again once #50 is done (which is stuck because visjs has still not fixed its regression bugs from a few years ago)