Пример #1
0
    def __init__(self,
                 field_name='Value',
                 highlight_fill_color='#79DCDE',
                 highlight_line_color='#79DCDE',
                 size=8,
                 is_categorical=False,
                 extent=None,
                 agg=None,
                 how='mean'):

        if how not in ('mean', 'sum', 'max', 'min', 'median', 'std', 'var',
                       'count'):
            raise ValueError("invalid 'how' downsample method")

        self.hover_data = ColumnDataSource(data=dict(x=[], y=[], value=[]))

        self.invisible_square = Square(x='x',
                                       y='y',
                                       fill_color=None,
                                       line_color=None,
                                       size=size)

        self.visible_square = Square(x='x',
                                     y='y',
                                     fill_color=highlight_fill_color,
                                     fill_alpha=.5,
                                     line_color=highlight_line_color,
                                     line_alpha=1,
                                     size=size)
        self.tooltips = []

        code = "source.selected = cb_data['index'];"
        self._callback = CustomJS(args={'source': self.hover_data}, code=code)

        self.renderer = GlyphRenderer()
        self.renderer.data_source = self.hover_data
        self.renderer.glyph = self.invisible_square
        self.renderer.selection_glyph = self.visible_square
        self.renderer.nonselection_glyph = self.invisible_square

        self.tool = HoverTool(callback=self._callback,
                              renderers=[self.renderer],
                              mode='mouse')

        self.extent = extent
        self.is_categorical = is_categorical
        self.field_name = field_name

        self._agg = agg
        self._size = size or 8

        self.how = how

        if self.agg is not None and self.extent is not None:
            self.compute()
Пример #2
0
    def __init__(self,
                 field_name='Value',
                 highlight_fill_color='#79DCDE',
                 highlight_line_color='#79DCDE',
                 size=8,
                 is_categorical=False,
                 extent=None,
                 agg=None):

        self.hover_data = ColumnDataSource(data=dict(x=[], y=[], value=[]))

        self.invisible_square = Square(x='x',
                                       y='y',
                                       fill_color=None,
                                       line_color=None,
                                       size=size)

        self.visible_square = Square(x='x',
                                     y='y',
                                     fill_color=highlight_fill_color,
                                     fill_alpha=.5,
                                     line_color=highlight_line_color,
                                     line_alpha=1,
                                     size=size)
        self.tooltips = []

        code = "source.set('selected', cb_data['index']);"
        self._callback = CustomJS(args={'source': self.hover_data}, code=code)

        self.renderer = GlyphRenderer()
        self.renderer.data_source = self.hover_data
        self.renderer.glyph = self.invisible_square
        self.renderer.selection_glyph = self.visible_square
        self.renderer.nonselection_glyph = self.invisible_square

        self.tool = HoverTool(callback=self._callback,
                              renderers=[self.renderer],
                              mode='mouse')

        self.extent = extent
        self.is_categorical = is_categorical
        self.field_name = field_name

        self._agg = agg
        self._size = size or 8

        if self.agg is not None and self.extent is not None:
            self.compute()
Пример #3
0
def plot_map(df, bs_latlong=None, bs=None, map_type="satellite", colorby='rssi'):
    map_options = GMapOptions(lat=.5*(df.latitude.min()+ df.latitude.max()),
                              lng=.5*(df.longitude.min()+df.longitude.max()),
                              map_type=map_type, zoom=11)

    
    plot = GMapPlot(
        x_range=DataRange1d(), y_range=DataRange1d(), map_options=map_options
    )
    plot.title.text = "Test_API_Google"

    # For GMaps to function, Google requires you obtain and enable an API key:
    #
    #     https://developers.google.com/maps/documentation/javascript/get-api-key
    #
    # Replace the value below with your personal API key:

    plot.api_key = "AIzaSyBn534zSTjx4L7l7yoklDismI0QXMiZSA8"
    
    normalize = (df[colorby] - df[colorby].min())/(df[colorby].max() - df[colorby].min())

    source = ColumnDataSource(
        data=dict(
            lat=df.latitude,
            lon=df.longitude,
            color=[cm.colors.to_hex(c) for c in cm.jet(normalize)[:,:-1]]
        )
    )


    circle = Circle(x="lon", y="lat", size=3, fill_color="color",
                       fill_alpha=0.8, line_color=None)


    plot.add_glyph(source, circle)

    if (bs is not None) & (bs_latlong is not None):
        bs = ColumnDataSource(
        data=dict(
            lat=np.array(bs_latlong[bs]['lat']).reshape(1,),
            lon=np.array(bs_latlong[bs]['long']).reshape(1,)
        )
    )


        circlebs = Square(x="lon", y="lat", size=9, fill_color="red",
                       fill_alpha=0.8, line_color=None)


        plot.add_glyph(bs, circlebs)

    plot.add_tools(PanTool(), WheelZoomTool(), BoxSelectTool())
    output_file("gmap_plot.html")
    show(plot)
Пример #4
0
def search(request):

    location = request.POST['search']

    api_key = 'AIzaSyB4WAP0dZG2f6avZ6EYiMBolrtVrxgqtlU'

    gm = googlemaps.Client(key=api_key)

    address = location

    lat = gm.geocode(address)[0]['geometry']['location']['lat']

    lng = gm.geocode(address)[0]['geometry']['location']['lng']

    map_options = GMapOptions(lat=lat, lng=lng, map_type='roadmap', zoom=8)

    plot = GMapPlot(x_range=Range1d(),
                    y_range=Range1d(),
                    map_options=map_options,
                    api_key=api_key)

    plot.add_tools(PanTool(), WheelZoomTool(), BoxSelectTool(),
                   PolySelectTool())

    scale = 2.5

    source = ColumnDataSource(
        data=dict(lat=[lat], lon=[lng], rad=[2], size=[100]))

    circle = Circle(x=lng, y=lat, size="rad", fill_color='red', fill_alpha=0.5)

    global latitude, longitude

    latitude = lat

    longitude = lng

    square = Square(x=lng,
                    y=lat,
                    size="size",
                    fill_color="red",
                    fill_alpha=0.5)

    plot.add_glyph(source, square)

    output_file(
        'C:/Users/pkt01/django_projects/geokno/geoproj/templates/geoproj/plot.html'
    )
    save(plot)

    return render(request, 'geoproj/Query.html')
Пример #5
0
def PlotMap(data_, bs=None, map_type="roadmap"):
    data = data_.sample(5000)
    lat_min, lat_max = data.latitude.min(), data.latitude.max()
    lon_min, lon_max = data.longitude.min(), data.longitude.max()
    map_options = GMapOptions(lat=.5 * (lat_min + lat_max),
                              lng=.5 * (lon_min + lon_max),
                              map_type=map_type,
                              zoom=9)
    plot = GMapPlot(x_range=Range1d(),
                    y_range=Range1d(),
                    map_options=map_options)
    plot.title.text = "Visualisation des données"

    # For GMaps to function, Google requires you obtain and enable an API key:
    #
    #     https://developers.google.com/maps/documentation/javascript/get-api-key
    #
    # Replace the value below with your personal API key:
    # plot.api_key = "AIzaSyDthyCGiKTxBwB7JUA0FP0g3cjGhWWPuC4"
    plot.api_key = "AIzaSyD-n_DViUNpTmYRgb2JCsC_gIHXpUMyMhQ"

    source = ColumnDataSource(data=dict(
        lat=data.latitude,
        lon=data.longitude,
    ))
    if bs is not None:
        bs = ColumnDataSource(data=dict(
            lat=bs.lat,
            lon=bs.lng,
        ))
        patch = Square(x="lon",
                       y="lat",
                       size=7,
                       fill_color="yellow",
                       fill_alpha=1,
                       line_color=None)
        plot.add_glyph(bs, patch)

    circle = Circle(x="lon",
                    y="lat",
                    size=2,
                    fill_color="red",
                    fill_alpha=.3,
                    line_color=None)
    plot.add_glyph(source, circle)
    #@TODO change output file to notebook (no writing to html)
    plot.add_tools(PanTool(), WheelZoomTool(), BoxSelectTool())
    output_file("gmap_.html")
    show(plot)
Пример #6
0
                                  BoxSelectTool())
# legend
catchmentmap_intro_page.legend.location = "top_right"
catchmentmap_intro_page.legend.orientation = "vertical"
"""runoff station"""
runoff_station_source = ColumnDataSource(
    data=dict(x=runoff_station.x,
              y=runoff_station.y,
              name=runoff_station.ESTACION,
              Department=runoff_station.DEPARTAMEN,
              Elevation=runoff_station.DEM_projec))

runoff_station_square_glypg = Square(
    x="x",
    y="y",
    name="name",
    fill_color="#FF34B3",  #,line_color="#3288bd"
    line_width=3,
    size=20)
catchmentmap_intro_page_glyph = catchmentmap_intro_page.add_glyph(
    runoff_station_source, runoff_station_square_glypg)

#show(catchmentmap_intro_page)

wb_home = widgetbox(home_div)

layout_home = layout([
    [wb_home],
    [intro_div],
    [catchmentmap_intro_page],
    [case_study_details],
Пример #7
0
           fill_color="#B3DE69")),
]

markers = [
    ("circle", Circle(x="x", y="y", radius=0.1, fill_color="#3288BD")),
    ("circle_x",
     CircleX(x="x", y="y", size="sizes", line_color="#DD1C77",
             fill_color=None)),
    ("circle_cross",
     CircleCross(x="x",
                 y="y",
                 size="sizes",
                 line_color="#FB8072",
                 fill_color=None,
                 line_width=2)),
    ("square", Square(x="x", y="y", size="sizes", fill_color="#74ADD1")),
    ("square_x",
     SquareX(x="x",
             y="y",
             size="sizes",
             line_color="#FDAE6B",
             fill_color=None,
             line_width=2)),
    ("square_cross",
     SquareCross(x="x",
                 y="y",
                 size="sizes",
                 line_color="#7FC97F",
                 fill_color=None,
                 line_width=2)),
    ("diamond",
Пример #8
0
def graphPlot(DG,
              DGspecies,
              DGreactions,
              plot,
              layout="force",
              positions=None,
              posscale=1.0,
              layoutfunc=None,
              iterations=2000,
              rseed=30):
    """given a directed graph, plot it!
    Inputs:
    DG: a directed graph of type DiGraph
    DGspecies: a directed graph which only contains the species nodes
    DGreactions: a directed graph which only contains the reaction nodes
    plot: a bokeh plot object
    layout: graph layout function. 
                'force' uses fa2 to push nodes apart
                'circle' plots the nodes and reactions in two overlapping circles, with the reactions on the inside of the circle
                'custom' allows user input "layoutfunc". Internally, layoutfunc is passed the three inputs (DG, DGspecies, DGreactions)
                                                        and should output a position dictionary with node {<node number>:(x,y)}

    positions: a dictionary of node names and x,y positions. this gets passed into the layout function
    posscale: multiply the scaling of the plot. This only affects the arrows because the arrows are a hack :("""
    random.seed(rseed)
    if (not PLOT_NETWORK):
        warn("network plotting disabled because some libraries are not found")
        return
    if (layout == "force"):
        #below are parameters for the force directed graph visualization
        forceatlas2 = ForceAtlas2(
            # Behavior alternatives
            outboundAttractionDistribution=True,  # Dissuade hubs
            linLogMode=False,  # NOT IMPLEMENTED
            adjustSizes=False,  # Prevent overlap (NOT IMPLEMENTED)
            edgeWeightInfluence=1.0,

            # Performance
            jitterTolerance=1.0,  # Tolerance
            barnesHutOptimize=True,
            barnesHutTheta=1.2,
            multiThreaded=False,  # NOT IMPLEMENTED

            # Tuning
            scalingRatio=2.4 * posscale,
            strongGravityMode=False,
            gravity=1.0,

            # Log
            verbose=False)

        positions = forceatlas2.forceatlas2_networkx_layout(
            DG, pos=positions, iterations=iterations)
    elif (layout == "circle"):
        positions = nx.circular_layout(DGspecies, scale=50 * posscale)
        positions.update(nx.circular_layout(DGreactions, scale=35 * posscale))
    elif (layout == "custom"):
        positions = layoutfunc(DG, DGspecies, DGreactions)
    reaction_renderer = from_networkx(DGreactions, positions, center=(0, 0))
    species_renderer = from_networkx(DGspecies, positions, center=(0, 0))
    edges_renderer = from_networkx(DG, positions, center=(0, 0))

    #edges
    edges_renderer.node_renderer.glyph = Circle(size=12,
                                                line_alpha=0,
                                                fill_alpha=0,
                                                fill_color="color")
    edges_renderer.edge_renderer.glyph = MultiLine(line_alpha=0.2,
                                                   line_width=4,
                                                   line_join="round")
    edges_renderer.edge_renderer.selection_glyph = MultiLine(
        line_color=Spectral4[2], line_width=5, line_join="round")
    edges_renderer.edge_renderer.hover_glyph = MultiLine(
        line_color=Spectral4[1], line_width=5, line_join="round")
    xbounds, ybounds = makeArrows2(edges_renderer, DG, positions,
                                   headsize=5)  #make the arrows!

    #we want to find the middle of the graph and plot a square that is 1:1 aspect ratio

    #find the midpoint of the graph
    xmid = statistics.mean(xbounds)
    ymid = statistics.mean(ybounds)
    #now, subtract the middle from the edges
    xmiddlized = [a - xmid for a in xbounds]
    ymiddlized = [a - ymid for a in ybounds]
    #now, find the biggest dimension
    absdim = max([abs(a) for a in xmiddlized + ymiddlized])
    xlim = [xmid - absdim * 1.05, xmid + absdim * 1.05]
    ylim = [ymid - absdim * 1.05, ymid + absdim * 1.05]
    #now set it on the plot!
    plot.x_range = Range1d(xlim[0], xlim[1])
    plot.y_range = Range1d(ylim[0], ylim[1])

    #reactions
    reaction_renderer.node_renderer.glyph = Square(size=8,
                                                   fill_color=Spectral4[0])
    reaction_renderer.node_renderer.selection_glyph = Square(
        size=8, fill_color=Spectral4[2])
    reaction_renderer.node_renderer.hover_glyph = Square(
        size=8, fill_color=Spectral4[1])

    #nodes
    species_renderer.node_renderer.glyph = Circle(size=12, fill_color="color")
    species_renderer.node_renderer.selection_glyph = Circle(
        size=15, fill_color=Spectral4[2])
    species_renderer.node_renderer.hover_glyph = Circle(
        size=15, fill_color=Spectral4[1])

    #this part adds the interactive elements that make it so that the lines are highlighted
    #when you mouse over and click
    edge_hover_tool = HoverTool(tooltips=None, renderers=[edges_renderer])
    species_hover_tool = HoverTool(tooltips=[("name", "@species"), ("type", "@type")],\
                                        renderers=[species_renderer],attachment="right")
    rxn_hover_tool = HoverTool(tooltips=[("reaction", "@species"), ("type", "@type"),("k_f","@k"),("k_r","@k_r")],\
                                        renderers=[reaction_renderer],attachment="right")

    plot.add_tools(edge_hover_tool, species_hover_tool, rxn_hover_tool,
                   TapTool(), BoxSelectTool(), PanTool(), WheelZoomTool())

    edges_renderer.selection_policy = NodesAndLinkedEdges()
    edges_renderer.inspection_policy = EdgesAndLinkedNodes()

    plot.renderers.append(edges_renderer)
    plot.renderers.append(reaction_renderer)
    plot.renderers.append(species_renderer)
Пример #9
0
                                          y='base',
                                          line_color=BLUE,
                                          line_width=2,
                                          line_alpha=1))


lines.add_glyph(Text(x=5.15,
                     y=92,
                     text_font_style='italic',
                     text=['Baseline'],
                     text_font_size='8pt',
                     text_color='#666666'))

lines.add_glyph(Square(x=3,
                       y=95,
                       fill_color=BLUE,
                       size=10,
                       line_color=None,
                       fill_alpha=0.8))

lines.add_glyph(Text(x=5.15,
                     y=84.75,
                     text_font_style='italic',
                     text=['Reform'],
                     text_font_size='8pt',
                     text_color='#666666'))

lines.add_glyph(Square(x=3,
                       y=88,
                       fill_color=RED,
                       size=10,
                       line_color=None,
Пример #10
0
N = len(graph_data.vertexes)
node_indices = list(range(N))

color_list = []
for vertex in graph_data.vertexes:
  color_list.append(vertex.color)


plot = figure(title='Graph Layout Demonstration', x_range=(0, 500), y_range=(0, 500),
              tools='', toolbar_location=None)

graph = GraphRenderer()

graph.node_renderer.data_source.add(node_indices, 'index')
graph.node_renderer.data_source.add(color_list, 'color')
graph.node_renderer.glyph = Square(size=30, fill_color='color')

# This is drawing edges from start to end
verts = [vertex for vertex in graph_data.vertexes]
for i in verts:
 start = []
 end = []

for vert in verts:
  for edge in vert.edges:
    start.append(verts.index(vert))
    end.append(verts.index(edge.destination))

graph.edge_renderer.data_source.data = dict(
  start=start,
  end=end)
Пример #11
0
def write_bokeh_graph(data_frame, html_output, project_code):
    df_tp = data_frame.T
    df_tp.index = pd.to_datetime(df_tp.index)
    df_tp.sort_index(inplace=True)
    df_columns_count = df_tp.shape[0]
    df_rows_count = df_tp.shape[1]
    colors = viridis(len(df_tp.columns))

    # option_sets
    hover = HoverTool(tooltips=[("name", "@name"),
                                ("time", "@time"),
                                ("count", "@count"),
                                ]
                      )
    tools_opt = ["resize", hover, "save", "pan", "wheel_zoom", "reset"]
    graph_opt = dict(width=900, x_axis_type="datetime",
                     toolbar_location="left", tools=tools_opt, toolbar_sticky=False,
                     background_fill_alpha=0, border_fill_alpha=0,
                     )
    line_opt = dict(line_width=3, alpha=0.8)
    output_file(html_output, mode="inline")

    legend_items = []

    # figure and line glyphs
    warning_figure = figure(title=project_code + " rvt warnings",
                            **graph_opt,
                            )

    for i, warning_type in enumerate(df_tp.columns):
        # print(f"df_tp.index is: \n{df_tp.index}")
        line_name_dict = [warning_type for _ in range(df_columns_count)]
        cds = ColumnDataSource(data=dict(x=df_tp.index,
                                         y=df_tp[warning_type],
                                         name=line_name_dict,
                                         count=df_tp[warning_type],
                                         time=df_tp.index.strftime("%Y-%m-%d %H:%M:%S"),
                                         )
                               )
        warning_figure.line("x",
                            "y",
                            color=colors[i],
                            name="name",
                            source=cds,
                            **line_opt
                            )
        legend_items.append((warning_type, colors[i]))

    square_size, legend_sq_offset = 20, 20
    legend_plot_height = df_rows_count * (legend_sq_offset + square_size)
    # print(f"plot height is: {legend_plot_height}")

    legend = Plot(plot_width=900,
                  plot_height=legend_plot_height,
                  x_range=Range1d(0, 300),
                  y_range=Range1d(0, legend_plot_height),
                  toolbar_location="left",
                  background_fill_alpha=0,
                  border_fill_alpha=0,
                  outline_line_alpha=0,
                  )

    for i, item in enumerate(legend_items):
        warn_type = item[0]
        color = item[1]

        square_y_pos = legend_plot_height - legend_sq_offset - i * (legend_sq_offset + square_size)

        square = Square(x=square_size,
                        y=square_y_pos,
                        size=square_size,
                        fill_color=color,
                        line_alpha=0,
                        )
        legend.add_glyph(square)

        warning_count_text = str(df_tp[warn_type][-1]).rjust(5)
        warning_text = warn_type

        count_txt = Text(x=square_size + 15,
                         y=square_y_pos,
                         text_align="right",
                         text_baseline="middle",
                         text=[warning_count_text],
                         text_font_size="10pt",
                         )
        legend.add_glyph(count_txt)
        warn_txt = Text(x=square_size + 16,
                        y=square_y_pos,
                        text_align="left",
                        text_baseline="middle",
                        text=[warning_text[:120]],
                        text_font_size="10pt",
                        )
        legend.add_glyph(warn_txt)

    save(column(style_plot(warning_figure), legend))
    print(colorful.bold_green(f" {html_output}\n updated successfully."))
    return df_tp
Пример #12
0
                x=[-75],
                y=[50],
                w=150,
                h=100)
plot1.x_range = Range1d(-75, 75, bounds=(-75, 75))
plot1.y_range = Range1d(-50, 50, bounds=(-50, 50))
shutters = plot1.square('x',
                        'y',
                        source=shutter_positions,
                        fill_color='yellow',
                        fill_alpha=0.2,
                        line_color=None,
                        size=20,
                        name="my_shutters")
shutters.selection_glyph = Square(fill_alpha=0.5,
                                  fill_color="green",
                                  line_color='green',
                                  line_width=3)
shutters.nonselection_glyph = Square(fill_alpha=0.2,
                                     fill_color="yellow",
                                     line_color=None)

hover = HoverTool(renderers=[shutters],
                  point_policy="snap_to_data",
                  tooltips="""
        <div>
            <div>
                <span style="font-size: 15px; font-weight: bold; color: #696">Mass = @mass  Msun</span>
            </div>
            <div>
                <span style="font-size: 15px; font-weight: bold; color: #696">Vmax = </span>
                <span style="font-size: 15px; font-weight: bold; color: #696;">@vmax km / s</span>
Пример #13
0
from bokeh.io import curdoc, show
from bokeh.models import ColumnDataSource, Grid, LinearAxis, Plot, Square

N = 9
x = np.linspace(-2, 2, N)
y = x**2
sizes = np.linspace(10, 20, N)

source = ColumnDataSource(dict(x=x, y=y, sizes=sizes))

plot = Plot(
    title=None, plot_width=300, plot_height=300,
    min_border=0, toolbar_location=None)

glyph = Square(x="x", y="y", size="sizes", fill_color="#74add1")
plot.add_glyph(source, glyph)

xaxis = LinearAxis()
plot.add_layout(xaxis, 'below')

yaxis = LinearAxis()
plot.add_layout(yaxis, 'left')

plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker))
plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker))

curdoc().add_root(plot)

show(plot)
Пример #14
0
def main(data, itvl):

    if itvl == 'daily':
        NR_OF_ROWS = 7
    elif itvl == 'weekly':
        NR_OF_ROWS = 7
    elif itvl == 'monthly':
        NR_OF_ROWS = 5
    elif itvl == 'yearly':
        NR_OF_ROWS = 4
    # NR_OF_COLS = len(data) // NR_OF_ROWS + 1

    # curdoc().theme = 'dark_minimal'

    p = figure(
        plot_width=PLOT_WIDTH,
        plot_height=PLOT_HEIGHT,
        title="log",
        x_range=(dt.now() - td(days=220), dt.now()),
        y_range=(0, NR_OF_ROWS + 1),
        x_axis_type="datetime",
        y_axis_type=None,
        x_axis_location="above",
        tooltips=[('date', '@date'), ('value', '@value'),
                  ('content', '@content')],
        toolbar_location=None,
        match_aspect=True,
        # tools='zoom_in,zoom_out,pan,box_zoom,reset,hover,save",
        background_fill_color='#333333')
    # p.axis.visible = False
    p.grid.grid_line_color = None
    # p.axis.axis_line_color = None
    # p.axis.major_tick_line_color = None
    # p.axis.major_label_text_font_size = "7px"
    # p.axis.major_label_standoff = 0
    # p.xaxis.major_label_orientation = np.pi/3
    p.xaxis.formatter = DatetimeTickFormatter()

    x, y, fill_alphas, date, values, content = [], [], [], [], [], []
    max_value = max([i['value'] for i in data])
    for entry in data:

        c = entry['content']
        content.append(c)

        value = entry['value']
        values.append(value)

        fill_alpha = value / max_value
        fill_alphas.append(fill_alpha)

        timestamp = entry['timestamp']
        d = dt.fromtimestamp(timestamp)
        date.append(d.strftime('%Y-%m-%d'))

        if itvl == 'daily':
            x.append(
                dt.strptime((d - td(days=d.weekday())).strftime('%Y-%m-%d'),
                            '%Y-%m-%d'))
        # if itvl == 'weekly':
        #     x.append(dt.strptime(
        #         (d - td(days=d.weekday())).strftime('%Y-%m-%d'), '%Y-%m-%d')
        #     )
        y.append(NR_OF_ROWS - d.weekday())

    source = ColumnDataSource(
        dict(x=x,
             y=y,
             fill_alpha=fill_alphas,
             date=date,
             value=values,
             content=content))

    p.add_glyph(
        source,
        Square(
            x='x',
            y='y',
            size=20,
            fill_color='#00FF00',
            fill_alpha='fill_alpha',
        ))

    select = figure(title="",
                    plot_height=30,
                    plot_width=PLOT_WIDTH,
                    y_range=p.y_range,
                    x_axis_location=None,
                    x_axis_type="datetime",
                    y_axis_type=None,
                    tools="",
                    toolbar_location=None,
                    background_fill_color='#333333')

    range_tool = RangeTool(x_range=p.x_range)
    range_tool.overlay.fill_color = "green"
    range_tool.overlay.fill_alpha = 0.2

    select.line(x=[dt(2016, 1, 1), dt.now()], y=[0, 0], color=None)
    select.ygrid.grid_line_color = None
    select.add_tools(range_tool)
    select.toolbar.active_multi = range_tool

    script, div = components(column(p, select))
    return script, div