0

I've got a Bokeh app that charts multiple lines depending on the values for certain widgets that a user selects. I would like to give the user the opportunity to download the raw data behind the chart.

Is it possible to download the data for certain lines shown in a Bokeh chart as a csv/Excel file?

Edit:

As suggested, I have included the CustomJS callback from this Git repo in my script: https://github.com/bokeh/bokeh/tree/master/examples/app/export_csv

Since my Bokeh source contains data for a Multiline chart and not a DataTable the output is not as expected. Unfortunately, I don't have any experience with Javascript. How can I modify the script such that the returned csv file accurately shows the data stored in my source multilines xs and ys?

antifragile
  • 83
  • 1
  • 8
  • The answers on this question might be able to help solve your problem: https://stackoverflow.com/questions/49388511/send-file-from-server-to-client-on-bokeh – Jasper Jan 28 '20 at 15:35

1 Answers1

1

There is an example in the repo that has a simple CustomJS callback that will allow the user to download the CDS contents as a CSV:

https://github.com/bokeh/bokeh/tree/master/examples/app/export_csv

bigreddot
  • 33,642
  • 5
  • 69
  • 122
  • Thank you for the guidance - I was able to include the CustomJS callback from the linked repo in my script. However, the csv output is not as expected. I assume because my Bokeh source contains data for a Multiline chart and not a DataTable. – antifragile Jan 29 '20 at 18:19
  • Right, the columns for `MultiLine` glyphs are "lists of lists". You will need to extract just the sub-parts you want to export. – bigreddot Jan 29 '20 at 19:49
  • The link is broken, this works: https://github.com/bokeh/bokeh/tree/branch-3.3/examples/server/app/export_csv – rcriii Jul 04 '23 at 13:05