def output_chart(issues_df, output_mode='static'):
    import datetime
    import bokeh
    from bokeh.models import HoverTool

    # Add timestamp to title

    issues_chart = Bar(issues_df,
                       label='value_delivered',
                       values='status',
                       agg='count',
                       stack='status',
                       title=ISSUES_TITLE + " (Updated " +
                       datetime.datetime.now().strftime('%m/%d/%Y') + ")",
                       xlabel="Value Delivered",
                       ylabel="Number of Use Cases",
                       legend='top_right',
                       tools='hover',
                       color=brewer["GnBu"][3])

    issues_chart.plot_width = DESTINATION_FRAME_WIDTH - (HTML_BODY_MARGIN * 2)
    issues_chart.plot_height = DESTINATION_FRAME_HEIGHT - (HTML_BODY_MARGIN *
                                                           2)
    issues_chart.logo = None
    issues_chart.toolbar_location = None

    hover = issues_chart.select(dict(type=HoverTool))
    hover.tooltips = [("Value Delivered", "$x")]

    #--- Configure output ---
    reset_output()

    if output_mode == 'static':
        # Static file.  CDN is most space efficient
        output_file(ISSUES_FILE,
                    title=ISSUES_TITLE,
                    autosave=False,
                    mode='cdn',
                    root_dir=None)  # Generate file
        save(issues_chart, filename=ISSUES_FILE)
    elif output_mode == 'notebook':
        output_notebook()  # Show inline
        show(issues_chart)
    else:
        # Server (using internal server IP, rather than localhost or external)
        session = bokeh.session.Session(root_url=BOKEH_SERVER_IP,
                                        load_from_config=False)
        output_server("ddod_chart", session=session)
        show(issues_chart)
def output_chart(issues_df,output_mode='static'):
    import datetime
    import bokeh
    from bokeh.models import HoverTool


    # Add timestamp to title
    
    issues_chart = Bar(issues_df, label='value_delivered', 
               values='status', agg='count', stack='status',
               title=ISSUES_TITLE+" (Updated "+datetime.datetime.now().strftime('%m/%d/%Y')+")", 
               xlabel="Value Delivered",ylabel="Number of Use Cases",
               legend='top_right',
               tools='hover',
               color=brewer["GnBu"][3]
              )

    issues_chart.plot_width  = DESTINATION_FRAME_WIDTH  - (HTML_BODY_MARGIN * 2)
    issues_chart.plot_height = DESTINATION_FRAME_HEIGHT - (HTML_BODY_MARGIN * 2)
    issues_chart.logo = None
    issues_chart.toolbar_location = None

    hover = issues_chart.select(dict(type=HoverTool))
    hover.tooltips = [ ("Value Delivered", "$x")]


    #--- Configure output ---
    reset_output()

    if output_mode == 'static':
        # Static file.  CDN is most space efficient
        output_file(ISSUES_FILE, title=ISSUES_TITLE, 
            autosave=False, mode='cdn', 
            root_dir=None
               )   # Generate file
        save(issues_chart,filename=ISSUES_FILE)
    elif output_mode == 'notebook':
        output_notebook()   # Show inline
        show(issues_chart)
    else:
        # Server (using internal server IP, rather than localhost or external)
        session = bokeh.session.Session(root_url = BOKEH_SERVER_IP, load_from_config=False)
        output_server("ddod_chart", session=session)
        show(issues_chart)
Example #3
0
# Go to http://localhost:5006/bokeh to view this plot

from collections import OrderedDict
import time

import numpy as np

from bokeh.charts import Line, curdoc, cursession, output_server, show
from bokeh.models import GlyphRenderer

N = 80
x = np.linspace(0, 4*np.pi, N)

xyvalues = OrderedDict(sin=np.sin(x), cos=np.cos(x))

output_server("line_animate")

chart = Line(xyvalues, title="Lines", ylabel='measures')

curdoc().add(chart)

show(chart)

renderer = chart.select(dict(type=GlyphRenderer))
ds = renderer[0].data_source

while True:
    for i in np.hstack((np.linspace(1, -1, 100), np.linspace(-1, 1, 100))):
        for k, values in xyvalues.items():
            if k != 'x':
                ds.data['y_%s'%k] = values * i
Example #4
0
x = sys.argv[1]
mod = sys.argv[2]
limit = sys.argv[3]

try:
    conn = psycopg2.connect("dbname='cta' user='******' host='localhost' password=''")
except:
    print "I am unable to connect to the database"
cur = conn.cursor()
try:
	c = "SELECT "+x+", COUNT("+x+") FROM cta_stops GROUP BY "+x+" ORDER BY COUNT("+x+") "+mod+" LIMIT "+limit+";"
	cur.execute(c)
except:
    print "Query Failed"

rows = cur.fetchall()
df = pd.DataFrame.from_records(rows, columns=[x, 'count_'+x])

p = Bar(df, x, values='count_'+x, title="Graph")
output_server("bar.html")


select = Select(title="Max or Min:", value="ASC", options=["ASC", "DESC"])
slider = Slider(start=0, end=100, value=1, step=1, title="Number of Elements")
button = Button(label="Submit", type="success")
layout = vform(select, slider, button)


show(layout)
Example #5
0
# Go to http://localhost:5006/bokeh to view this plot

from collections import OrderedDict
import time

import numpy as np

from bokeh.charts import Line, curdoc, cursession, output_server, show
from bokeh.models import GlyphRenderer

N = 80
x = np.linspace(0, 4 * np.pi, N)

xyvalues = OrderedDict(sin=np.sin(x), cos=np.cos(x))

output_server("line_animate")

chart = Line(xyvalues, title="Lines", ylabel='measures')

curdoc().add(chart)

show(chart)

renderer = chart.select(dict(type=GlyphRenderer))
ds = renderer[0].data_source

while True:
    for i in np.hstack((np.linspace(1, -1, 100), np.linspace(-1, 1, 100))):
        for k, values in xyvalues.items():
            if k != 'x':
                ds.data['y_%s' % k] = values * i