-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Description
One of the best features in shiny is the ability to make reactive expression tying together a number of different tasks so that multiple outputs could depend on the same intermediate step. This is particularly useful for example below when having a table and a plot depend on the same input which is being filtered/transformed using some of the reactive components. It also allows many of the longer expressions to be rewritten more modularly with fewer inputs
clean_data <- reactive({
raw_df %>% subset(age>input$min_age) %>% subset(count<input$max_count)
})
output$result_table<-renderDataTable({clean_data()})
output$result_plot<-renderPlot({ggplot(clean_data(), aes(x = age, y = count))+geom_jitter()})
Clearly in dash this is a bit trickier, but presumably something like a new type of Dependency
@app.callback(
dash.dependencies.ReactiveExpression('clean_data'),
[dash.dependencies.Input('crossfilter-xaxis-column', 'value')])
def clean_data(xaxis_val):
return raw_df.query('xaxis=={}'.format(xaxis_val))
@app.callback(
dash.dependencies.Output('crossfilter-indicator-scatter', 'figure'),
[dash.dependencies.ReactiveExpression('clean_data')])
def show_plot(in_data):
return dict(data = [], layout = go.Layout()
Metadata
Metadata
Assignees
Labels
No labels