<commit_before>import datetime
import pandas as pd
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc
import dash_table
from dash_fda.constants import INITIAL_URL, MANUFACTURERS
from dash_fda.utils import get_meta, get_results


jumbotron = dbc.Jumbotron(
    children=[
        html.H1("Dash FDA", className="display-3"),
        html.P(
            "A Plotly Dash application to interact with the API endpoints of openFDA.",
            className="lead",
        ),
    ],
    className="bg-info text-white",
)


def box_plot():
    return dbc.Card(
        [
            dbc.CardBody(
                [
                    html.H3(
                        "Adverse event reports received each month",
                        className="card-title",
                    ),
                    dcc.Graph(
                        id="box-plot-month",
                        config={"editable": False},
                        figure={"layout": {"title": {"text": ""}}},
                    ),
                ]
            ),
        ]
    )


def device_manufacturer_form():
    """medical device label+input and manufacturer label+dropdown"""
    return dbc.Card(
        dbc.Form(
            [
                dbc.FormGroup(
                    [
                        dbc.Label("Device (e.g. x-ray)", html_for="medical-device-input"),
                        dbc.Input(
                            id="medical-device-input",
                            type="text",
                            value="x-ray",
                        ),
                    ]
                ),
                dbc.FormGroup(
                    [
                        dbc.Label("Manufacturer", html_for="manufacturer-dropdown"),
                        dcc.Dropdown(
                            id="manufacturer-dropdown",
                            options=MANUFACTURERS,
                            value=MANUFACTURERS[3]["value"],
                        ),
                    ]
                ),
                html.Div(
                    [
                        dbc.Button("Submit", color="primary", id="submit-button"),
                    ],
                    className="text-right",
                ),
            ]
        )
    )


def pie_charts():
    return html.Div(
        [
            dbc.Card(
                [
                    dbc.CardBody(
                        [
                            # html.H3("Adverse Event Type", className="card-title"),
                            dcc.Graph(id="pie-event"),
                            html.P(
                                "Some quick example text to build on the card title and "
                                "make up the bulk of the card's content.",
                                className="card-text",
                            ),
                        ]
                    ),
                ],
            ),
            dbc.Card(
                [
                    dbc.CardBody(
                        [
                            # html.H3("Medical Device Class", className="card-title"),
                            dcc.Graph(id="pie-device"),
                        ]
                    ),
                ]
            ),
        ]
    )


def footer():
    meta = get_meta(INITIAL_URL)
    disclaimer = meta["disclaimer"]
    return dbc.Card(
        dbc.CardBody(
            [
                html.Span("Built with "),
                dbc.CardLink(
                    "Plotly Dash",<commit_msg>Pie charts: use 1-column layout on smaller screens<commit_after>import datetime
import pandas as pd
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc
import dash_table
from dash_fda.constants import INITIAL_URL, MANUFACTURERS
from dash_fda.utils import get_meta, get_results


jumbotron = dbc.Jumbotron(
    children=[
        html.H1("Dash FDA", className="display-3"),
        html.P(
            "A Plotly Dash application to interact with the API endpoints of openFDA.",
            className="lead",
        ),
    ],
    className="bg-info text-white",
)


def box_plot():
    return dbc.Card(
        [
            dbc.CardBody(
                [
                    html.H3(
                        "Adverse event reports received each month",
                        className="card-title",
                    ),
                    dcc.Graph(
                        id="box-plot-month",
                        config={"editable": False},
                        figure={"layout": {"title": {"text": ""}}},
                    ),
                ]
            ),
        ]
    )


def device_manufacturer_form():
    """medical device label+input and manufacturer label+dropdown"""
    return dbc.Card(
        dbc.Form(
            [
                dbc.FormGroup(
                    [
                        dbc.Label(
                            "Device (e.g. x-ray)", html_for="medical-device-input"
                        ),
                        dbc.Input(
                            id="medical-device-input",
                            type="text",
                            value="x-ray",
                        ),
                    ]
                ),
                dbc.FormGroup(
                    [
                        dbc.Label("Manufacturer", html_for="manufacturer-dropdown"),
                        dcc.Dropdown(
                            id="manufacturer-dropdown",
                            options=MANUFACTURERS,
                            value=MANUFACTURERS[3]["value"],
                        ),
                    ]
                ),
                html.Div(
                    [
                        dbc.Button("Submit", color="primary", id="submit-button"),
                    ],
                    className="text-right",
                ),
            ]
        )
    )


def pie_chart_col(chart_id):
    return dbc.Col(
        md=6,
        children=dbc.Card(
            [
                dbc.CardBody(
                    [
                        dcc.Graph(id=chart_id),
                    ]
                ),
            ],
        ),
    )


def pie_charts():
    return html.Div(
        [
            dbc.Row([pie_chart_col("pie-event"), pie_chart_col("pie-device")]),
        ]
    )


def footer():
    meta = get_meta(INITIAL_URL)
    disclaimer = meta["disclaimer"]
    return dbc.Card(
        dbc.CardBody(
            [
                html.Span("Built with "),
                dbc.CardLink(
                    "Plotly Dash",
{'fraction_non_alphanumeric': 0.09884158266887318, 'fraction_numerical': 0.0018053257108469987, 'mean_word_length': 0.9364986891931255, 'pattern_counts': {'":': 8, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5374793', 'n_tokens_mistral': 1728, 'n_tokens_neox': 1568, 'n_words': 296}