daattali / timevis

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

More detailed options for 'editable' #26

Closed poroale closed 7 years ago

poroale commented 7 years ago

Is it possible to have the possibility to change the group of an item, while disabling the possibility of changing the start / end times? The item should still be deletable.

I mean something like here, where you can edit the 'editable' option in a detailed way: http://visjs.org/examples/timeline/editing/individualEditableItems.html

var items = new vis.DataSet([ {id: 1, content: 'Editable', editable: true, start: '2010-08-23', group: 1}, {id: 2, content: 'Editable', editable: true, start: '2010-08-23T23:00:00', group: 2}, {id: 3, content: 'Read-only', editable: false, start: '2010-08-24T16:00:00', group: 1}, {id: 4, content: 'Read-only', editable: false, start: '2010-08-26', end: '2010-09-02', group: 2}, {id: 5, content: 'Edit Time Only', editable: { updateTime: true }, start: '2010-08-28', group: 1}, {id: 6, content: 'Edit Group Only', editable: { updateGroup: true }, start: '2010-08-29', group: 2}, {id: 7, content: 'Remove Only', editable: { remove: true }, start: '2010-08-31', end: '2010-09-03', group: 1}, {id: 8, content: 'Default', start: '2010-09-04T12:00:00', group: 2} ]);

daattali commented 7 years ago

I don't think that kind of thing is supported by the javascript library that timevis is built on top of. You can look at the examples of that timeline javascript library here http://visjs.org/timeline_examples.html and see if there's any examples of what you mean. If you find it then it should work with timevis as well, but I doubt that kind of thing works


R-Shiny Consultant http://deanattali.com/shiny

On 22 January 2017 at 08:48, jorkku notifications@github.com wrote:

Currently you can edit the start / end times of an item by moving the item (if editable=TRUE), but would it be possible to also have the possibility to change the row on which the item is (while disabling the ability to change the start / end times)? If there is already some item on the row I'm trying to move the current item to, then this move should be blocked.

The reason why I'm asking this is because I would like to visualize interactively a work roster and have the possibility of moving the shift from a worker to another.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/daattali/timevis/issues/26, or mute the thread https://github.com/notifications/unsubscribe-auth/AA6IFDEqbavvc3hdRxyuOBSIYWysQ8G7ks5rU15BgaJpZM4LqYxE .

poroale commented 7 years ago

Thank you for the reply.

The example "Edit Group Only" in http://visjs.org/examples/timeline/editing/individualEditableItems.html is basically what I would need.

daattali commented 7 years ago

I see, in that case you should be able to do this by simply translating the javascript options object to R. I haven't tried running this code, but something like this should work:

groups <- data.frame(id = 1:2, content = c("group1", "group2"))
df <- data.frame(id = 1:2,
                 content = c("one", "two"),
                 start = c("2016-01-10", "2016-01-12"),
                 group = 1:2)
timevis(df, groups, options = list(editable = list(updateGroup = TRUE)))

or timevis(df, groups, options = list(editable = list(updateTime = TRUE)))

(I'm getting these editable options from the documentation at http://visjs.org/docs/timeline/

poroale commented 7 years ago

Ok, I understand. Both your examples work nicely.

Thank you.