Bokeh Figure with AjaxDataSource and Categorical Axis Labels

Cross post from http://stackoverflow.com/questions/42602926/bokeh-figure-with-ajaxdatasource-and-categorical-axis-labels

I’m trying to port some plots to use AjaxDataSource instead of DataFrames or ColumnDataSource and want to get access to one of the columns to set the axis range however this seems to not work as it sets the range to be the initial empty list and does not update it once the data loads from the Ajax call.

I’d like to be able to do something like this:

source = AjaxDataSource(
        data_url='http://localhost:8080/data/email/policy',
        polling_interval=60000,
        method='GET',
        mode='replace')
    source.data = dict(Policy=[], Count=[])
    colors = Set1[3]
    p = figure(
        responsive=True,
        plot_height=150,
        toolbar_location='right',
        tools=TOOLS,
        y_range=source.data['Policy'])

    p.hbar(
        y='Policy',
        right='Count',
        left=0,
        height=0.3,
        color=colors[1],
        source=source)
    p.ygrid.grid_line_color = None
    return p