0
votes

We are trying to build a web app--Dashboard-- to show different interactive(including click callback, fetch new data etc) charts with Bokeh + Holoviews + Datashader on DJango.

Since data is very large and could have 10+ million points we are using datashader. We can have a static html from backend from Bokeh + Holoviews + Datashader from Backend and pass it to front end using Django REST api as :

views.py

import numpy as np
import holoviews as hv
import datashader as ds
from dask import dataframe as dd
from bokeh.io import show, curdoc
from bokeh.layouts import layout
from bokeh.models import Slider, Button
from holoviews.operation.datashader import datashade

renderer = hv.renderer('bokeh').instance(mode='server')

def home(request):
    def plot_info(y_col):
        from vaex import dataframe as datafm
        df_dask = dd.read_parquet(r"C:\Dropbox\1mln.parquet", engine='pyarrow',
                                  columns=['nest11', 'nest21', 'first_element', 'second_element', 'timestamp'])
        df_dask['timestamp'] = dd.to_datetime(df_dask.timestamp, unit='ns')
        return hv.Curve((df_dask['timestamp'], df_dask[y_col]))


    def bearer():
        stream = hv.streams.Stream.define('y-axis', y_col="nest11")()
        dmap = hv.DynamicMap(plot_info, streams=[stream])
        vmap = datashade(dmap).opts(width=1200, height=600, responsive=True)
        html = renderer.static_html(vmap)

        return html
context = {
        'seq_num': bearer(),

  }

return render(request, 'home/welcome.html', context)

Works fine. However Since we used Datashader, data is aggregated and converted in static html when we zoom in we would not get the data which we are looking for at from end side. For that, my guess is we need Bokeh server.

My doubts are :(since use of Datashader is must for large dataset)

  1. How can i use Bokeh server along with Django REST apis ? Also i want to have a customized html page at front end so i am using Django template.
  2. Is there an alternative to Django for REST apis development with Bokeh + Datashader ?
  3. Does Bokeh support REST APIs ? how ? pls share some examples of REST APIs and callbacks ? for example I've a Dashboard and when i click one chart, I should get more details about the chart and play around those charts in dashboard ? dropdown etc
1

1 Answers

1
votes
  1. I would strongly suggest using Panel which is built on top of Bokeh and supports HoloViews. For Django integration have a look at these docs.

  2. / 3. The Bokeh server is built on Tornado, which means it can be easily extended, e.g. in the next release of Panel (0.10) you will be able to easily register custom REST APIs to be served alongside your app. There aren't any examples yet since it's not released but I'll be working on a few examples in time for the next release which is due in about two weeks.