mages / googleVis

Interface between R and the Google Chart Tools
https://mages.github.io/googleVis/
360 stars 155 forks source link

Fill pattern of bars in gvisTimeline #88

Closed mubashirqasim closed 4 years ago

mubashirqasim commented 4 years ago

hi there,

First of all, Thank you very much for the development of this library. I have been using it for a long time in many of my shiny apps.

This is to ask if it is possible to add some abilities to add more variables in gvisTimeline chart. One way to doing this could be fill patterns in the bars of gvisTimeline chart.

In the following example, for instance, I would like to use different fill patterns for the Course_Type variable.

library(googleVis)

df <- data.frame(Student = structure(c(rep("Allan",5), rep("Joan",5), rep("Kat", 5)), class = "character"),
                 Course = c(LETTERS[1:5], LETTERS[1:5], LETTERS[1:5]), 
                 Start = structure(c(16713,16768,16725,16758,16780,
                                     16714,16754,16765,16729,16785,
                                     16724,16730,16755,16760,16759), class = "Date"), 
                 End = structure(c(16733,16775,16755,16779,16790,
                                   16744,16762,16780,16760,16795,
                                   16744,16750,16758,16784,16798), class = "Date"))

df$Course_Type <- ifelse(df$Course %in% c("A","C","E"), "Compulsory", "Elective")

plot(gvisTimeline(data=df,
                  rowlabel = "Student",
                  barlabel = "Course",
                  start = "Start", end = "End",
                  options=list(width=600, height=1000) ))

Many thanks for your time.

Kind regards,

Mubashir

mages commented 4 years ago

I don't think this is possible, according to the Google documentation: https://developers.google.com/chart/interactive/docs/gallery/timeline