Exemple #1
0
def endings_dashboard(response):
    urls = [x[0][0] for x in response["pages"]]
    parsed_urls = [urlparse(x).hostname for x in urls]
    endings_counter = Counter([x[x.rfind("."):] for x in parsed_urls
                               ]).most_common(ENDING_PLOT_LIMIT)
    xendings = [x[0] for x in endings_counter]
    yendings = [y[1] for y in endings_counter]
    source = ColumnDataSource(data=dict(x=xendings, y=yendings))

    table = VBox(children=[endings_table(source)])
    plot = VBox(children=[endings_plot(source)])
    return components(vplot(HBox(children=[table, plot])))
Exemple #2
0
def domains_dashboard(response, extra_plots=None):
    """
    Domains dashboard plot function. Takes an arguments for extra plots which
    will be added in a tab with the other plots.
    """
    # Parsed Response Data
    urls = [x[0][0] for x in response["pages"]]
    parsed_urls = [urlparse(x).hostname for x in urls]

    # Domain names Bar chart.
    domains_counter = Counter(parsed_urls).most_common(DOMAIN_PLOT_LIMIT)
    xdomains = [x[0] for x in domains_counter]
    ydomains = [y[1] for y in domains_counter]
    source_domains = ColumnDataSource(data=dict(x=xdomains, y=ydomains))

    bar_domains = Bar(source_domains.data,
                      values="y",
                      label="x",
                      title="Most Common Sites by Number",
                      bar_width=BAR_WIDTH,
                      height=584,
                      xlabel="Sites",
                      ylabel="Occurences")
    panel_domains = Panel(child=bar_domains, title="Sites")

    # Domain Information Table
    table_domains_counter = Counter(parsed_urls).most_common(
        DOMAIN_TABLE_LIMIT)
    xdomains_table = [x[0] for x in table_domains_counter]
    ydomains_table = [y[1] for y in table_domains_counter]
    source_table_domains = ColumnDataSource(
        data=dict(x=xdomains_table, y=ydomains_table))

    columns_domain = [
        TableColumn(field="x", title="Site Name"),
        TableColumn(field="y", title="Count"),
    ]
    data_table_domain = DataTable(source=source_table_domains,
                                  columns=columns_domain,
                                  width=400,
                                  height=280)

    # Add the plots and charts to a vform and organize them with VBox and HBox
    plot_tabs = Tabs(tabs=[panel_domains, extra_plots])

    # Take the plot and table and arrange them in a hbox.
    vbox_tables = VBox(children=[data_table_domain])
    vbox_plots = VBox(children=[plot_tabs])
    hbox_dashboard = HBox(children=[vbox_tables, vbox_plots])
    return components(vplot(hbox_dashboard))
Exemple #3
0
def large_plot(n):
    from bokeh.models import (Plot, LinearAxis, Grid, GlyphRenderer,
                              ColumnDataSource, DataRange1d, PanTool,
                              WheelZoomTool, BoxZoomTool, BoxSelectTool,
                              BoxSelectionOverlay, ResizeTool, PreviewSaveTool,
                              ResetTool)
    from bokeh.models.widgets.layouts import VBox
    from bokeh.models.glyphs import Line

    vbox = VBox()
    objects = set([vbox])

    for i in xrange(n):
        source = ColumnDataSource(data=dict(x=[0, i + 1], y=[0, i + 1]))
        xdr = DataRange1d()
        ydr = DataRange1d()
        plot = Plot(x_range=xdr, y_range=ydr)
        xaxis = LinearAxis(plot=plot)
        yaxis = LinearAxis(plot=plot)
        xgrid = Grid(plot=plot, dimension=0)
        ygrid = Grid(plot=plot, dimension=1)
        tickers = [
            xaxis.ticker, xaxis.formatter, yaxis.ticker, yaxis.formatter
        ]
        glyph = Line(x='x', y='y')
        renderer = GlyphRenderer(data_source=source, glyph=glyph)
        plot.renderers.append(renderer)
        pan = PanTool(plot=plot)
        wheel_zoom = WheelZoomTool(plot=plot)
        box_zoom = BoxZoomTool(plot=plot)
        box_select = BoxSelectTool(plot=plot)
        box_selection = BoxSelectionOverlay(tool=box_select)
        plot.renderers.append(box_selection)
        resize = ResizeTool(plot=plot)
        previewsave = PreviewSaveTool(plot=plot)
        reset = ResetTool(plot=plot)
        tools = [
            pan, wheel_zoom, box_zoom, box_select, resize, previewsave, reset
        ]
        plot.tools.extend(tools)
        vbox.children.append(plot)
        objects |= set([
            source, xdr, ydr, plot, xaxis, yaxis, xgrid, ygrid, renderer,
            glyph, plot.tool_events, box_selection
        ] + tickers + tools)

    return vbox, objects
Exemple #4
0
            text_font_size='10pt',
            text_color='black')

    Callback_A = CustomJS(args={
        'source1': source1,
        'gsvsingle': source2,
        'tcsingle': source3
    },
                          code="""
            var f = cb_obj.get('value');
            var data1 = source1.get('data');
            var data2 = gsvsingle.get('data');
            var data3 = tcsingle.get('data');
            data1['x'] = data2[f];
            data1['y'] = data3[f];
            source1.trigger('change');
        """)
    #Use the Select widget
    dropdown_age = Select(title="Organization:",
                          value='AMERICAN HEART ASSOCIATION INC',
                          options=on_sorted,
                          callback=Callback_A)

    #Display data
    filters = VBox(dropdown_age)
    tot = HBox(filters, gridplot([[p1]]))
    show(tot)

conn.commit()

conn.close()