Open timelyportfolio opened 8 years ago
@pssguy, I committed some experimental code to make this work. Try with your data. As another example,
library(timelineR)
# old "nonworking"
d3kit_timeline(
data.frame(time = 1:3),
textFn = ~time,
margin = list(left=100,right=20,bottom=20,top=20)
)
# new working
d3kit_timeline(
data.frame(time = 1:3),
textFn = ~time,
margin = list(left=100,right=20,bottom=20,top=20),
scale = htmlwidgets::JS("d3.scale.linear()")
)
# new working improved with custom domain
d3kit_timeline(
data.frame(time = 1:3),
textFn = ~time,
margin = list(left=100,right=20,bottom=20,top=20),
scale = htmlwidgets::JS("d3.scale.linear()"),
domain = c(0,5)
)
# some additional customization
add_axis(
d3kit_timeline(
data.frame(time = 1:3),
textFn = ~time,
margin = list(left=100,right=20,bottom=20,top=20),
scale = htmlwidgets::JS("d3.scale.linear()"),
domain = c(0,5),
height =100
),
ticks=3
)
Thanks . Looks good and I can translate to my data smoothly
However, I'm having problems utilizing in shiny. The browser is launched but nothing appears There do seem to be some some errors according top console
e.g Error: Invalid value for
Can you replicate Any idea what I am doing incorrectly?
library(shiny)
library(timelineR)
app <- shinyApp(
ui = fluidPage(
timelineOutput("timeline")
),
server = function(input, output) {
output$timeline <- renderTimeline({
df <- data.frame(time = 1:3)
d3kit_timeline(
df,
textFn = ~time,
margin = list(left=100,right=20,bottom=20,top=20),
scale = htmlwidgets::JS("d3.scale.linear()"),
domain = c(0,5)
)
})
}
)
runApp(app)
@pssguy just getting back on the computer. I stripped out the Shiny piece as I was experimenting, and I forgot to put it back. I'll add it tonight or tomorrow morning. Sorry. Also, the source d3kit-timeline officially got this new functionality, so I'll merge it in also.
I added back the Shiny, and upgraded to 0.2.0 of d3kit-timeline
. Thanks again. Also thought you would like the example added at http://kristw.github.io/d3kit-timeline/.
library(shiny)
library(timelineR)
app <- shinyApp(
ui = fluidPage(
d3kit_timelineOutput("timeline")
),
server = function(input, output) {
output$timeline <- renderd3kit_timeline({
df <- data.frame(time = 1:3)
d3kit_timeline(
df,
textFn = ~time,
margin = list(left=100,right=20,bottom=20,top=20),
scale = htmlwidgets::JS("d3.scale.linear()"),
domain = c(0,5)
)
})
}
)
runApp(app)
Thanks. Works fine. I'll have a working interactive up this evening
@pssguy brings up a great use case to visualize soccer goals, but currently
d3kit_timeline
does not allow non-date data.