question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Longer chapter(s) on interactive graphs

See original GitHub issue

We’ve already mentioned a few times that the part on plotly graphs in Dash applications should be expanded. I’m trying here to summarize what could go into a new version:

  • the different ways to set dcc.Graph.figure: dict or plotly figure, which can be created with plotly.graph_objects or plotly.express (possibly using fig.update_traces and fig.update_layout). provide a link to plot.ly/python/creating-and-updating-figures/ -[ ] existing example capturing user interaction (clickData etc.)

  • existing example Update Graphs on Hover

  • example of editable (`config={'editable":True}) figure triggering a callback when edited

  • explain the shape of selectedData and how to access the components of it

  • explain how we recommend selectedData with clicking instead of clickData

  • explain how the user interface for selectedData works: clicking, shift clicking, double clicking to unselect, and more.

  • explain what selected data looks like for other chart types including sunbursts

  • datashader examples

  • rasterly examples

  • mention clientside callbacks for graphs (see #754 )

  • subplots vs multiple dcc.Graph components

  • real world examples of restyleData (responding to legend events, like keeping two graphs in sync)

  • real world examples of hoverData, including:

    • using hover data to update the graph itself. For example:

    You can thicken a trace when hovering over it in Dash without needing to use javascript by creating a callback with the input hoverData. The hoverData includes the index of the trace that’s being hovered on so you would be able to use that info to generate a thicker version of the trace in that callback (I would simply append this thicker trace to the list of existing traces because that is easier than deleting the thin trace first).

    Then if you set clear_on_unhover=True in the dcc.Graph, hoverData will change to None when a trace is unhovered so your callback would look something like this:

    @app.callback(Output('graph', 'figure'), [Input('graph', 'hoverData')], [State('graph', 'figure')])
    update_graph_on_hover(hoverData, fig):
      if not hoverData is None:
        trace = create_thicker_version_of_hovered_over_trace(hoverData)
        fig['data'].append(trace)
        return fig
    
      # delete that last trace if hoverdata is cleared
      else:
        fig['data'].pop()
    

    If you go the above route, you may need to add a dummy trace that’ll get popped before any hover action takes place.

    • using hover data to update something different
  • Examples of the config. For example, how to change the size and resolution of the PNG graph when downloading it

Does that make sense? Anything else missing? It’s a lot of work but I think it makes sense to consider this as a whole. A lot of questions on the forum would probably disappear with the above additions.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
chriddypcommented, May 8, 2020

for the R version, instead of datashader we’ll document rasterly

0reactions
emmanuellecommented, May 19, 2020

extendData often triggers questions in the forum since there is no doc example and some links (including the release notes of dash 0.41) point to https://github.com/plotly/dash-core-components/pull/461, where the example code block is not valid any more (different syntax). See for example https://community.plotly.com/t/what-is-a-correct-usage-of-extenddata-property-to-achieve-adding-data-to-existing-graph-instead-of-constantly-updating-it/39569/4

Read more comments on GitHub >

github_iconTop Results From Across the Web

Chapter 6. Creating interactive visualizations
The benefits of dynamic versus static diagrams; Navigating the chart; Charting user actions; Using animation sparingly; Designing for mobile platforms;
Read more >
Chapter 12 Interactive Graphs - Data Visualization with R
Chapter 12 Interactive Graphs. This book has focused on static graphs - images that can be placed in papers, posters, slides, and journal...
Read more >
TWS Chart Layout and Configuration - YouTube
Learn how to open or load a TWS chart and access configuration menus. This lesson will teach you simple TWS chart shortcuts, allowing...
Read more >
Part 4. Interactive Graphing and Crossfiltering - Dash Plotly
This is the 4th chapter of the Dash Tutorial. The previous chapter covered basic callback usage. The next chapter describes how to share...
Read more >
Time Series | the R Graph Gallery
The time series section of the gallery displays many examples of time sery ... Note that this online course is dedicated to timeseries...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found