0

I'm new to R and would like to create a Gantt-style diagram where I can see how long jobs on a SQL Server run over the week. So my y-axis would be filled with job names and my x-axis has a (in and out zoom-able) scale with Weekdays, hours, minutes and seconds.

My dataset can still be configured. I can transform the start and end times to every format since I have them as DateTimes.

This is how the data looks like:

structure(list(JobName = structure(c(1L, 1L, 1L, 2L, 2L), .Label = c("ATLAS_Admin_DeployClientDatabase", "ATLAS_Admin_ParseMasterCubeDatabase"), class = "factor"), RunDateTime = structure(c(1L,3L, 5L, 2L, 4L), .Label = c("2016-11-10T15:39:36.0000000", "2016-11-16T11:30:20.0000000","2016-11-16T11:37:25.0000000", "2016-11-16T15:51:56.0000000","2016-11-16T15:52:59.0000000"), class = "factor"), StartWeekday = structure(c(1L,2L, 2L, 2L, 2L), .Label = c("Thursday", "Wednesday"), class = "factor"),    StartTime = structure(c(3L, 2L, 5L, 1L, 4L), .Label = c("1899-12-30T11:30:20.0000000",    "1899-12-30T11:37:25.0000000", "1899-12-30T15:39:36.0000000",    "1899-12-30T15:51:56.0000000", "1899-12-30T15:52:59.0000000"    ), class = "factor"), EndRunDateTime = structure(c(1L, 3L,    5L, 2L, 4L), .Label = c("2016-11-10T16:02:39.0000000", "2016-11-16T11:31:24.0000000",    "2016-11-16T12:03:10.0000000", "2016-11-16T15:52:57.0000000",    "2016-11-16T16:19:06.0000000"), class = "factor"), EndWeekday = structure(c(1L,    2L, 2L, 2L, 2L), .Label = c("Thursday", "Wednesday"), class = "factor"),    EndTime = structure(c(4L, 2L, 5L, 1L, 3L), .Label = c("1899-12-30T11:31:24.0000000",    "1899-12-30T12:03:10.0000000", "1899-12-30T15:52:57.0000000",    "1899-12-30T16:02:39.0000000", "1899-12-30T16:19:06.0000000"    ), class = "factor")), .Names = c("JobName", "RunDateTime","StartWeekday", "StartTime", "EndRunDateTime", "EndWeekday","EndTime"), row.names = c(NA, 5L), class = "data.frame")

The names are linked over the JobID.

In the end it should look like this: Gantt-Diagram with weekdays/times instead of dates

enter image description here

I'm not limited to any library, yet ggplot is already installed.

Talvien
  • 47
  • 7
  • Hi Frederik, welcome to SO! Please take a look at this: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example. In short, provide us with example data, don't put a link to an image, embed the image in the question itself. – Amit Kohli Nov 17 '16 at 09:27
  • I wasn't alowed to embed it :/ SO sais I have to link it. – Talvien Nov 17 '16 at 09:38
  • No seriously, it doesnt. A popup appears telling me, I need 10 reputation until I can embed. – Talvien Nov 17 '16 at 09:45
  • Ah... correct... sorry I forgot about that. I'll delete my comments. In the meantime, I don't want to *see* what your data looks like... we need actual data so that we can play with. Did you check the link I sent you? – Amit Kohli Nov 17 '16 at 09:48
  • @FrederikNegromloc ; as Amit comments, it is not very useful to add images of data. Can you edit your question with the output of `dput(yourdataframe name)` please. – user20650 Nov 17 '16 at 11:26
  • perhaps useful, http://stackoverflow.com/questions/3550341/gantt-charts-with-r, http://stackoverflow.com/questions/9862519/gantt-style-time-line-plot-in-base-r, http://stackoverflow.com/questions/10489411/how-to-modify-my-r-code-to-plot-this-kind-of-gantt-chart . – user20650 Nov 17 '16 at 11:29
  • Okay, I try to get a frame of the data. Problem is I use R within Power BI, so my data comes from the Power BI Data model. But I will try. Thanks guys. – Talvien Nov 17 '16 at 12:08
  • Ok, I made it. Only the format of the time looks kinda crazy. Looks like DateTime even though it Time in PowerQuery Language – Talvien Nov 17 '16 at 13:32
  • @FrederikNegromloc ; i added a couple of hints here, http://chat.stackoverflow.com/rooms/128394/frederik-gantt , that may help to get you started. – user20650 Nov 17 '16 at 23:17
  • Thanks user 20650, this was already very helpful! I have a Gantt Chart now which looks similar to what I want. Just have to figure out why it works in my IDE but doesn't in Power BI. Maybe you wanna post your answer here? – Talvien Nov 18 '16 at 10:19
  • It seems that Power BI can't handle the timevis library. I'm doing it with ggplot now, just don't get the bars to be visible... – Talvien Nov 18 '16 at 14:01
  • @Talvien ; that;s a shame about timevis. To get help with the ggplot figure, can you edit your question with the code that you have attempted, and indicate what the problem is please. – user20650 Nov 18 '16 at 16:41
  • @user20650 I already opened another thread. There someone solved my problem. No another occurred. I get bars that last from the very first starttime to the very last endtime. http://stackoverflow.com/questions/40680130/no-bars-shown-in-r-ggplot-gantt-chart/40680508#40680508 – Talvien Nov 21 '16 at 09:02

0 Answers0