def setLayout(self, options):
     self.layout = html.Div([
         html.Header([
             html.A(html.Img(src='assets/hexa.png', id='logo')),
             html.H1('ANALYSIS'),
             dcc.Dropdown(
                 id='dropdown-1',
                 options=[{
                     'label': i,
                     'value': i
                 } for i in options],
                 value='',
             ),
             html.Div(id='depDropdown'),
             html.Button('Actualiser les données', id='button-1'),
         ]),
         html.Div(id='output'),
         visdcc.Run_js(id='javascript-1'),
         html.Footer([
             html.Nav([
                 html.Ul([
                     html.Li(html.Div(id='case-1')),
                     html.Li(html.Div(id='case-2')),
                     html.Li(html.Div(id='case-3'))
                 ])
             ]),
             html.Button(id='invisible_button', style={'display': 'none'}),
             visdcc.Run_js(id='javascript-2'),
         ],
                     id='footer')
     ])
Beispiel #2
0
def rightPanel(hide_twinRow=False):
    return dbc.Col(
        id='rightPanel',
        style={
            'background-color': '#111',
            'color': '#FFF'
        },
        width=9,
        children=[
            html.P(id='msgBox', children=''),
            html.H3('e-NABLE on G+, Wikifactory, and hub.e-NABLE.org...'),
            html.Br(),
            searchBox,
            dcc.Markdown("""
* **Mouse over** a data point to see author and date.
* **Click** on a data point to view the Thread in the **Selected Thread** Panel"""
                         ),
            dropDown,
            #html.P(),
            visdcc.Run_js(id='javascript'),
            twinRow(hide_twinRow),
            dcc.Graph(id='bothFig',
                      figure=fullFigs['bothFig'],
                      style={'background-color': '#111'})
        ])
Beispiel #3
0
def Base(session_id):
    return html.Div([
        dcc.Store(id='session-id', data=session_id, storage_type='session'),
        dcc.Location(id='url', refresh=False),
        html.Div(id='page-content'),
        visdcc.Run_js(id='javascript-exe'),
        html.Div(id='javascript-exe-modal-div')
    ])
Beispiel #4
0
def get_criptocoins_market():
    return html.Div(children=[
        html.Div([
            html.Br(),
            html.Label('View BINANCE Market Graph: '),
            dcc.Input(id="txt_cryptocoin_market",
                      type="text",
                      placeholder="^binance",
                      value="^binance")
        ]),
        html.Div(dcc.Graph(id="cryptocoin-market-graph")),
        visdcc.Run_js(id="javascript")
    ])
Beispiel #5
0
def interactive_menu(output_elem_id):
    """
    Create the necessary elements for the sidemenus to become interactive.

    Args:
        output_elem_id (str): The id for the div with the contents \
                          of the sidemenu.

    Returns:
        list: Dash elements, the sidebar, its buttons, and the \
              JS script to be run.
    """

    return [
        # The second sidebar with the tab-specific menu
        html.Div(
            id="sidenav2",
            className="sidenav2",
            children=[
                # Close button for the sidebar
                html.A(html.I(className="fas fa-times"),
                       className="closebtn2",
                       id="closebtn2"),

                # Contents of the sidebar
                html.Div(id=output_elem_id),
            ]),

        # Open button for the sidebar
        html.Span(id="open_menu2",
                  className="open_menu2",
                  children=[
                      html.I(className="fas fa-angle-double-right"),
                  ]),

        # Interactivity: opening/closing the sidebar resizes
        # the main div and hides/shows appropriate menu buttons
        visdcc.Run_js(id='close_sidebar',
                      run="""
            // show the button for opening the submenu
            var elem = document.getElementById("open_menu2");
            elem.style.display = "inline-block";
            
            // and bind the appropriate function to it
            elem.onclick = function(){openNav2()};
    
            // do the same for the close button
            var elem2 = document.getElementById("closebtn2");
            elem2.onclick = function(){closeNav2()};
        """)
    ]
Beispiel #6
0
def generate_control_card_tab2():
    """ Build a div that containing controls (button) for graphs.

    Currently contains:
        - dropdown menu to choose topic
        - dropdown menu to choose alert ID based on previously chosen topic.

    Returns
    ---------
    div: A Div containing controls for graphs in tab 2.
    """
    return html.Div(
        id="control-card",
        children=[
            html.P("Select Topic"),
            # Topic list
            dcc.Dropdown(id="topic-select",
                         options=[{
                             "label": i,
                             "value": i
                         } for i in topic_list],
                         value=topic_list[0],
                         clearable=False,
                         style={
                             'width': '100%',
                             'display': 'inline-block'
                         }),
            html.Br(),
            # Alert ID list
            html.P("Select Alert"),
            dcc.Dropdown(id="alerts-dropdown",
                         placeholder="Select an alert ID",
                         clearable=False,
                         style={
                             'width': '300px',
                             'display': 'inline-block'
                         }),
            html.Br(),
            html.Div(id='container-button-timestamp'),
            html.Div([visdcc.Run_js(id='aladin-lite-div')],
                     style={
                         'width': '300px',
                         'height': '300px'
                     })
        ],
    )
Beispiel #7
0
def resume_tweets(df, type='share'):

    list_twt = []

    for i in list(range(30)):

        user = df['id_user'].to_list()[i]
        tweet = int(df['tweet_id'].to_list()[i])
        is_rt = df['is_RT'].to_list()[i]

        link = df['retweeted_url'].to_list()[i]

        if link == None:
            link = df['quote_url'].to_list()[i]
        else:
            pass

        if link == None:
            link = "https://twitter.com/{user}/status/{tweet}"
        else:
            pass

        if type == 'share':
            text = f"#{i+1} Most Shared - Total Shares: {df['count'].to_list()[i]} "
        else:
            text = f"#{i+1} Most Retweeted - Total Shares: {df['count'].to_list()[i]}"
        list_twt.append(
            html.Div([
                html.Div(f"{text}",
                         style={
                             'textAlign': 'center',
                             'fontWeight': 'bold',
                             "direction": "ltr",
                             'fontSize': '18px'
                         }),
                html.Blockquote(html.A(href=link),
                                className="twitter-tweet",
                                style={'width': "498px"})
            ],
                     style={"margin": "48px 0"}))

    list_twt.append(visdcc.Run_js(id="javascript", run="twttr.widgets.load()"))

    return list_twt
Beispiel #8
0
 def _build_component(self) -> html.Div:
     timer = dcc.Interval(id=self.timer_id,
                          interval=self._update_interval_s * 1000,
                          n_intervals=0)
     scroller = visdcc.Run_js(id=self.js_id, run='')
     self.console = dcc.Textarea(id=self.console_id,
                                 contentEditable='false',
                                 style={
                                     'height': '100%',
                                     'width': '100%',
                                     'borderWidth': '1px',
                                     'borderRadius': '5px',
                                     'borderStyle': 'dashed'
                                 },
                                 persistence_type='session',
                                 persistence=True)
     return html.Div(id=self.id_,
                     children=[timer, self.console, scroller],
                     style={'height': '100%'})
Beispiel #9
0
 def _build_component(self) -> html.Div:
     timer = dcc.Interval(
         id=self.timer_id, interval=self._update_interval_s * 1000, n_intervals=0
     )
     scroller = visdcc.Run_js(id=self.js_id, run="")
     self.console = dcc.Textarea(
         id=self.console_id,
         contentEditable="false",
         style={
             "height": "100%",
             "width": "100%",
             "borderWidth": "1px",
             "borderRadius": "5px",
             "borderStyle": "dashed",
         },
         persistence_type="session",
         persistence=True,
     )
     return html.Div(
         id=self.id_,
         children=[timer, self.console, scroller],
         style={"height": "100%"},
     )
Beispiel #10
0
def layout(name):
    # even if there is one object ID, this returns  several alerts
    results = client.scan("", "key:key:{}".format(name[1:]), "*", 0, True,
                          True)

    layout_ = html.Div(
        [
            html.Br(),
            dbc.Row([
                dbc.Col(
                    [
                        title(name),
                        html.Br(),
                        html.Div([visdcc.Run_js(id='aladin-lite-div')],
                                 style={
                                     'width': '100%',
                                     'height': '25pc'
                                 }),
                        card_download(results)
                    ],
                    width={"size": 3},
                ),
                dbc.Col(tabs(results), width=8)
            ],
                    justify="around",
                    no_gutters=True),
            html.Div(id='object-data', style={'display': 'none'}),
            html.Div(id='object-upper', style={'display': 'none'})
        ],
        className='home',
        style={
            'background-image':
            'linear-gradient(rgba(255,255,255,0.5), rgba(255,255,255,0.5)), url(/assets/background.png)',
            'background-size': 'contain'
        })

    return layout_
Beispiel #11
0
                      className='message-body',
                      id='crawlShow',
                      style={
                          'overflow': 'scroll',
                          'height': '60vh'
                      })
         ],
                  className='message is-link',
                  style={'width': '100%'})
     ],
              className='tile is-8 search_input'),
 ],
          id='showPanel',
          className='tile is-ancestor',
          style={'display': 'none'}),
 visdcc.Run_js(id='crawlScript'),
 visdcc.Run_js(id='crawlScript1'),
 dcc.ConfirmDialog(id='confirm', message='已爬取过该用户,是否重新爬取?'),
 html.Div([
     html.Div('', className='tile is-4'),
     html.Div([
         html.Div(
             [
                 html.Header([
                     html.Div('查询结果',
                              id='crawled-title',
                              className='card-header-title')
                 ],
                             className='card-header'),
                 html.Div([
                     html.Div([
Beispiel #12
0
def f1(server):
    dash_app1 = dash.Dash(__name__,
                          server=server,
                          external_stylesheets=external_stylesheets)

    lowess = sm.nonparametric.lowess

    dash_app1.index_string = temp

    ##### Functions =============================
    def make_lowess(series):
        series = pd.Series(series)
        endog = series.values
        exog = series.index.values

        smooth = lowess(endog, exog)
        index, data = np.transpose(smooth)

        return pd.Series(data, index=pd.to_datetime(index))

    #### Data preparation ==============================================
    df_group = pd.read_pickle("./data.pkl")

    df_group = df_group.replace({'建物型態_': '套房(1房1廳1衛)'},
                                {'建物型態_': '套房(1房1廳1衛)'},
                                regex=False)
    df_group = df_group.replace({'建物型態_': '住宅大樓(11層含以上有電梯)'},
                                {'建物型態_': '住宅大樓(11層含以上有電梯)'},
                                regex=False)
    df_group = df_group.replace({'建物型態_': '公寓(5樓含以下無電梯)'},
                                {'建物型態_': '公寓(5樓含以下無電梯)'},
                                regex=False)
    df_group = df_group.replace({'建物型態_': '店面(店鋪)'}, {'建物型態_': '店面(店鋪)'},
                                regex=False)
    df_group = df_group.replace({'建物型態_': '華廈(10層含以下有電梯)'},
                                {'建物型態_': '華廈(10層含以下有電梯)'},
                                regex=False)

    ##### Lines =================================
    all_area = list(np.unique(np.array(df_group['鄉鎮市區_'])))
    all_type = list(np.unique(np.array(df_group['建物型態_'])))
    all_y = ['單價元平方公尺_count', '單價元平方公尺_median', 'date_diff_median']
    dash_app1.layout = html.Div(children=[
        html.Button('open url', id='button'),
        visdcc.Run_js(id='javascript'),
        html.Div(children=[
            html.Div([
                html.Div([
                    html.Label('Y'),
                    dcc.Dropdown(id='my_y',
                                 options=[{
                                     'label': p,
                                     'value': p
                                 } for p in all_y],
                                 multi=False,
                                 value="單價元平方公尺_count"),
                ]),
                html.Div([
                    html.Label('鄉鎮市區'),
                    dcc.Dropdown(id='my_area',
                                 options=[{
                                     'label': p,
                                     'value': p
                                 } for p in all_area],
                                 multi=True,
                                 value=all_area[0:4]),
                ]),
                html.Div(children=[
                    html.Label('建物型態'),
                    dcc.Dropdown(id='my_type',
                                 options=[{
                                     'label': v,
                                     'value': v
                                 } for v in all_type],
                                 multi=True,
                                 value=all_type[0:6]),
                    html.Button(id='submit-button-state',
                                n_clicks=0,
                                children='Submit',
                                style={
                                    'float': 'right',
                                    'margin': '10px 0px 10px 0px'
                                }),
                    html.Button("Fix Sc", id="fix"),
                ])
            ],
                     className="three_columns"),
            html.Div(children=[
                html.Div(children=[dcc.Graph(id="graph")]),
            ],
                     className="nine_columns")
        ],
                 className="Main",
                 id="MainPower")
    ])

    @dash_app1.callback(Output('javascript', 'run'),
                        [Input("button", "n_clicks")])
    def myfun(x):
        return """let titleEls = document.getElementsByClassName("three_columns")[0];
                    let btn = document.getElementById("fix");
                    btn.addEventListener("click",function(){
                        titleEls.classList.toggle("A");
                        btn.classList.toggle("click");
                        console.log("toggle");
                    });
                    """

    @dash_app1.callback(Output('graph', 'figure'),
                        Input('submit-button-state', 'n_clicks'),
                        State('my_y', 'value'), State('my_area', 'value'),
                        State('my_type', 'value'))
    def set_cities_options(n_clicks, my_y, my_area, my_type):
        # pdb.set_trace()
        if type(my_area) == type(''):
            my_area = [my_area]
        if type(my_type) == type(''):
            my_type = [my_type]

        # pdb.set_trace()
        df_plot = df_group[df_group['鄉鎮市區_'].isin(my_area)
                           & df_group['建物型態_'].isin(my_type)]
        df_plot['k'] = df_plot.groupby(['建物型態_',
                                        '鄉鎮市區_'])[my_y].transform(make_lowess)

        fig = px.line(
            df_plot,
            x="date_",
            y=[my_y, 'k'],
            # height=700, width=1000,
            facet_col="鄉鎮市區_",
            facet_row="建物型態_",
            template=
            'plotly',  # "plotly", "plotly_white", "plotly_dark", "ggplot2", "seaborn", "simple_white", "none"
            # color_discrete_map={
            #     my_y: "#456987",
            #     "k": "#147852"
            # }
        )
        fig.for_each_annotation(lambda a: a.update(text=a.text.split("=")[-1]))
        # pdb.set_trace()
        # fig.data[0].mode='markers+lines'
        # for i in fig.data[0:3]:
        #     i.mode = 'markers+lines'
        fig.update_xaxes(matches='x', tickangle=-45, title=None)
        fig.update_yaxes(matches=None,
                         title=None,
                         showticklabels=True,
                         visible=True)
        fig.update_layout(showlegend=False)

        return fig

    return dash_app1
Beispiel #13
0
    html.Div([
        '未查询到用户,请先进行',
        html.A('爬取', href='/crawling'),
    ],
             className='notification is-danger is-light nosearch',
             id='nosearch',
             style={'display': 'none'}),
    html.Div([
        html.Div(id='analyseResult1'),
        html.Div(id='analyseResult2'),
        html.Div(id='analyseResult3'),
        html.Div(id='analyseResult4'),
        html.Div(id='analyseResult5'),
    ],
             id='analyseResult'),
    visdcc.Run_js(id='similarScript'),
    visdcc.Run_js(id='addlistenScript'),
])


@app.callback(
    Output('info_analyse', 'style'),
    [Input('startAnalyse', 'n_clicks')],
)
def hiddenInfo(n):
    return {'display': 'none'}


@app.callback(
    [Output('addlistenScript', 'run'),
     Output('similarPanel', 'style')],
Beispiel #14
0
import visdcc
import pandas as pd

app = dash.Dash(__name__)

app.layout = html.Div([
    html.H1('These are data from G+ and Wikifactory.'),
    html.Span('Filter posts by title or author:  '),
    dcc.Input(id='filter',
              placeholder='Filter by title or author...',
              type='text',
              value=''),
    html.
    P('Mouse over a data point to see the title.  Click on a data point go to a URL.'
      ),
    visdcc.Run_js(id='javascript'),
    dcc.Graph(id='graph')
])

from PeopleAndPostsOver import df
""" The populaterizer filters and populates the graph. 
    It gets its input from filter
"""


@app.callback(Output('graph', 'figure'), [Input('filter', 'value')])
def populaterizer(value):

    #filter!
    query = df.texts.str.contains(value, case=False)
    newdf = df[query]
        [html.Tr(
            [html.Td( df.iloc[i, j], id = '{}_{}_{}'.format(id, i, j) ) for j in range(len(df.columns))]
         ) for i in range(len(df))]
    )
    return html.Table([Thead, Tbody], id = id, className = "display")

df = pd.DataFrame({'name': ['Jacky', 'Mei', 'Jay', 'Sandy', 'Jerry', 'Jimmy', 'Jeff',
                            'Jacky', 'Mei', 'Jay', 'Sandy', 'Jerry', 'Jimmy', 'Jeff',
                            'Jacky', 'Mei', 'Jay', 'Sandy', 'Jerry', 'Jimmy', 'Jeff'],
                   'age': [18, 71, 14, 56, 22, 28, 15,
                           18, 71, 14, 56, 22, 28, 15,
                           18, 71, 14, 56, 22, 28, 15]}, columns = ['name', 'age'])

app.layout = html.Div([
    html.Button('Add mousemove event', id = 'button'),
    visdcc.Run_js(id = 'javascript', run = "$('#datatable').DataTable()"),
    html.Br(),
    html.Div(
        generate_html_table_from_df(df, id = 'datatable'), 
        style = {'width': '40%'}
    ),
    html.Div(id = 'output_div')
])
           
@app.callback(
    Output('javascript', 'run'),
    [Input('button', 'n_clicks')])
def myfun(x): 
    if x is None: return ''
    return '''
    var target = $('#datatable')[0]
Beispiel #16
0
                                                         value=False),
                                        html.H4("Good 👌🏼", id="good-header")
                                    ],
                                            align="center",
                                            justify="center")
                                ],
                                        width=8)
                            ])
                        ])
                ]),
            html.Div(id='scroll-blocker', className='scroll'),
        ]),
    visdcc.Run_js(id='javascript',
                  run='''
                        new fullScroll({
                            mainElement: "main",
                            sections: ["intro", "plots"],
                            displayDots: false
                          });
                        ''')
])


@app.callback(Output("loc", "href"), [Input("start-button", "n_clicks")])
def get_started(n_clicks):
    return "#0" if n_clicks is None else "#1"


@app.callback([
    Output("title", "children"),
    Output("desc", "children"),
    Output("form", "children"),
Beispiel #17
0
import dash_html_components as html
from data.others.home_background_script import script
import visdcc


from building_blocks import *
from callbacks import *


prefix="home"
print("Loading "+prefix.capitalize()+" ...")

layout=dbc.Col([
            dbc.Col([
                html.Canvas(id="fancy-network-background",style={"position":"absolute", "width":"100%", "height":"66vh", "padding":"0px", "z-index":"0"}),# "background": "linear-gradient(to top, rgba(230,245,249,0), rgba(230,245,249,0.5))"
                visdcc.Run_js(id="fancy_network_background_script", run=script),
                # html.Center(html.H1(html.Strong("COVIDrugNet"))),
                dbc.Row([
                    dbc.Col([
                        html.Img(src=app.get_asset_url("imgs/logo_wide.svg"), alt="COVID-19 Drugs Networker", style={"width":"100%"}),
                    ], xs=10, lg=6, align="center", style={"position":"relative","z-index":"1"}),
                    dbc.Col([
                        html.P("Visualize and Analyze Networks about Drugs and Targets Related to COVID-19", style={"text-align":"center","font-size":"x-large","font-weight":"bold","background":"white","box-shadow":"0rem 0rem 0.25rem white", "border-radius": "5rem"}),
                        html.P("COVIDrugNet is a free and open web tool", style={"text-align":"center","font-size":"large","background":"white","box-shadow":"0rem 0rem 0.25rem white", "border-radius": "5rem", "margin-bottom":0}),
                        html.P("based on networks and designed to support the exploration and investigation of the landscape of medicines currently in clinical trial for the treatment of COVID-19", style={"text-align":"center","font-size":"large","background":"white","box-shadow":"0rem 0rem 0.25rem white", "border-radius": "5rem", "margin-bottom":0}),
                        html.P(["(according to ",html.A("DrugBank Dashboard dedicated to COVID-19", href="https://go.drugbank.com/covid-19", target="_blank", style={"color":"black"}),")"], style={"text-align":"center","font-size":"medium","background":"white","box-shadow":"0rem 0rem 0.25rem white", "border-radius": "5rem"})
                    ], xs=10, lg=3, align="center", style={"position":"relative","z-index":"1"})
                ], justify="center", align="center", style={"padding-top":"7.5vh", "padding-bottom":"7.5vh"}),
                # html.Center(html.H4("Visualize and Analyze Networks about Drugs and Targets Related to COVID-19")),
                dbc.Row([
                    dbc.Col([
Beispiel #18
0
def calibration_layout(calibration_data):
    return dbc.Container(
        id="main-layout",
        className="float-left",
        style={"margin-left": "20px"},
        children=[
            visdcc.Run_js(
                "javascript"),  # run javascript to refresh page on demand
            dcc.ConfirmDialog(
                id="confirm-calibration-dialog",
                message="Are you sure you want to set new calibration?"),
            dcc.ConfirmDialog(
                id="confirm-zoom-dialog",
                message="Are you sure you want to change the zoom level?"),
            dcc.ConfirmDialog(
                id="confirm-restore-calibration-dialog",
                message="Restore calibration to factory default?"),
            dbc.Row(  # single bootstrap row
                className="mt-5",
                children=[
                    dbc.Col(
                        xs=
                        12,  # put content in columns when viewing on small devices
                        sm=12,
                        md=7,
                        lg=7,
                        children=[
                            calibration_display(VIDEO_STREAM_SRC,
                                                calibration_data)
                        ]),
                    dbc.Col(
                        style={"text-align": "center"},
                        xs=12,
                        sm=12,
                        md=4,
                        lg=4,
                        children=[
                            html.Div(
                                className="div-control-group",
                                style={
                                    "padding-bottom": "24px",
                                    "padding-top": "10px"
                                },
                                children=[
                                    zoom_slider(
                                        calibration_data.get("zoom_level", 1)),
                                    dbc.Button(html.Span(
                                        "Confirm Calibration",
                                        style={"font-size": "18px"}),
                                               style={
                                                   "width": "200px",
                                                   "margin-top": "20px"
                                               },
                                               id="calibration-btn",
                                               className=
                                               "align-self-center control-btn",
                                               size="lg",
                                               n_clicks=0,
                                               color="#00aacf"),
                                    dbc.Button(
                                        html.Span("Restore Calibration",
                                                  style={"font-size": "18px"}),
                                        id="btn-restore-calib",
                                        className=
                                        "align-self-center control-btn",
                                        style={
                                            "width": "200px",
                                            "margin-top": "20px",
                                            "margin-left": "20px"
                                        },
                                        # style=style,
                                        size="lg",
                                        n_clicks=0,
                                        color="#00aacf"),
                                ])
                        ])
                ])
        ])
Beispiel #19
0
 [
     dbc.CardHeader([
         dbc.Row([
             dbc.Col(
                 html.H4("Imagen cargada"),
                 width=8,
             ),
             dbc.Col(
                 [
                     dbc.Button(
                         "Habilitar cropper",
                         id='cropper-enable',
                         color="secondary",
                         className="mr-1",
                         block=True),
                     visdcc.Run_js(
                         id='enablecropjs'),
                 ],
                 width=4,
             ),
         ]),
     ]),
     dbc.CardBody([
         html.Div(id='image-to-crop'),
     ]),
     dbc.CardFooter([
         html.H6('Datos del cropper'),
         table,
         html.H6(
             'Tipo de área a especificar'),
         dbc.Row([
             dbc.Col([
Beispiel #20
0
    def serve_layout(self, sess_id):
        download_link = html.A(id=self.DS_ID + 'download-link',
                               target='_blank',
                               href='dimred/download?value=' + sess_id),

        layout = html.Div(children=[
            dcc.Store(id=self.DS_ID + 'session_id',
                      data=sess_id,
                      storage_type='memory'),
            dcc.Store(id=self.DS_ID + 'location', storage_type='memory'),
            dcc.Store(id=self.DS_ID + 'currently_selected_data',
                      storage_type='memory'),
            dcc.Store(id=self.DS_ID + 'all_selected_pool',
                      storage_type='memory'),
            dcc.Store(id=self.DS_ID + 'all_selected_data',
                      storage_type='memory'),
            dcc.Store(id=self.DS_ID + 'uploaded_data', storage_type='memory'),
            visdcc.Run_js(id=self.DS_ID + 'javascript'),
            html.Div(children=[
                html.Div(children=[
                    html.Button('Done',
                                id=self.DS_ID + 'close_selector',
                                className="close_selector",
                                n_clicks_timestamp=0),
                    html.H4('Select Data:',
                            id=self.DS_ID + 'path',
                            style={
                                'textAlign': 'center',
                                'margin': '0',
                                'paddingTop': '3rem'
                            }),
                    html.Div(children=[
                        html.Div(
                            id=self.DS_ID + 'button_container',
                            children=self.all_buttons,
                        ),
                        html.Div(children=[
                            html.Div(children=[
                                dcc.Dropdown(
                                    id=self.DS_ID + 'ratings_assignment',
                                    options=[{
                                        'label': x,
                                        'value': x
                                    } for x in assignment_options],
                                    style={'width': '25vw'},
                                    multi=True,
                                    placeholder='Select Assignment(s)'),
                                dcc.Dropdown(id=self.DS_ID + 'ratings_prepost',
                                             options=[{
                                                 'label': x,
                                                 'value': x
                                             } for x in [
                                                 'All Pre/Post', 'Pre', 'Post'
                                             ]],
                                             style={'width': '25vw'},
                                             multi=True,
                                             placeholder='Select Pre/Post'),
                                dcc.Dropdown(id=self.DS_ID + 'ratings_type',
                                             options=[{
                                                 'label': x,
                                                 'value': x
                                             } for x in [
                                                 'All Types', 'Technology',
                                                 'Market', 'Organization'
                                             ]],
                                             style={'width': '25vw'},
                                             multi=True,
                                             placeholder='Select Type'),
                                html.Button('Add',
                                            id=self.DS_ID + 'ratings_add',
                                            n_clicks_timestamp=0)
                            ],
                                     id=self.DS_ID + 'ratings_selectors',
                                     style={'display': 'flex'}),
                            html.Div(children=[
                                dcc.
                                Dropdown(id=self.DS_ID +
                                         'decisionpoints_assignment',
                                         options=[{
                                             'label': x,
                                             'value': x
                                         } for x in [assignment_options[0]] +
                                                  assignment_options[2:]],
                                         style={'width': '25vw'},
                                         multi=True,
                                         placeholder='Select Assignment(s)'),
                                dcc.Dropdown(
                                    id=self.DS_ID + 'decisionpoints_prepost',
                                    options=[{
                                        'label': x,
                                        'value': x
                                    } for x in ['All Pre/Post', 'Pre', 'Post']
                                             ],
                                    style={'width': '25vw'},
                                    multi=True,
                                    placeholder='Select Pre/Post'),
                                html.Button('Add',
                                            id=self.DS_ID +
                                            'decisionpoints_add',
                                            n_clicks_timestamp=0)
                            ],
                                     id=self.DS_ID +
                                     'decisionpoints_selectors',
                                     style={'display': 'flex'}),
                            html.Div(children=[
                                html.Button('Add',
                                            id=self.DS_ID + 'pp_add',
                                            n_clicks_timestamp=0)
                            ],
                                     id=self.DS_ID + 'pp_selectors',
                                     style={'display': 'flex'}),
                        ],
                                 id=self.DS_ID + 'selector_container')
                    ],
                             style={
                                 'width': '100%',
                                 'display': 'flex',
                                 'justifyContent': 'center'
                             }),
                ]),
                html.Div(children=[
                    html.Div(children=[
                        html.Div(children=[
                            html.H4('Currently Selected Data',
                                    style={'textAlign': 'center'}),
                            html.Div(children=[
                                html.P('n=_, _ dropped',
                                       id=self.DS_ID + 'current_description')
                            ],
                                     style={
                                         'height': '5vh',
                                         'textAlign': 'center'
                                     }),
                            html.Div(children=[
                                dash_table.DataTable(id=self.DS_ID +
                                                     'currently_selected',
                                                     style_table={
                                                         'height': '100%',
                                                         'overflowY': 'scroll'
                                                     },
                                                     page_current=0,
                                                     page_size=8,
                                                     page_action='custom',
                                                     fill_width=True)
                            ],
                                     style={
                                         'flex': '1',
                                         'minHeight': '0'
                                     })
                        ],
                                 style={
                                     'display': 'flex',
                                     'flexDirection': 'column',
                                     'width': '48%',
                                     'margin': '1%'
                                 }),
                        html.Div(children=[
                            download_link[0],
                            dcc.Upload(id=self.DS_ID + 'upload_all_selected',
                                       children=[
                                           html.Button(
                                               'Upload',
                                               className='downloadButton',
                                               style={'left': '51%'})
                                       ]),
                            html.Button(id=self.DS_ID +
                                        'download_all_selected',
                                        children=['Download'],
                                        className='downloadButton'),
                            html.H4('All Selected Data',
                                    style={'textAlign': 'center'}),
                            html.P('n = 0',
                                   id=self.DS_ID + 'all_selected_n',
                                   style={'textAlign': 'center'}),
                            dcc.Dropdown(id=self.DS_ID + 'label',
                                         className='dropdown-spacing',
                                         placeholder='Label',
                                         style={} if
                                         (self.DS_ID == 'class____'
                                          or self.DS_ID == 'reg____') else
                                         {'display': 'none'}),
                            dcc.Dropdown(id=self.DS_ID +
                                         'all_selected_dropdown',
                                         className='dropdown-spacing',
                                         multi=True,
                                         value=[],
                                         placeholder='Data Sets'),
                            html.Div(children=[
                                dash_table.DataTable(
                                    id=self.DS_ID + 'all_selected',
                                    style_table={
                                        'height': '100%',
                                        'overflowY': 'scroll'
                                    },
                                    page_current=0,
                                    page_size=6,
                                    page_action='custom',
                                    merge_duplicate_headers=True,
                                    fill_width=True)
                            ],
                                     style={
                                         'flex': '1',
                                         'minHeight': '0'
                                     })
                        ],
                                 style={
                                     'display': 'flex',
                                     'flexDirection': 'column',
                                     'width': '48%',
                                     'margin': '1%'
                                 }),
                    ],
                             style={
                                 'display': 'flex',
                                 'height': '100%'
                             }),
                ],
                         style={
                             'flex': '1',
                             'marginTop': '1rem',
                             'minHeight': '0'
                         })
            ],
                     id=self.DS_ID + 'selector',
                     className="selector",
                     style={'display': 'none'}),
            html.Div(children=[
                html.Div(children=[
                    html.Div(children=[
                        html.H4("Select Questions",
                                style={'marginRight': '2rem'}),
                        html.Button("Select All",
                                    id=self.DS_ID + 'select_all_pp',
                                    n_clicks_timestamp=0),
                        html.Button("Deselect All",
                                    id=self.DS_ID + 'deselect_all_pp',
                                    n_clicks_timestamp=0),
                        html.Button('Close',
                                    id=self.DS_ID + 'close_pp_selector',
                                    n_clicks_timestamp=0,
                                    style={'marginLeft': 'auto'}),
                    ],
                             style={
                                 'display': 'flex',
                                 'paddingBottom': '2rem'
                             }),
                    dash_table.DataTable(
                        id=self.DS_ID + 'pp_table',
                        columns=[{
                            "name": 'Questions',
                            "id": 'Questions'
                        }],
                        data=[{
                            'Questions': x
                        }
                              for x in pp_questions],
                        style_cell={
                            'textAlign': 'left',
                        },
                        style_table={
                            'maxHeight': '80vh',
                            'overflowY': 'scroll',
                        },
                        style_data={'whiteSpace': 'normal'},
                        css=[{
                            'selector':
                            '.dash-cell div.dash-cell-value',
                            'rule':
                            'display: inline; white-space: inherit; overflow: inherit; text-overflow: inherit;'
                        }],
                        row_selectable="multi",
                        filter_action='native',
                        sort_action='native',
                        fill_width=True)
                ],
                         className='pp_container'),
            ],
                     id=self.DS_ID + 'pp_questions_selector',
                     className='pp_questions',
                     style={'display': 'none'}),
            html.Div(children=[
                html.Div(children=[
                    html.Div(children=[
                        html.H4("Select Concentrations",
                                style={'marginRight': '2rem'}),
                        html.Button("Select All",
                                    id=self.DS_ID + 'select_all_concentration',
                                    n_clicks_timestamp=0),
                        html.Button("Deselect All",
                                    id=self.DS_ID +
                                    'deselect_all_concentration',
                                    n_clicks_timestamp=0),
                        html.Button('Close',
                                    id=self.DS_ID +
                                    'close_concentration_selector',
                                    n_clicks_timestamp=0,
                                    style={'marginLeft': 'auto'}),
                    ],
                             style={
                                 'display': 'flex',
                                 'paddingBottom': '2rem'
                             }),
                    dash_table.DataTable(
                        id=self.DS_ID + 'concentration_table',
                        columns=[{
                            "name": app_data.additional_questions[1][0],
                            "id": app_data.additional_questions[1][0]
                        }],
                        data=[{
                            app_data.additional_questions[1][0]: x
                        } for x in app_data.concentrations],
                        style_cell={
                            'textAlign': 'left',
                        },
                        style_table={
                            'maxHeight': '80vh',
                            'overflowY': 'scroll',
                        },
                        style_data={'whiteSpace': 'normal'},
                        css=[{
                            'selector':
                            '.dash-cell div.dash-cell-value',
                            'rule':
                            'display: inline; white-space: inherit; overflow: inherit; text-overflow: inherit;'
                        }],
                        row_selectable="multi",
                        filter_action='native',
                        sort_action='native',
                        fill_width=True)
                ],
                         className='pp_container'),
            ],
                     id=self.DS_ID + 'concentration_selector',
                     className='pp_questions',
                     style={'display': 'none'}),
            html.Div(children=[
                html.Div(children=[
                    html.Div(children=[
                        html.H4("Select Companies",
                                style={'marginRight': '2rem'}),
                        html.Button("Select All",
                                    id=self.DS_ID + 'select_all_companies',
                                    n_clicks_timestamp=0),
                        html.Button("Deselect All",
                                    id=self.DS_ID + 'deselect_all_companies',
                                    n_clicks_timestamp=0),
                        html.Button('Close',
                                    id=self.DS_ID + 'close_companies_selector',
                                    n_clicks_timestamp=0,
                                    style={'marginLeft': 'auto'}),
                    ],
                             style={
                                 'display': 'flex',
                                 'paddingBottom': '2rem'
                             }),
                    dash_table.DataTable(
                        id=self.DS_ID + 'companies_table',
                        columns=[{
                            "name": app_data.additional_questions[0][0],
                            "id": app_data.additional_questions[0][0]
                        }],
                        data=[{
                            app_data.additional_questions[0][0]: x
                        } for x in app_data.companies],
                        style_cell={
                            'textAlign': 'left',
                        },
                        style_table={
                            'maxHeight': '80vh',
                            'overflowY': 'scroll',
                        },
                        style_data={'whiteSpace': 'normal'},
                        css=[{
                            'selector':
                            '.dash-cell div.dash-cell-value',
                            'rule':
                            'display: inline; white-space: inherit; overflow: inherit; text-overflow: inherit;'
                        }],
                        row_selectable="multi",
                        filter_action='native',
                        sort_action='native',
                        fill_width=True)
                ],
                         className='pp_container'),
            ],
                     id=self.DS_ID + 'companies_selector',
                     className='pp_questions',
                     style={'display': 'none'}),
        ],
                          style={
                              'position': 'absolute',
                              'width': '100%',
                              'top': '5vh'
                          })

        return layout
if config.MLFLOW_URI is not None:
    mlflow.tracking.set_tracking_uri(config.MLFLOW_URI)

df_select_init = pd.DataFrame()
df_select_init['filename'] = [[]] * 1
df_select_init['_id'] = [[]] * 1
df_select_init['content_type'] = [[]] * 1
df_select_init['comments'] = [[]] * 1
df_labels_init = pd.DataFrame(config.DEFAULT_LABELS)

layout = html.Div([
    html.Div([
        html.Div([
            dcc.Store(id='store-shapes'),
            dcc.Store(id='polygon-data'),
            visdcc.Run_js(id='javascript-ctrl-click',
                          run="$('#graph-image').Graph()"),
            visdcc.Run_js(id='javascript-ctrl-keyup',
                          run="$('#graph-image').Graph()"),
            visdcc.Run_js(id='javascript-drag-color',
                          run="$('#graph-image').Graph()"),
            html.Br(),
            html.Div([
                html.Button(id='button-rect',
                            n_clicks=0,
                            title='rectangle marquee tool',
                            style={
                                'background-image': 'url(../assets/rect.png)',
                                'background-repeat': 'no-repeat',
                                'background-size': 'contain',
                                'background-position': 'center',
                                'height': '50px',
Beispiel #22
0
                                        html.Div([
                                            dcc.Graph(id='bankrupcy_proba-graph')
                                        ], id='prediction-graph-div')
                                    ]
                                )
                            ]
                        )]
                    )
                )
            ]),
        visdcc.Run_js(id='javascript',
                      run='''
                            new fullScroll({	
                                mainElement: 'main', 
                                sections:['title-section', 'map-section','prediction-section'],
                                displayDots: true,
                                dotsPosition: 'right',
                                animateTime: 0.7,
                                animateFunction: 'ease'	
                            });
                            '''
                      ),
    ]
)

@app.callback(
    Output('map', 'figure'),
    [
        Input('year-slider', 'value'),
        Input('map-type-radiobuttons', 'value'),
        Input('selected-voivodeship-indices', 'children'),
    ])
Beispiel #23
0
    dbc.Row([
        dbc.Col(filters, width=2),
        dbc.Col([
            search_bar,
            html.Div(results,
                     id='results_box',
                     style={
                         "maxHeight": "550px",
                         "overflowY": "scroll"
                     }),
            html.Br(), pagination_buttons
        ],
                width=8),
        dbc.Col(top_tags, width=2)
    ]),
    visdcc.Run_js(id='scroll_top')
])

# PROJECT PAGE
# instructions
graph_text = dcc.Markdown("""
    Learn more about this project and discover related projects. The figure below
    displays this project's top 7 most related projects. The size of the
    connection represents the strength of the relationship between projects.
    Different color projects represent different clusters of related projects.
    
    **Click and drag to move individual nodes. Hover over nodes or relationships
    for more info.**
    """)

project_layout = html.Div([
Beispiel #24
0
COEFFICIENTS_PATH = "{}/coefficients.json".format(PATH)
DATA_PATH = "{}/data.json".format(PATH)
NORMALIZED_DATA_PATH = "{}/normalizedData.json".format(PATH)
TEXT_PATH = "text.json"

app = dash.Dash(__name__, external_stylesheets=[dbc.themes.COSMO])
server = app.server
app.title = "Unessay"
devMode = False
data = appUtil.getDataFrame(DATA_PATH)
normalizedData = appUtil.getDataFrame(NORMALIZED_DATA_PATH)
coefficients = appUtil.getDataFrame(COEFFICIENTS_PATH)
text = appUtil.getTextObject(TEXT_PATH)

app.layout = html.Div(children=[
    visdcc.Run_js(id='intro1'),
    visdcc.Run_js(id='mon1'),
    visdcc.Run_js(id='dat1'),
    visdcc.Run_js(id='mod1'),
    visdcc.Run_js(id='viz1'),
    visdcc.Run_js(id='gd1'),
    visdcc.Run_js(id='bd1'),
    visdcc.Run_js(id='cnc1'),
    dbc.Row([
        dbc.Col([html.Div([])], md=4),
        dbc.Col(dbc.Row(html.H1(children='Machine Learning in Organizations'),
                        justify="center"),
                md=4),
        dbc.Col(getHeader(), align="right")
    ]),
    html.Div(id='data', style={'display': 'none'}),
Beispiel #25
0
import sd_material_ui
import visdcc

import uuid
import pickle
import pandas as pd
import os

static_dir = os.path.dirname(__file__)

SideBar = [
    html.Img(id="app_logo",
             src=encode_image(os.path.join(static_dir,
                                           "assets/images/y2d.png"))),
    html.Br(),
    visdcc.Run_js(id='theme_javascript'),
    html.Div(html.A('Dark/Light theme'),
             id="dark_theme",
             n_clicks=0,
             className="nav_item"),

    # Collapsible button with external links
    html.Div(html.A([
        html.Span('External links'),
        html.I(className="fa fa-caret-down", id="external_links_caret"),
    ]),
             id='button_collapse',
             n_clicks=0,
             className="nav_item"),
    # Stuff inside the collapsible
    html.Div(
Beispiel #26
0
                                            style={'display': 'inline-block'}),
                                        html.Div(
                                            id='heatmap-good-graph3',
                                            style={'display': 'inline-block'}),
                                    ]),
                                ],
                                         style={'display': 'inline-block'})
                            ])
                    ])),
        ]),
    visdcc.Run_js(id='javascript',
                  run='''
                            new fullScroll({	
                                mainElement: 'main', 
                                sections:['barplot-section', 'scatter-section', 'scatter-3d-section', 'piechart-section', 'heatmap-section'],
                                displayDots: true,
                                dotsPosition: 'right',
                                animateTime: 0.7,
                                animateFunction: 'ease'	
                            });
                            '''),
])


@app.callback([
    dash.dependencies.Output('barplot-good-graph', 'children'),
    dash.dependencies.Output('barplot-explanation', 'children'),
    dash.dependencies.Output('barplot-wrong-answer', 'style'),
    dash.dependencies.Output('barplot-good-answer', 'style'),
    dash.dependencies.Output('barplot-number-of-clicks', 'children')
], [
Beispiel #27
0
authorizedLayout = html.Div(id='authorizedContent',
                            children='Your app goes here')

# Layout to display when the user is not authorized
# You can use the redirect layout instead to return the user to the signin page
unauthaurizedLayout = html.Div(children=[
    html.H1(id='title', children='Unauthaurized user'),
    html.A(
        id='signout', href=routes["SIGNIN"], children="Return to signin page")
])

# Use this layout to redirect the user to another page (signin page?)
# Use this to run JS inside dash: https://github.com/jimmybow/visdcc#3-visdccrun_js-
redirectLayout = html.Div(children=[
    visdcc.Run_js(id='javascript',
                  run='window.location.replace("' + routes['SIGNINFULLPATH'] +
                  '");')
    # visdcc.Run_js(id = 'javascript', run='window.location.replace("http://*****:*****@app.callback(Output('pageContent', 'children'), [Input('url', 'pathname')])
def on_load(path):
    if path == '/revoke':
        session.logout()
Beispiel #28
0
def server_layout(mode=None):
    #return the layout of the GUI
    session_id = str(uuid.uuid4())

    #variable, distribution selection panel
    selection_panel = html.Div(id='selection-panel',children=[
        html.Div(id='selected-column-panel',children=[
            html.Div(id='selected-column-sec1-panel',children=[
                drc.NamedDropdown(
                    name='Select series',
                    id='selected-series',
                    searchable=False,
                    clearable=False
                ),
                dcc.Checklist(
                    id='apply-log-transform',
                    options=[{'label':' Apply log transform','value':'logtransform'}
                ]),
            ]),
            drc.NamedTextarea(
                id='series-characteristics',
                name='Series characteristics',
                cols='50',
                rows='2',
                readOnly='readOnly'
            ),
        ]),
        html.Div(id='apply-panel',children=[
            html.Div(id='apply-sec1-panel',children=[
                drc.NamedDropdown(
                    id='fitted-distributions',
                    name='Fitted distribution',
                    options=[
                        {'label': ' '+ v[0], 'value': k}
                        for k,v in dist_par_template.items() if k != 'native' and v[2]
                    ],
                    value='normal',
                    searchable=False,
                    clearable=False
                ),
            ]),
            # html.Div(id='apply-sec1b-panel',children=[
            #     drc.NamedDropdown(
            #         id='plotting-distributions',
            #         name='Probability scale',
            #         options=[
            #             {'label': ' '+ v[0], 'value': k}
            #             for k,v in dist_par_template.items() if v[2]
            #         ],
            #         value='native',
            #         searchable=False,
            #         clearable=False
            #     ),
            # ]),
            html.Div(id='apply-sec2a-panel',children=[
                html.Button('Fit',id='fit-button',n_clicks=0),
            ]),
            #dcc.Checklist(
            #    id='show-y-log',
            #    options=[{'label':' Show y-axis in log scale','value':'true'}
            #]),
        ]),
        html.Label(id='graph-refresh'),
        dcc.Store(
            id='graph-refresh-hidden',
            data=0
        ),
        html.Div(id='message-panel',children=[""]),

    ])

    #variable, distribution selection panel
    par_panel = html.Div(id='fitted-panel',children=[
        html.Div(id='fitted-sec1-panel',children=[
            drc.NamedTextarea(
                id='fitted-par',
                name='Estimated distribution parameters',
                readOnly='readOnly',
                cols= 40,
                rows= 3
            ),
            drc.NamedTextarea(
                id='estimated-quantiles',
                name='Estimated quantiles',
                readOnly='readOnly',
                cols= 40,
                rows= 3
            ),
        ])
    ])

    upload_panel = html.Div(id='last-card',children=[
        dcc.Upload(
            id='upload-data',
            children=html.Div([
                'Drag and Drop or ',
                html.A('Select File')
            ]),
            style={
                'lineHeight': '60px',
                'borderWidth': '1px',
                'borderStyle': 'dashed',
                'borderRadius': '5px',
                'textAlign': 'center',
            }
        ),
        html.Label('''File upload limited to < %0.0f Kb, containing no more than %d rows and %d columns'''%(configs['max_file_size']/1024,configs['max_file_rows'],configs['max_file_cols'])),
        html.Label('',id='data-filename'),
        html.Label('',id='data-description'),
        html.Div(id='table-panel',children=[
            dash_table.DataTable(
                id='attribute-table',
                columns=[],
                row_selectable='multi',
                editable=False,
                style_header={
                    'textAlign': 'center',
                    'fontWeight': 'bold',
                    'color': 'black',
                },
                style_cell={
                    'padding': '2px',
                    '--selected-background': 'grey',
                    'color': 'black',
                },
                style_data_conditional=[
                    {
                        'if': {'row_index': 'odd'},
                        'backgroundColor': 'rgb(248, 248, 248)'
                    }
                ],
                #locale_format= '0.3',
            )
        ],style={'visibility':'none','display':'none'}),
    ])

    chart_panel = html.Div(id='chart-panel',children=[
        dcc.Loading(id = "loading-icon", children=[
            dcc.Graph(
                id='graph',
                figure={
                },
                responsive=True,
                config=graph_config,
                style={'display':'none'}
            )
        ]),
    ],
    style={'visibility':'none'})


    layout = html.Div(
        id="body",
        className="container scalable",
        children=[
            visdcc.Run_js(id = 'chart-updated-js'),
            visdcc.Run_js(id = 'chart-unupdated-js'),
            visdcc.Run_js(id = 'error-display-js'),
            dcc.Store(id='error-display',data=''),
            html.Title(title=configs['title']),
            #hidden session id
            #row 1 for title
            html.Div(id='top-panel',children=[
                html.H5(id='app-title',children=
                    '''Distribution Fitting and Analysis Tool.
                    This tool is only for demostration porpuses''',
                    style={"margin-bottom": "0px"},
                ),
            ],className="row flex-display"),
            #second row layout
            html.Div(id='main-panel',children=[
                html.Div(id='left-panel',children=[
                    upload_panel
                ]),
                html.Div(id='output-panel',children=[
                    selection_panel,
                    par_panel,
                    chart_panel
                ],style={'visibility':'none','display':'none'}),
            ]),
            #row 4 is the footer
            html.Div(id='footer-panel',children=[
                '''
                    A web application built on top of Dash (v%s) (framework for Python) by
                    Exequiel Sepúlveda and Dmitri Kavetski.'''%(dash.__version__)
            ]),
        ],
    )
    return layout