Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Group colors in gvisTimeline #51

Open
daheelee opened this issue Nov 9, 2016 · 2 comments
Open

Group colors in gvisTimeline #51

daheelee opened this issue Nov 9, 2016 · 2 comments

Comments

@daheelee
Copy link

daheelee commented Nov 9, 2016

Hello,

I am using gvisTimeline in Shiny, and I need to color code the timeline bars according to groups. This is different from the colorByRowLabel option because I am trying to use the same colors for groups of rows, not by each row label.
I know we can just use the options for colors, but I am not able to utilize this because the data set I am using to generate the plot is a reactive object. Is there any way we could add a functionality where you can just use a 'colors' column so that each timeline bar uses the corresponding color for the row, or use 'group' colors in the option?

For example, if I wanted to color code by 'Level', in the dataset below,
it would be great if I could do something like:

gvisTimeline(data=dat, rowlabel="Class", barlabel="Day", start="Start", end="End", colors = "Level" ) or
gvisTimeline(data=dat, rowlabel="Class", barlabel="Day", start="Start", end="End", colors = "Color" )

screen shot 2016-11-09 at 6 44 14 pm

Thanks for your help!

DL

@mages
Copy link
Owner

mages commented Nov 10, 2016

I don’t understand, why you can’t use the options argument in the reactive environment.

On 9 Nov 2016, at 23:57, daheelee [email protected] wrote:

Hello,

I am using gvisTimeline in Shiny, and I need to color code the timeline bars according to groups. This is different from the colorByRowLabel option because I am trying to use the same colors for groups of rows, not by each row label.
I know we can just use the options for colors, but I am not able to utilize this because the data set I am using to generate the plot is a reactive object. Is there any way we could add a functionality where you can just use a 'colors' column so that each timeline bar uses the corresponding color for the row, or use 'group' colors in the option?

For example, if I wanted to color code by 'Level', in the dataset below,
it would be great if I could do something like:

gvisTimeline(data=dat, rowlabel="Class", barlabel="Day", start="Start", end="End", colors = "Level" ) or
gvisTimeline(data=dat, rowlabel="Class", barlabel="Day", start="Start", end="End", colors = "Color" )

https://cloud.githubusercontent.com/assets/20231857/20159094/8a07da94-a6ac-11e6-95b9-cae44943c54f.png
Thanks for your help!

DL


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub #51, or mute the thread https://github.com/notifications/unsubscribe-auth/ABF-1U6EmGnZbALJ6G3SZXbOWSOzkn4Gks5q8l4EgaJpZM4KuH7V.

@daheelee
Copy link
Author

My issue is that the list of colors has to remain reactive but options does not take a reactive object.

So the app I am creating uses a data set is created by reading in a google spreadsheet which is updated by users. Now I have the data set in the Shiny app reactive because I need the app to reflect any changes that are made in the spreadsheet, without having to restart the app. This means the list of colors that is used in the gvisTimeline function needs to remain reactive. But it seems like I can't do this.

As an example, let's say the reactive data set I had in the previous post, and I can make a list of colors according to this. colors_timeline gives a string list of colors from a function (colors) according to 'Level' variable (Advanced is red, Intermediate is yellow, Elementary is blue). So with the example dataset, this would give "['red', 'red', 'yellow', 'yellow', 'blue', 'blue']". But note, this list is reactive.

colors_timeline = reactive({
colors(dat())
})

And I can't use the colors_timeline directly in gvisTimeline function as below because options does not take a reactive object.

output$timeline <- renderGvis({
gvisTimeline(data = dat(), rowlabel = "Day", barlabel = "Class", start = "Start", end = "End",
options = list(colors = colors_timeline()) <-this is wrong
})

So I was asking if it's possible to add a 'colors' argument in the gvisTimeline function so that color coding with reactive data set is possible.

DL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants