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

Custom tooltip in gvisTimeline #34

Closed
number-cruncher opened this issue Apr 29, 2016 · 3 comments
Closed

Custom tooltip in gvisTimeline #34

number-cruncher opened this issue Apr 29, 2016 · 3 comments

Comments

@number-cruncher
Copy link

Can you help troubleshoot....

My goal is to add a custom tooltip to the gvisTimeline function.

I've modified your script to add tooltip as a parameter. However, when I run the modified function, I get the following error message "could not find function "gvisChart". I reloaded googleVis, but I get the same error message.

This is also an unsolved post on StackOverflow, so I'm reaching out to the expert!

Thanks in advance for any guidance.

gvisTimeline <- function(data, rowlabel="", barlabel="", tooltip="", start="",
end="", options=list(), chartid){

    my.type <- "Timeline"
    dataName <- deparse(substitute(data))

    my.options <- list(gvis=modifyList(list(width=600, height=200),options), dataName=dataName,
                       data=list(rowlabel=rowlabel, barlabel=barlabel,** tooltip=tooltip**, start=start, end=end,
                                 allowed=c("number", "string", "date", "datetime"))
    )


    checked.data <- gvisCheckTimelineData(data, rl=rowlabel, bl=barlabel, **tt=tooltip**,
                                          start=start, end=end)

    output <- gvisChart(type=my.type, checked.data=checked.data, options=my.options,
                        chartid=chartid, package="timeline") 

    return(output)

}

gvisCheckTimelineData <- function(data, rl, bl, tt, start, end){

    if(any(c(rl, bl, **tt**, start, end) %in% ""))
            return(data)
    else  
            return(data[, c(rl, bl, **tt,** start, end)])

}

require(timeline)
require(googleVis)
data(ww2)
ww2$Person <- gsub("\n" ," ", ww2$Person)
ww2$tooltip <- rep("Hello World",nrow(ww2))
plot(gvisTimeline(ww2, barlabel="Person", rowlabel="Group", tooltip = "tooltip",
start="StartDate", end="EndDate",
options=list(tooltip="{isHtml:'True'}"), chartid="ww2")
)

@mages
Copy link
Owner

mages commented Apr 30, 2016

Hi Whitney,

The function gvisChart is not exported by googleVis, hence you have to rebuild the package yourself with your new function.

I hope this helps.

Regards

Markus

On 29 Apr 2016, at 21:54, Whitney E Kramer notifications@github.com wrote:

Can you help troubleshoot....

My goal is to add a custom tooltip to the gvisTimeline function.

I've modified your script to add tooltip as a parameter. However, when I run the modified function, I get the following error message "could not find function "gvisChart". I reloaded googleVis, but I get the same error message.

This is also an unsolved post on StackOverflow, so I'm reaching out to the expert!

Thanks in advance for any guidance.

gvisTimeline <- function(data, rowlabel="", barlabel="", tooltip="", start="",
end="", options=list(), chartid){

my.type <- "Timeline"
dataName <- deparse(substitute(data))

my.options <- list(gvis=modifyList(list(width=600, height=200),options), dataName=dataName,
                   data=list(rowlabel=rowlabel, barlabel=barlabel,** tooltip=tooltip**, start=start, end=end,
                             allowed=c("number", "string", "date", "datetime"))
)


checked.data <- gvisCheckTimelineData(data, rl=rowlabel, bl=barlabel, **tt=tooltip**,
                                      start=start, end=end)

output <- gvisChart(type=my.type, checked.data=checked.data, options=my.options,
                    chartid=chartid, package="timeline") 

return(output)

}

gvisCheckTimelineData <- function(data, rl, bl, tt, start, end){

if(any(c(rl, bl, **tt**, start, end) %in% ""))
        return(data)
else  
        return(data[, c(rl, bl, **tt,** start, end)])

}

require(timeline)
require(googleVis)
data(ww2)
ww2$Person <- gsub("\n" ," ", ww2$Person)
ww2$tooltip <- rep("Hello World",nrow(ww2))
plot(gvisTimeline(ww2, barlabel="Person", rowlabel="Group", tooltip = "tooltip",
start="StartDate", end="EndDate",
options=list(tooltip="{isHtml:'True'}"), chartid="ww2")
)


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub

@number-cruncher
Copy link
Author

Got it working. Thanks Markus. Post to follow.

@mages mages closed this as completed Aug 31, 2016
@number-cruncher
Copy link
Author

thx

On Wed, Aug 31, 2016 at 2:24 PM, Markus Gesmann notifications@github.com
wrote:

Closed #34 #34.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#34 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AFBPl3KBtTNCFbSMeea_ands3PR5rDqlks5qlcbSgaJpZM4ITK1M
.

Whitney Kramer
Manager of Analytics and Insights
101 Tremont Street, 6th floor, Boston, MA 02108
m: 507.358.3600 • iorahealth.com

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