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
Update reactive graph sample data to include time #1132
Conversation
I'm going to merge this unless anyone has objections |
Go for it. |
@bborgesr I think the time elapsed needs to be in separate DOM nodes from the existing label for a couple of reasons. 1) It'd be great if the elapsed time could be shown in a different typeface (proportional instead of fixed-width), smaller size, maybe bold, maybe lighter color. 2) The length of the label can be arbitrarily long and fades out as it gets longer. See this (contrived) example: library(shiny)
ui <- fluidPage(
plotOutput("plot")
)
server <- function(input, output, session) {
reactive({
df <- cars
df <- head(df)
df
}) -> r
output$plot <- renderPlot({
plot(r())
})
}
shinyApp(ui, server) It's pretty unlikely you'd use |
@jcheng5 Implemented those changes and also:
|
|
Can we go quite a bit darker with the color? I find it a bit hard to read right now. How does |
}); | ||
}, | ||
exit: function(data) { | ||
var node = nodes[data.id]; | ||
node.running = false; | ||
var timeElapsed = (parseFloat(data.time) - parseFloat(node.start)) * 1000 | ||
var timeLabel = 'time elapsed: ' + (Math.round(timeElapsed * 1000) / 1000) + ' ms'; | ||
node.timeLabel = time ? timeLabel : ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually you want to keep the data in its "native" form until you're ready to display it (i.e. store the timeElapsed
float on the node, not the fully formatted string). If we decide we want to show the number in a different color or weight than the "time elapsed" label, then we can do that easily.
Other than the notes I've made, this looks great! It really makes me itch to want to pull forward all the improvements to the reactlog though :) Or at least to make this data easily exportable as a nice data frame, there's all sorts of interesting visualizations you could imagine on this data... |
…tted string; made sure we're not showing any time elapsed info while the node is active (it could be confusing)
Yeah, I agree that making this data exportable (and maybe adding a few guidelines and examples of how it might be useful or how best to visualize it) would be great... (This might be especially useful for the larger apps that begin to test the limitation of our current visualization). A few notes:
|
I think the travis failures are due to the new version of htmltools I just pushed to CRAN, which includes a new argument in the htmlTemplate function. I'll fix this in a separate PR. |
Oh, good. I was scratching my head trying to figure out what I broke... :) |
After some experimentation, I found that I like this color scale for the time labels. It's a 6-step monochromatic red scale ranging from a very pale red/beige to a dark wine red. I got it from colorbrewer, which is supported by d3 (lib/colorbrewer). Unfortunately, this script has to be loaded in addition to the regular d3 script. For now, I'm loading it directly from github (because I wanted to experiment with lots of scales and because I thought it might be nice for app authors to eventually have access to that and be able to pass it in as a parameter). However, we could also just decide to only include the particular color array we settle on. So let me know what you think about this particular color array... I feel like it's not too distracting (because it's monochromatic), but still achieves the goal of drawing the user's attention to the bottlenecks of the code... To map the domain of time differences into the colors, I find the minimum and maximum time differences in the log data -- so that the time elapsed info is always normalized for that particular run of an app. On a completely unrelated note, @jcheng5 -- I noticed that, in the beginning of the |
It's fine to remove that console.log but there's not really security implications; if the data has made it to client-side JavaScript, it's already compromised, it doesn't matter if you print it to the console or not. I wouldn't bother making the color scheme configurable at this time--let's just grab the colors we need and credit colorbrewer. I'm not sure whether it makes sense to normalize the colors against the app's run times. If a reactive takes only 20ms but it happens to be the slowest reactive in an app, should it be dark red? |
Yes, the slowest reactive in any app will always be dark red and the fastest will always be light red. I take your point that this might be strange at first, but I don't much like the alternative: if all your reactives are under 20ms (but there's a spread -- 1ms, 10ms, 20ms) if you don't normalize it, then the colors will be all the same(ish) and that defeats the purpose of color-coding the time labels. On the other hand, as long as we explain that the colors are always normalized, I think we could make people look at this as a metric for their app only and identify what is taking longer in their app (even if it's super fast compared to other apps). Also, it would be hard to define a fits-all domain because different apps can have really different run times... |
OK. Let's start with that and see how it feels. |
cc @bborgesr