How can you set the hoverinfo of ggplotly() in a activity frequency plot of bupaR to Activity: and Absolute Activity Frequency: ?
## app.R ##
library(shiny)
library(shinydashboard)
library(bupaR)
library(processmapR)
library(eventdataR)
library(plotly)
ui <- dashboardPage(
dashboardHeader(title = "decio"),
dashboardSidebar(
collapsed = TRUE
),
dashboardBody(
plotlyOutput("activity_frequency"),
)
)
server <- function(input, output,session) {
sip<-bupaR::simple_eventlog(eventlog = eventdataR::sepsis,
case_id = "case_id",
activity_id = "activity",
#activity_instance_id = "activity_instance_id",
timestamp = "timestamp",
#lifecycle_id = "lifecycle",
resource_id = "resource"
)
output$activity_frequency <- renderPlotly({
ggplotly(sip %>% activity_frequency("activity") %>% plot())
})
}
shinyApp(ui, server)
I don't know what you want in your tooltips, so I'm just going to show you a way you could change them.
When I realized you were using a function called
activity_frequencyand you named the Plotly output the same thing, I made a change. I changed the call inuiandserverfromactivity_frequencytoact_freq.I created a function that modifies the tooltips. Inside
server, after callingggplotly, you'll run the plot through that function.This function will make your tooltips look like this.
It's not particularly informative (since that information is already there). However, it's still a big change from the default, which looks like this.
I put this function before the call to create
ui.Then I modified the call to create
output$act_freq <- renderPlotly({so that the function was called. You've already used the({instead of(, so you can list multiple steps in the call.Here is the entire
server.Just so we're totally clear, here is all the code together.