Beispiel #1
0
def impressjs(tree, embed=True, params=None):
    head = tree[0]
    body = tree[1]

    def path(*args):
        return join_path("thirdparty", "impressjs", *args)

    # remove the default style
    #head.remove(head.find("./style"))
    add_class(body, "impress-not-supported")
    failback = html.Div(
        '<div class="fallback-message">' +
        '<p>Your browser <b>doesn\'t support the features required</b> by' +
        'impress.js, so you are presented with a simplified version of this' +
        'presentation.</p>' +
        '<p>For the best experience please use the latest <b>Chrome</b>,' +
        '<b>Safari</b> or <b>Firefox</b> browser.</p></div>')

    slides = html.Div(id="impress")

    for item in list(body):
        body.remove(item)
        slides.append(item)

    body.append(slides)

    # <script src="js/impress.js"></script>
    body.append(js(path("js", "impress.js"), embed))

    body.append(html.Script("impress().init();"))
Beispiel #2
0
def revealjs(tree, embed=True, params=None):
    head = tree[0]
    body = tree[1]
    params = params or {}
    theme_name = params.pop("theme", "default") + ".css"

    def path(*args):
        return join_path("thirdparty", "revealjs", *args)

    add_class(body, "reveal")
    slides = html.Div(class_="slides")

    for item in list(body):
        body.remove(item)
        slides.append(item)

    body.append(slides)

    # <link rel="stylesheet" href="css/reveal.css">
    # <link rel="stylesheet" href="css/theme/default.css" id="theme">
    head.append(css(path("css", "reveal.css"), embed))
    head.append(css(path("css", "theme", theme_name), embed))

    # <script src="lib/js/head.min.js"></script>
    # <script src="js/reveal.min.js"></script>
    body.append(js(path("lib", "js", "head.min.js"), embed))
    body.append(js(path("js", "reveal.min.js"), embed))

    head.append(css("rst2html5-reveal.css", embed))

    params['history'] = True
    param_s = json.dumps(params)
    body.append(
        html.Script("$(function () { Reveal.initialize(%s); });" % param_s))
Beispiel #3
0
def display_graphs(n_clicks, value):

    graphs = []
    for i in value:
        filtered_df = df[df.unit_name == i]
        min_y = filtered_df['PG_Unit_P10'].min() * .75
        max_y = filtered_df['PG_Unit_P90'].max()
        tmp_df = df[df['unit_name'] == i]
        graphs.append(
            dcc.Graph(id='graph-{}'.format(i),
                      figure={
                          'data':
                          [(go.Scatter(x=tmp_df['Quarter'],
                                       y=tmp_df['Unit'].round(2),
                                       hovertemplate='Unit Score: %{y}',
                                       name=i,
                                       showlegend=False,
                                       line=dict(width=2.5,
                                                 color='rgb(0,0,0)'))),
                           go.Scatter(x=tmp_df['Quarter'],
                                      y=tmp_df['PG_Unit_P10'].round(2),
                                      hovertemplate='10th Pctl: %{y}',
                                      showlegend=False,
                                      name='PG 10th Pctl',
                                      fill='tozeroy',
                                      line=dict(width=0.5,
                                                color='rgb(151, 204, 255)')),
                           go.Scatter(x=tmp_df['Quarter'],
                                      y=tmp_df['PG_Unit_P25'].round(2),
                                      hovertemplate='25th Pctl: %{y}',
                                      showlegend=False,
                                      name='PG 25th Pctl',
                                      fill='tonexty',
                                      line=dict(width=0.5,
                                                color='rgb(153, 255, 153)')),
                           go.Scatter(x=tmp_df['Quarter'],
                                      y=tmp_df['PG_Unit_P50'].round(2),
                                      hovertemplate='50th Pctl: %{y}',
                                      showlegend=False,
                                      name='PG 50th Pctl',
                                      fill='tonexty',
                                      line=dict(width=0.5,
                                                color='rgb(255, 255, 102)')),
                           go.Scatter(x=tmp_df['Quarter'],
                                      y=tmp_df['PG_Unit_P75'].round(2),
                                      hovertemplate='75th Pctl: %{y}',
                                      showlegend=False,
                                      name='PG 75th Pctl',
                                      fill='tonexty',
                                      line=dict(width=0.5,
                                                color='rgb(255, 204, 153)')),
                           go.Scatter(x=tmp_df['Quarter'],
                                      y=tmp_df['PG_Unit_P90'].round(2),
                                      hovertemplate='90th Pctl: %{y}',
                                      showlegend=False,
                                      name='PG 90th Pctl',
                                      fill='tonexty',
                                      line=dict(width=0.5,
                                                color='rgb(255, 102, 102)'))],
                          'layout': {
                              'title': 'HOC/Pt Day {}'.format(i),
                              'yaxis': {
                                  'range': [min_y, max_y]
                              }
                          },
                      },
                      style={
                          'height': '50vh',
                          'width': '90%'
                      }))
    return html.Div(graphs)
Beispiel #4
0
available_units = df['unit_name'].unique()
quarters = df['Quarter'].unique()
quarters = sorted(quarters)

micu = df[df['unit_name'] == 'MICU 12120']

app.layout = html.Div([
    html.Div([
        html.Label('Clinical Units'),
        dcc.Dropdown(id='units',
                     options=[{
                         'label': i,
                         'value': i
                     } for i in available_units],
                     value='',
                     searchable=False,
                     multi=True,
                     style={'width': '75%'}),
    ]),
    html.Div([
        html.Button(id='button', n_clicks=0, children='Add graph'),
        html.Div(id='container',
                 children=dcc.Graph(figure={'data': []},
                                    style={'display': 'none'})),
    ])
])


@app.callback(Output('container', 'children'), [Input('button', 'n_clicks')],
              [State('units', 'value')])
def display_graphs(n_clicks, value):