def generate_prop_table(component_name, component_names, library_name): '''Generate a prop table for each component (both React and Python). :param (str) component_name: The name of the component as it is defined within the package. :param (dict[list]) component_names: A dictionary defining which components are React components, and which are Python components. The keys in the dictionary are 'react' and 'python', and the values for each are lists containing the names of the components that belong to each category. :param (str) library_name: The name of the library. :rtype (object): An html.Table containing data on the props of the component. ''' regex = { 'python': r'^\s*([a-zA-Z_]*)\s*\(([a-zA-Z\/]*);\s*([a-z]*)\):\s*(.*?)\s*(\(Default:\s*(.*)\)|)\s*$' } component_type = 'react' \ if component_name in component_names['react'] else 'python' tableRows = [ html.Tr([ html.Th('Attribute'), html.Th('Description'), html.Th('Type'), html.Th('Default value') ]) ] exec("import {}".format(library_name)) if component_type == 'python': sep = '\n-' doc = eval("{}.{}".format(library_name, component_name)).__doc__ props = doc.split(sep) elif component_type == 'react': path = os.path.join( os.path.dirname(os.path.abspath(eval(library_name).__file__)), 'metadata.json') with open(path, 'r') as f: metadata = json.load(f) # Mol3d for some reason is a plain JS file, not a react file cname = '{}.react.js'.format(component_name) if component_name == 'Molecule3dViewer': cname = 'Molecule3dViewer.js' elif component_name == 'Molecule2dViewer': cname = 'Molecule2dViewer.react.js' docs = metadata['src/lib/components/{}'.format(cname)] props = docs['props'] for prop in props: if component_type == 'python': desc_sections = prop.split('\n\n') partone = desc_sections[0].replace(' ', ' ') r = re.match(re.compile(regex[component_type]), partone.replace('\n', ' ')) if r is None: continue (prop_name, prop_type, prop_optional, prop_desc, _, prop_default) = r.groups() if prop_default is None: prop_default = '' if 'optional' in prop_optional: prop_optional = '' if len(desc_sections) > 1: prop_desc += ' ' prop_desc += desc_sections[1] elif component_type == 'react': prop_name = prop prop_desc = props[prop]['description'] prop_type = js_to_py_type(props[prop]['type']) if 'defaultValue' in props[prop].keys(): prop_default = props[prop]['defaultValue']['value'] else: prop_default = '' tableRows.append( html.Tr([ html.Td(rc.Markdown(prop_name)), html.Td(rc.Markdown(prop_desc)), html.Td(rc.Markdown(prop_type)), html.Td(rc.Markdown('```python \n' + prop_default + '\n```')) ])) return html.Div([ html.H3("{} Properties".format(component_name)), html.Table(tableRows) ])
def get_evaluation_dash_app(self, dash_=None): """ Evaluation dass app. :return: """ external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] if dash_ is None: app = dash.Dash(__name__, external_stylesheets=external_stylesheets, suppress_callback_exceptions=True) else: app = dash_ # forward_returns_period = [1, 2, 5, 10] # period list # forward_str = str(forward_returns_period).replace('[', '').replace(']', '') para_dcc_list = [] for k, v in self.alpha_func_paras.items(): para_dcc_list.append(html.Div(children=k)) para_dcc_list.append(dcc.Input( id="input_{}".format(k), placeholder=str(k), type='number', value=str(v), debounce=True )) app.layout = html.Div(children=[ html.H1(children=self.factor_name + ' evaluation', style={'font-weight': 'normal', 'text-align': 'center', 'display': 'block', 'fontFamily': 'helvetica neue', 'margin': '100px auto'}), html.Div([ # change forward returns html.Div([ html.Div(id='forward-returns-period'), # add forward returns html.Div(children='Enter a value to add or remove forward return value'), dcc.Input( id='forwards-periods-input', type='text', value='1, 2, 5, 10' ), html.Button('Update', id='UpdateButton'), ] , style={'margin-left': '6.25em', 'width:': '25em', 'float': 'left'}), # change parameter html.Div([ html.Div(children='Factor Parameter'), html.Div(para_dcc_list, id='alpha_paras'), html.Button('Submit', id='AlphaButton'), html.Div(id="current-parameter"), ], style={'margin-left': '20em', 'display': 'inline-block'}), ]), html.Div([ dcc.RadioItems( id='in-out-sample', options=[{'label': i, 'value': i} for i in ['In sample', 'Out ot the sample']], value='In sample', labelStyle={'display': 'inline-block'} ) ], style={'display': 'block', 'margin': '0px 100px 50px 100px'}), # summary table html.Div([html.H5(children='Factor Summary Table', style={'text-align': 'center', 'margin-bottom': '20px'}), html.Table(id='summary-table', style={'width:': '40%', 'float': 'left', 'font-size': '1.25em'})], style={'margin-left': '6.25rem', 'display': 'inline-block'}), # ic_table html.Div([html.H5(children='Factor IC Table', style={'display': 'block', 'text-align': 'center', 'margin-bottom': '20px'}), html.Table(id='ic-table', style={'width:': '40%', 'font-size': '1.25em'}), ], style={'margin-left': '18.75em', 'display': 'inline-block'}), # beta table html.Div([html.H5(children='Factor Beta', style={'text-align': 'center', 'margin-bottom': '20px'}) , html.Table(id='beta-table', style={'width': '100%', 'font-size': '1.25em'})], style={'display': 'block', 'margin': '20px auto 60px'}), html.Div([html.H5(children='Factor Distribution', style={'text-align': 'center', 'margin': 'auto'}), dcc.Graph(id='distribution')], style={'width': '49%', 'display': 'inline-block', 'margin-bottom': '50px'}), html.Div([html.H5(children='Q-Q plot ', style={'text-align': 'center', 'margin': 'auto'}), dcc.Graph(id='qqplot')], style={'width': '49%', 'display': 'inline-block', 'margin-bottom': '50px'}), html.Div([html.H5(children='Factor IC', style={'text-align': 'center', 'margin': 'auto'}), dcc.Graph(id='ic_heatmap')], style={'width': '100%', 'display': 'inline-block', 'margin-bottom': '50px'}), html.Div([html.H5(children='Price Factor', style={'text-align': 'center', 'margin': 'auto'}), dcc.Graph(id='price_factor')], style={'width': '100%', 'display': 'inline-block', 'margin-bottom': '50px'}), html.Div([html.H5(children='Factor Return', style={'text-align': 'center', 'margin': 'auto'}), dcc.Graph(id='factor-returns')], style={'width': '100%', 'display': 'inline-block', 'margin-bottom': '50px'}), html.Div([html.H5(children='Factor Backtesting', style={'text-align': 'center', 'margin': 'auto'}), dcc.Graph(id='factor-backtest')], style={'width': '100%', 'display': 'inline-block', 'margin-bottom': '50px'}), html.Div(children=self.factor.to_json(orient='split'), id='in_sample_factor', style={'display': 'none'}), html.Div(id='out_sample_factor', style={'display': 'none'}), html.Div(children=json.dumps([1, 2, 5, 10]), id='forward_returns_period_saved', style={'display': 'none'}), html.Div(id='forward_str', style={'display': 'none'}), ], style={'margin': '20px'}) # make input parameter into dict def _get_alpha_parameter_from_div(alpha_paras): paras = {} for child in alpha_paras: if child['type'] == 'Input': props = child['props'] k = props['id'].replace('input_', '') v = props['value'] try: v = int(v) except: v = float(v) paras[k] = v return paras @app.callback(Output('in_sample_factor', 'children'), [ Input('AlphaButton', 'n_clicks'), Input('alpha_paras', 'children')]) def update_alpha_insample(n_clicks, alpha_paras): # some expensive clean data step # print(alpha_paras) paras = _get_alpha_parameter_from_div(alpha_paras) self.calculate_factor(self.alpha_func, **paras) in_sample_factor = self.factor # type: pd.Series # more generally, this line would be # json.dumps(cleaned_df) return in_sample_factor.to_json(orient='split') @app.callback(Output('out_sample_factor', 'children'), [ Input('AlphaButton', 'n_clicks'), Input('alpha_paras', 'children')]) def update_alpha_out_of_sample(n_clicks, alpha_paras): paras = _get_alpha_parameter_from_div(alpha_paras) self.calculate_factor(self.alpha_func, **paras) out_of_sample_factor = self.alpha_func(self.out_of_sample, **paras) # type: pd.Series # more generally, this line would be # json.dumps(cleaned_df) return out_of_sample_factor.to_json(orient='split') @app.callback([Output('forward_returns_period_saved', 'children'), Output("forward-returns-period", "children")], [Input("UpdateButton", "n_clicks")], [State("forwards-periods-input", "value")]) def update_forward_return(n_clicks, value): fr = list(set([int(p) for p in value.split(',')])) fr.sort() forward_str = str(fr).replace('[', '').replace(']', '') return json.dumps(fr), 'Forward return list: ' + forward_str @app.callback([ Output('distribution', 'figure'), Output('ic_heatmap', 'figure'), Output('qqplot', 'figure'), Output('price_factor', 'figure'), Output('factor-returns', 'figure'), Output('factor-backtest', 'figure'), Output('summary-table', 'children'), Output('ic-table', 'children'), Output('beta-table', 'children'), ], [Input("UpdateButton", "n_clicks"), Input('in-out-sample', 'value'), Input('forward_returns_period_saved', 'children'), Input('in_sample_factor', 'children'), Input('out_sample_factor', 'children'), ]) def update_forward_returns(n_clicks, value, forward_period, alpha_json, out_alpha_json): forward_returns_period = json.loads(forward_period) factor = pd.read_json(alpha_json, orient='split', typ='series') if value == 'In sample': update_distribution_figure = factor_distribution_plot(factor) returns = calculate_forward_returns(self.in_sample, forward_returns_period) ic_heatmap = get_monthly_ic(returns, factor, forward_returns_period) update_heatmap_figure = monthly_ic_heatmap_plot(ic_heatmap) update_qqplot_figure = qq_plot(factor) update_factor_plot_figure = price_factor_plot(self.in_sample, factor) factor_returns = calculate_ts_factor_returns(self.in_sample, factor, forward_returns_period) update_factor_plot_figure1 = returns_plot(factor_returns, self.factor_name) factor_returns = calculate_ts_factor_returns(self.in_sample, factor, forward_returns_period) cumulative_returns = calculate_cumulative_returns(factor_returns, 1) benchmark = self.in_sample['close'] / self.in_sample['close'][0] update_factor_plot_figure2 = cumulative_return_plot(cumulative_returns, benchmark=benchmark, factor_name=self.factor_name) # tables factor_table = pd_to_dash_table(factor_summary(factor), 'summary') ic_table = pd_to_dash_table(pd.DataFrame(calculate_ts_information_coefficient(factor, returns), columns=[self.factor_name]), 'ic') ols_table = pd_to_dash_table(factor_ols_regression(factor, returns), 'ols') return update_distribution_figure, update_heatmap_figure, \ update_qqplot_figure, update_factor_plot_figure, \ update_factor_plot_figure1, update_factor_plot_figure2, \ factor_table, ic_table, ols_table else: # out of sample的情况还没搞好 out_factor = pd.read_json(out_alpha_json, orient='split', typ='series') # update_distribution_figure = factor_distribution_plot(out_factor) returns = calculate_forward_returns(self.out_of_sample, forward_returns_period) ic_heatmap = get_monthly_ic(returns, out_factor, forward_returns_period) update_heatmap_figure = monthly_ic_heatmap_plot(ic_heatmap) # update_qqplot_figure = qq_plot(out_factor) update_factor_plot_figure = price_factor_plot(self.out_of_sample, out_factor) factor_returns = calculate_ts_factor_returns(self.out_of_sample, out_factor, forward_returns_period) update_factor_plot_figure1 = returns_plot(factor_returns, self.factor_name) factor_returns = calculate_ts_factor_returns(self.out_of_sample, out_factor, forward_returns_period) cumulative_returns = calculate_cumulative_returns(factor_returns, 1) benchmark = self.out_of_sample['close'] / self.out_of_sample['close'][0] update_factor_plot_figure2 = cumulative_return_plot(cumulative_returns, benchmark=benchmark, factor_name=self.factor_name) # for out of sample data onlye in_out_distplot = overlaid_factor_distribution_plot(factor, out_factor) inout_qqplot = observed_qq_plot(factor, out_factor) # inout_qqplot.show() factor_table = pd_to_dash_table(factor_summary(out_factor), 'summary') ic_table = pd_to_dash_table(pd.DataFrame(calculate_ts_information_coefficient(out_factor, returns), columns=[self.factor_name]), 'ic') ols_table = pd_to_dash_table(factor_ols_regression(out_factor, returns), 'ols') return in_out_distplot, update_heatmap_figure, \ inout_qqplot, update_factor_plot_figure, \ update_factor_plot_figure1, update_factor_plot_figure2, \ factor_table, ic_table, ols_table return app
# Main layout app.layout = html.Div([ html.H2(["News Articles Recommender and Analyzer"], className="padded"), dcc.Textarea( value="trump White House government", # placeholder = "Enter text / article here...", style={'width': '100%'}, id='input-1-state'), html.Button(id='submit-button', n_clicks=0, children='Submit'), html.Div([ html.Div([ html.H6(["Recommended Articles"], className="gs-header gs-table-header padded"), html.Table(make_dash_table(pd.DataFrame(np.asarray([])))) ], id="recommended_articles", className="six columns"), html.Div([], id="wc_image", className="six columns") ], className="row "), html.Div([ html.Div([ html.H6(["Article Sentiment"], className="gs-header gs-table-header padded"), html.Table(make_dash_table(pd.DataFrame(np.asarray([])))) ], id='article_sentiment', className="six columns"), html.Div([
html.P(id='area_out'), html.Table([ html.Tr([ html.Td(['區域人口'], style={'width': table_head}), html.Td(id='output1') ]), html.Tr([ html.Td(['人口密度'], style={'width': table_head}), html.Td(id='output2') ]), html.Tr([ html.Td(['公車站牌數'], style={'width': table_head}), html.Td(id='output3') ]), html.Tr([ html.Td(['捷運站數'], style={'width': table_head}), html.Td(id='output4') ]), html.Tr([ html.Td(['區內醫院數'], style={'width': table_head}), html.Td(id='output5') ]), #hospitalCount html.Tr([ html.Td(['政府機關數'], style={'width': table_head}), html.Td(id='output6') ]), # govCount html.Tr([ html.Td(['人均年所得'], style={'width': table_head}), html.Td(id='output7') ]) ]) ],
import dash_core_components as dcc import dash_html_components as html from dash.dependencies import Output, Input external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] app = dash.Dash(__name__, external_stylesheets=external_stylesheets) app.layout = html.Div([ dcc.Input(id='num', type='number', value=5), html.Table([ html.Tr([html.Td(['x', html.Sup(2)]), html.Td(id='square')]), html.Tr([html.Td(['x', html.Sup(3)]), html.Td(id='cube')]), html.Tr([html.Td([2, html.Sup('x')]), html.Td(id='twos')]), html.Tr([html.Td([3, html.Sup('x')]), html.Td(id='threes')]), html.Tr([html.Td(['x', html.Sup('x')]), html.Td(id='x^x')]), ]) ]) @app.callback([ Output('square', 'children'), Output('cube', 'children'), Output('twos', 'children'), Output('threes', 'children'), Output('x^x', 'children') ], [Input('num', 'value')])
# Header for the first row html.Div(html.H2('Remote Sensing Surveillance Plan')), # Second row with options and summary table html.Div([ ###Dropdown menu html.Div([ html.Div('Select Coverage Level'), dcc.Dropdown( id='coverage_level', options=onLoad_coverage_level_option(), value='All' ) ],className='three columns'), # Summary table html.Div([ html.Table(id='rs-summary-table',) ], className='three columns', style={'width':'auto','align':'right','margin-left':'auto'}) ],className='row'), # Third row with scatter plot and pie create_pie_chart html.Div([ # Main graph html.Div([ dcc.Graph(id='rs-graph') ],className='seven columns'), # # Pie chart html.Div([ dcc.Graph(id='summary-pie-chart') ],className='five columns') ],className='row'), html.Div(
def create_layout(app): # Page layouts return html.Div( [ html.Div([Header(app)]), # page 1 html.Div( [ # Row 1 - Texto html.Div( [ html.Div( [ html.H5("Resumo do App"), html.Br([]), html.P( "\ Por meio dos dados abertos é disponibilizado pelo IBAMA uma base de registros de comunicação de acidentes ambientais. Aqui temos uma análise desses dados afim de encontrar informações relevantes e insights importantes sobre acidentes ambientais no Brasil.", style={"color": "#ffffff"}, className="row", ), ], className="product", ) ], className="row", ), # Row 2 - Resumo e Tipos Eventos html.Div( [ html.Div( [ html.H6( ["Resumo dos Acidentes"], className="subtitle padded" ), html.Table(make_dash_table(df_resumo)), html.P( [ "Um resumo geral de algumas informações que chamam atenção e podem ser relavantes. Podemos identificar o periodo dos registros, o total de registros, o estado com maior número de acidentes dentre outras informações." ], style={"color": "#7a7a7a"}, ), ], className="six columns", ), html.Div( [ html.H6( "Top 5 Tipos de Eventos", className="subtitle padded", ), dcc.Graph( id="graph-1", figure={ "data": [ go.Bar( y=df_tipo_evento['Quantidade'], x=df_tipo_evento['Tipo Evento'], marker={ "color": "#97151c", "line": { "color": "rgb(255, 255, 255)", "width": 2, }, }, name="Eventos", ), ], "layout": go.Layout( autosize=False, bargap=0.4, font={"family": "Raleway", "size": 10}, height=200, hovermode="closest", legend={ "x": -0.0228945952895, "y": -0.189563896463, "orientation": "h", "yanchor": "top", }, margin={ "r": 0, "t": 20, "b": 10, "l": 10, }, showlegend=True, title="", width=330, xaxis={ "autorange": True, #"range": [-0.5, 2000], "showline": True, "title": "", "type": "category", }, yaxis={ "autorange": False, "gridcolor": "rgba(127, 127, 127, 0.2)", "mirror": False, "nticks": 4, "range": [0, tipo_evento_max], "showgrid": True, "showline": True, "ticklen": 10, "ticks": "outside", "title": "", "type": "linear", "zeroline": False, "zerolinewidth": 4, }, ), }, config={"displayModeBar": False}, ), html.P( [ "Informações de quais são os tipos de acidentes mais comuns. Aqui já podemos ver que o tipo mais comum, não podemos identificar e ele corresponde a mais de 50% dos acidentes." ], style={"color": "#7a7a7a"}, ), ], className="six columns", ), ], className="row", style={"margin-bottom": "35px"}, ), # Row 3 - Instituições e Origens html.Div( [ html.Div( [ html.H6( "Top 5 Origens Acidentes", className="subtitle padded", ), dcc.Graph( id="graph-1", figure={ "data": [ go.Bar( x=df_origem['Origem'], y=df_origem['Quantidade'], marker={ "color": "#97151c", "line": { "color": "rgb(255, 255, 255)", "width": 2, }, }, name="Origens", ), ], "layout": go.Layout( autosize=False, bargap=0.4, font={"family": "Raleway", "size": 10}, height=200, hovermode="closest", legend={ "x": -0.0228945952895, "y": -0.189563896463, "orientation": "h", "yanchor": "top", }, margin={ "r": 0, "t": 20, "b": 10, "l": 10, }, showlegend=True, title="", width=330, xaxis={ "autorange": True, #"range": [-0.5, 2000], "showline": True, "title": "", "type": "category", }, yaxis={ "autorange": False, "gridcolor": "rgba(127, 127, 127, 0.2)", "mirror": False, "nticks": 4, "range": [0, origem_max], "showgrid": True, "showline": True, "ticklen": 10, "ticks": "outside", "title": "", "type": "linear", "zeroline": False, "zerolinewidth": 4, }, ), }, config={"displayModeBar": False}, ), html.P( [ "Na origem dos acidentes, o notável é que são as rodovias a mais comum das origens, revelando outros problemas do Brasil. Problemas de educação no trânsito, problemas nas estradas que são problemas não só para acidentes ambientais." ], style={"color": "#7a7a7a"}, ), ], className="six columns", ), html.Div( [ html.H6( ["Porcentagem Atuação das Principais Instituições"], className="subtitle padded" ), html.Table(make_dash_table(df_institiuicoes_atuando)), html.P( [ "Nas instituições fica um pensamento, por que em mais de 50% dos acidentes ambientais, não tem atuação de orgão oficiais do governo? Logo pensamos, será que a maioria dos acidentes ambientais os culpados não são punidos?" ], style={"color": "#7a7a7a"}, ), ], className="six columns", ), ], className="row", style={"margin-bottom": "35px"}, ), ], className="sub_page", ), ], className="page", )
html.Table( [html.Tr([html.Th(col) for col in comment_names])] + [ html.Tr([ html.Td( dcc.Input(id='increment', placeholder='Input Increment', value='', type='number', min=1, max=50, step=1, style={'width': 60})), html.Td( dcc.Input(id='size', value='', placeholder='Input Size', min=10000, max=1000000000, step=1, style={'width': 80})), html.Td( dcc.Dropdown(id='general', options=[{ 'label': o, 'value': o } for o in opt], value='', placeholder='Allow General Market?', style={'width': 100})), html.Td( dcc.Dropdown(id='stateIncl', options=[{ 'label': s, 'value': s } for s in usa], value='', placeholder='Select State', multi=True, style={'width': 100})), html.Td( dcc.Dropdown( id='stateExcl', # options=[ # {'label':s, 'value':s} # for s in states # ], value='', placeholder='Select State', multi=True, style={'width': 100})), html.Td( dcc.Dropdown(id='couponMin', options=[{ 'label': c, 'value': c } for c in coupon], value='', placeholder='Select Rating', style={'width': 100}), ), html.Td( dcc.Dropdown( id='couponMax', # options=[ # {'label':r, 'value':r} # for r in wells.keys() # ], value='', placeholder='Select Rating', style={'width': 100}), ), html.Td( dcc.Dropdown(id='maturityMin', options=[{ 'label': d, 'value': d } for d in years], value='', placeholder='Select Maturity', style={'width': 100}), ), html.Td( dcc.Dropdown( id='maturityMax', # options=[ # {'label':r, 'value':r} # for r in wells.keys() # ], value='', placeholder='Select Maturity', style={'width': 100}), ), html.Td( dcc.Dropdown(id='call', options=[{ 'label': d, 'value': d } for d in years], value='', placeholder='Call Date', style={ 'width': 100, 'margin': 'auto' })), html.Td( dcc.Dropdown(id='ratingMin', options=[{ 'label': r, 'value': r } for r in wells.keys()], value='', placeholder='Select Rating', style={'width': 100}), ), html.Td( dcc.Dropdown( id='ratingMax', # options=[ # {'label':r, 'value':r} # for r in ratings # ], placeholder='Select Rating', value='', style={'width': 100}), ), html.Td( dcc.DatePickerSingle(id='settledate', month_format='MMMM Y', placeholder='MMMM Y', date=dt.today(), min_date_allowed=dt.today(), max_date_allowed=dt.now() + relativedelta(years=50), style={'width': 100} # with_full_screen_portal=True )) ]) ], style={ 'grid-row': '3 / 8', 'width': '10px' }),
html.Table( [ html.Thead([ html.Tr(html.Th('Parameters',colSpan=2,style={'font-size':13, 'background-color':'rgb(220,220,220)', 'textAlign':'center', 'padding':5})) ], style={'height':'20px'}), html.Colgroup([ html.Col(style={'backgroundColor':'rgb(220,220,220)','width':100}), html.Col(style={'width':100}) ]), html.Tbody([ html.Tr([html.Th('RSI',style=th_style), html.Td(id='rsi-output',style=td_style)]), html.Tr([html.Th('Dose',style=th_style), html.Td(id='dose-output',style=td_style)]), html.Tr([html.Th('RxRSI',style=th_style),html.Td(id='rxdose-output',style=td_style)]), html.Tr([html.Th('GARD (Tx)',style=th_style),html.Td(id='gard-output',style=td_style)]), html.Tr(html.Th('Normal Tissue Doses',style={'textAlign':'center','fontSize':13,'padding':5},colSpan=2)), html.Tr([html.Th('Heart',style=th_style), html.Td(id='heart-dose-output',style=td_style)]), html.Tr([html.Th('Lung',style=th_style), html.Td(id='lung-dose-output',style=td_style)]), html.Tr([html.Th('Esophagus',style=th_style), html.Td(id='esoph-dose-output',style=td_style)]), html.Tr(html.Th('Outcomes',style={'textAlign':'center','fontSize':13,'padding':5},colSpan=2)), html.Tr([html.Th('1-yr pLC',style=th_style), html.Td(id='pefs-output-1',style=td_style)]), html.Tr([html.Th('2-yr pLC',style=th_style), html.Td(id='pefs-output-2',style=td_style)]), html.Tr([html.Th('5-yr pLC',style=th_style), html.Td(id='pefs-output-5',style=td_style)]) ]) ], style={'margin-top':10} )
), html.P(DRUG_DESCRIPTION, id="chem_desc"), ], className="chem__desc__container", ), ], className="one-third column", ), ], className="container card app__content bg-white", ), html.Div( [ html.Table( make_dash_table([STARTING_DRUG], df), id="table-element", className="table__container", ) ], className="container bg-white p-0", ), ], className="app__container", ), ]) def df_row_from_hover(hoverData): """ Returns row for hover point as a Pandas Series. """ global data_holder, dfs_tracker df = dfs_tracker['df']
app.layout = html.Div([ html.H3('智能理财助手Demo V0.1', style={'text-align': 'center'}), # html.H3('Removed the real text'), # html.Img(src="https://thumbnail0.baidupcs.com/thumbnail/096cf1a5ad6a41f39a41c6ae97cf3cd7?fid=3226213234-250528-223386035414277&time=1532073600&rt=sh&sign=FDTAER-DCb740ccc5511e5e8fedcff06b081203-Wfc0%2B%2FgW4G%2FIZLxND%2FoEGyE2MF8%3D&expires=8h&chkv=0&chkbd=0&chkpc=&dp-logid=4654344113923524678&dp-callid=0&size=c710_u400&quality=100&vuk=-&ft=video", style={'align': 'right'}), html.Div( [ html.Div( [ html.Table([ html.Tr([ # text input for user message html.Td([ dcc.Input( id='msg_input', value='你好', type='text') ], style={'valign': 'middle'}), # message to send user message to bot backend html.Td([ html.Button( 'Send', id='send_button', type='submit') ], style={'valign': 'middle'}) ]) ]) ], style={ 'width': '325px', 'margin': '0 auto' }), html.Br(), html.Div(id='conversation') ],
def select_bent_function(bentf_name, selected_database): try: conn = db.connect_to_database(selected_database) except IOError: return ['Cannot connect to database {}.'.format(selected_database)] if bentf_name is None: return [] bentf_c = db.cdb.select_classification_where_name(conn, bentf_name) bentf_path = os.path.join(output_dir, 'download') bentf_c.save_as_csv(bentf_path) with Capturing() as report: bentf_c.report() wc_matrix = bentf_c.weight_class_matrix wc_graph = dcc.Graph(figure=matrix_figure(wc_matrix), id='wc-graph') ci_matrix = bentf_c.bent_cayley_graph_index_matrix ci_graph = dcc.Graph(figure=matrix_figure(ci_matrix), id='ci-graph') di_matrix = bentf_c.dual_cayley_graph_index_matrix di_graph = dcc.Graph(figure=matrix_figure(di_matrix), id='di-graph') return [html.P(bentf_name + ':')] + [html.P(line) for line in report] + [ html.Table( # Header [ html.Tr([ html.Div([ html.Div( [html.B('Weight class matrix')], style={ 'textAlign': 'center', 'width': '33%', 'display': 'inline-block' }), html.Div( [html.B('Cayley graph index matrix')], style={ 'textAlign': 'center', 'width': '33%', 'display': 'inline-block' }), html.Div( [html.B('Dual Cayley graph index matrix')], style={ 'textAlign': 'center', 'width': '33%', 'display': 'inline-block' }) ], style={ 'width': '100%', 'display': 'inline-block' }) ]) ] + # Body [ html.Tr([ html.Div([ html.Div(wc_graph, style={ 'width': '33%', 'display': 'inline-block' }), html.Div(ci_graph, style={ 'width': '33%', 'display': 'inline-block' }), html.Div(di_graph, style={ 'width': '33%', 'display': 'inline-block' }) ], style={ 'width': '100%', 'display': 'inline-block' }) ]) ]) ]
def create_layout(app, ExpID, projectname=projectname): ### Read experiment specific learnings try: aim = dfrunmaster[dfrunmaster.ExpID == ExpID]['Description'].values[0] param = dfrunmaster[dfrunmaster.ExpID == ExpID]['Params'].values[0] param = ast.literal_eval(param) exppath = param['Artefacts'] dffeatobs = pd.read_csv(f"{exppath}/observations.csv") if os.path.exists(f"{exppath}/importance.csv"): imp = pd.read_csv(f"{exppath}/importance.csv") imp.columns = [i.lower() for i in imp.columns] imp = imp.groupby('feature', as_index=False).agg({'importance': 'sum'}) imp['importance'] = imp['importance'] / sum(imp['importance']) topfeatures = imp.sort_values(by='importance', ascending=False).head(10) topfeatures.sort_values(by='importance', ascending=True, inplace=True) except: return html.Div() return html.Div( [ html.Div([Header(app, projectname)]), html.Div( [ html.Div( [ html.Div( [ html.H6(f"Experiment{ExpID} : {aim}"), ], className="product", ) ], className="row", ), html.Div( [ html.Div( [ html.H6( f"Top 10 Features", className="subtitle padded", ), create_feature_imp_plot( topfeatures, "graph-4", topfeatures['importance'], "<b>Importance : %{x:.02f}") ], className="seven columns", ), html.Div( [ html.H6( "Observations from Features", className="subtitle padded", ), html.Table(make_dash_table(dffeatobs)), ], className="five columns", ), ], className="row ", ), ], className="sub_page", ), ], className="page", )
import dash_core_components as dcc import dash_html_components as html from app import app from dash.dependencies import Input, Output from pyrbn import RBN layout = html.Div(children=[ html.H1("RBN Explorer - multiple"), html.Div("Collective information about various RBN measurements"), html.Table([ html.Tr([ html.Td("n (min)"), html.Td(dcc.Input(id="rbn_n_min", type="number", value=5)), ]), html.Tr([ html.Td("n (max"), html.Td(dcc.Input(id="rbn_n_max", type="number", value=25)), ]), html.Tr([ html.Td("k"), html.Td(dcc.Input(id="rbn_k", type="number", value=2)), ]), ]), dcc.Graph(id="cycle-length", figure={}), ]) @app.callback( [Output("cycle-length", "figure")], [ Input("rbn_n_min", "value"), Input("rbn_n_max", "value"),
html.Table([ html.Tr([ html.Td([ html.Div([ html.Div([ html. H6("Please feel free to reach out directly to us at [email protected] or use the submission form directly to the right of this page. Alternatively, you can write directly to us at the address below. We look forward to hearing from you." ) ], style={ 'width': "100%", "padding": "20px" }), html.Div([ html.Div([ html.P("Name"), dcc.Input(placeholder="Name", type="text", value="", id="contactUs_Name", style={'width': '80%'}, className="form-control"), ], style={'padding': "15px"}), html.Div([ html.P("Email"), dcc.Input(placeholder="Email", type="text", value="", id="contactUs_Email", style={'width': '80%'}, className="form-control"), ], style={'padding': "15px"}), html.Div([ html.P("Message"), dcc.Textarea(placeholder="Message", value="", id="contactUs_Message", style={'width': '80%'}, className="form-control"), ], style={'padding': "15px"}), html.Div([ html.Button("Submit", id="contactUs_submit", className="btn btn-primary"), ], style={ 'padding': "15px", "align": "left" }), ], style={'width': "100%"}, className="form-group") ]), ], style={"width": "70%"}), html.Td([ html.Div([ html.Div([ html.P([ html.B("Houston"), ]), html.P([ "1322 Space Park Drive Suite A155 Houston, TX 77058-3400", ]), ]), html.Div([ html.P([ html.B("Phone:"), ]), html.P([ "+1 844-882-7437", ]), ]), html.Div([ html.P([ html.B("Email:"), ]), html.P([ "*****@*****.**", ]), ]), html.Div([ html.P([ html.B("Business Hours:"), ]), html.P([ "Weekdays: 9am to 5pm", ]), ]), html.Div([ html.P([ html.B("Web:"), ]), html.P([ "http://inveniamfunds.com", ]), ]), ], style={"width": "100%"}), ], style={ "width": "30%", "vertical-align": "top" }), ]), ], style={"width": "100%"}),
def get_new_issues(categories, start_date, end_date): if categories is None or categories == list(): categories = ["issue"] return html.Table([ html.Tr([ html.Td("Date of the issue", style={ "border": "1px solid black", "border-collapse": "collapse", "width": "10%", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }), html.Td("Comment containing the issue", style={ "border": "1px solid black", "border-collapse": "collapse", "width": "50%", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }), html. Td("Label of the issue (if no label the model predicted there is an issue but cannot define which one)", style={ "border": "1px solid black", "border-collapse": "collapse", "width": "40%", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }) ]) ] + [ html.Tr([ html.Td(issue_dic["date"], style={ "border": "1px solid black", "border-collapse": "collapse" }), html.Td(issue_dic["sentence"], style={ "border": "1px solid black", "border-collapse": "collapse" }), html.Td(dcc.Dropdown(id='issue_{}'.format(issue_dic["id"]), options=[{ 'label': i, 'value': i } for i in ISSUE_NAMES], multi=True, value=issue_dic["issues"]), style={ "border": "1px solid black", "border-collapse": "collapse" }) ]) for issue_dic in rebuild_issues(start_date, end_date) if set(issue_dic["issues"]) & set(categories) != set() ], style={ "border": "1px solid black", "border-collapse": "collapse" })
def test_inin011_multi_output(dash_duo): app = Dash(__name__) app.layout = html.Div([ html.Button("OUTPUT", id="output-btn"), html.Table([ html.Thead([html.Tr([html.Th("Output 1"), html.Th("Output 2")])]), html.Tbody( [html.Tr([html.Td(id="output1"), html.Td(id="output2")])]), ]), html.Div(id="output3"), html.Div(id="output4"), html.Div(id="output5"), ]) @app.callback( [Output("output1", "children"), Output("output2", "children")], [Input("output-btn", "n_clicks")], [State("output-btn", "n_clicks_timestamp")], ) def on_click(n_clicks, n_clicks_timestamp): if n_clicks is None: raise PreventUpdate return n_clicks, n_clicks_timestamp # Dummy callback for DuplicateCallbackOutput test. @app.callback(Output("output3", "children"), [Input("output-btn", "n_clicks")]) def dummy_callback(n_clicks): if n_clicks is None: raise PreventUpdate return "Output 3: {}".format(n_clicks) with pytest.raises(DuplicateCallbackOutput) as err: @app.callback(Output("output1", "children"), [Input("output-btn", "n_clicks")]) def on_click_duplicate(n_clicks): if n_clicks is None: raise PreventUpdate return "something else" pytest.fail("multi output can't be included in a single output") assert "output1" in err.value.args[0] with pytest.raises(DuplicateCallbackOutput) as err: @app.callback( [Output("output3", "children"), Output("output4", "children")], [Input("output-btn", "n_clicks")], ) def on_click_duplicate_multi(n_clicks): if n_clicks is None: raise PreventUpdate return "something else" pytest.fail("multi output cannot contain a used single output") assert "output3" in err.value.args[0] with pytest.raises(DuplicateCallbackOutput) as err: @app.callback( [Output("output5", "children"), Output("output5", "children")], [Input("output-btn", "n_clicks")], ) def on_click_same_output(n_clicks): return n_clicks pytest.fail("same output cannot be used twice in one callback") assert "output5" in err.value.args[0] with pytest.raises(DuplicateCallbackOutput) as err: @app.callback( [Output("output1", "children"), Output("output5", "children")], [Input("output-btn", "n_clicks")], ) def overlapping_multi_output(n_clicks): return n_clicks pytest.fail( "no part of an existing multi-output can be used in another") assert ("{'output1.children'}" in err.value.args[0] or "set(['output1.children'])" in err.value.args[0]) dash_duo.start_server(app) t = time.time() btn = dash_duo.find_element("#output-btn") btn.click() time.sleep(1) dash_duo.wait_for_text_to_equal("#output1", "1") assert int(dash_duo.find_element("#output2").text) > t
def train_backend_and_return_resume(clicks, model, cv): if clicks is None: clicks = 0 if clicks > 0: try: return html.Table([ html.Tr([ html.Td("Issue type", style={ "border": "1px solid black", "border-collapse": "collapse", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }), html.Td("Precision for 0", style={ "border": "1px solid black", "border-collapse": "collapse", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }), html.Td("Recall for 0", style={ "border": "1px solid black", "border-collapse": "collapse", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }), html.Td("F1 score for 0", style={ "border": "1px solid black", "border-collapse": "collapse", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }), html.Td("Total number of 0", style={ "border": "1px solid black", "border-collapse": "collapse", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }), html.Td("Precision for 1", style={ "border": "1px solid black", "border-collapse": "collapse", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }), html.Td("Recall for 1", style={ "border": "1px solid black", "border-collapse": "collapse", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }), html.Td("F1 score for 1", style={ "border": "1px solid black", "border-collapse": "collapse", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }), html.Td("Total number of 1", style={ "border": "1px solid black", "border-collapse": "collapse", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }) ]) ] + [ html.Tr([ html.Td(name, style={ "border": "1px solid black", "border-collapse": "collapse" }), html.Td(round(i[0], 2), style={ "border": "1px solid black", "border-collapse": "collapse" }), html.Td(round(j[0], 2), style={ "border": "1px solid black", "border-collapse": "collapse" }), html.Td(round(k[0], 2), style={ "border": "1px solid black", "border-collapse": "collapse" }), html.Td(round(s[0], 2), style={ "border": "1px solid black", "border-collapse": "collapse" }), html.Td(round(i[1], 2), style={ "border": "1px solid black", "border-collapse": "collapse" }), html.Td(round(j[1], 2), style={ "border": "1px solid black", "border-collapse": "collapse" }), html.Td(round(k[1], 2), style={ "border": "1px solid black", "border-collapse": "collapse" }), html.Td(round(s[1], 2), style={ "border": "1px solid black", "border-collapse": "collapse" }) ]) for name, (i, j, k, s) in backend.retrain(model=model, do_cv="cv" in cv) ]) except AssertionError: return html.Table([ html.Tr([ html.Td("Issue type", style={ "border": "1px solid black", "border-collapse": "collapse", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }), html.Td("Precision for 0", style={ "border": "1px solid black", "border-collapse": "collapse", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }), html.Td("Recall for 0", style={ "border": "1px solid black", "border-collapse": "collapse", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }), html.Td("F1 score for 0", style={ "border": "1px solid black", "border-collapse": "collapse", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }), html.Td("Total number of 0", style={ "border": "1px solid black", "border-collapse": "collapse", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }), html.Td("Precision for 1", style={ "border": "1px solid black", "border-collapse": "collapse", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }), html.Td("Recall for 1", style={ "border": "1px solid black", "border-collapse": "collapse", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }), html.Td("F1 score for 1", style={ "border": "1px solid black", "border-collapse": "collapse", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }), html.Td("Total number of 1", style={ "border": "1px solid black", "border-collapse": "collapse", 'background': '#D5ECF8', 'textAlign': 'center', 'color': colors['text'], 'font-family': 'Georgia' }) ]) ] + [ html.Tr([ html.Td(name), html.Td(round(i[0], 2), style={ "border": "1px solid black", "border-collapse": "collapse" }), html.Td(round(j[0], 2), style={ "border": "1px solid black", "border-collapse": "collapse" }), html.Td(round(k[0], 2), style={ "border": "1px solid black", "border-collapse": "collapse" }), html.Td(round(s[0], 2), style={ "border": "1px solid black", "border-collapse": "collapse" }), html.Td(round(i[1], 2), style={ "border": "1px solid black", "border-collapse": "collapse" }), html.Td(round(j[1], 2), style={ "border": "1px solid black", "border-collapse": "collapse" }), html.Td(round(k[1], 2), style={ "border": "1px solid black", "border-collapse": "collapse" }), html.Td(round(s[1], 2), style={ "border": "1px solid black", "border-collapse": "collapse" }) ]) for name, (i, j, k, s) in backend.retrain(model=model, do_cv="cv" in cv) ])
def generate_table(dataframe, max_rows=10): return html.Table( [html.Tr([html.Th(col, style={'overflow':'hidden'}) for col in dataframe.columns])]+ [html.Tr([ html.Td(dataframe.iloc[i][col]) for col in dataframe.columns]) for i in range(min(len(dataframe), max_rows))] )
def update_graph(term,n): global old_term if term == '' : term = old_term old_term = term conn = sqlite3.connect('twitter.db') # manage_data(conn) df = pd.read_sql("select * from sentiment where tweet like '%"+term+"%' order by unix desc limit 1000",conn) df['unix'] = pd.to_datetime(df['unix'],unit='ms') df.sort_values('unix',inplace=True) df.set_index('unix',inplace=True) df = df.iloc[-100:,:] tableData = df.iloc[-10:,:] positive = 0 negative = 0 neutral = 0 for senti in df['sentiment']: if senti > 0: positive += 1 if senti < 0: negative += 1 else: neutral += 1 df['smoothe_sentiment'] = df['sentiment'].rolling(int(len(df)/5)).mean() df = df.resample('2s').mean() df.dropna(inplace=True) X = df.index Y = df.smoothe_sentiment.values data = go.Scatter( x=list(X), y=list(Y), name = 'Scatter', mode = 'lines+markers' ) layout = go.Layout(xaxis = dict(range=[min(X),max(X)]), yaxis = dict(range=[min(Y),max(Y)]), margin=dict(l=40,r=20,b=20,t=60,pad=0), template = 'plotly_dark', hovermode='x') pie = go.Pie(values=[positive,negative,neutral], labels= ['Positive','Negative','Neutral'], text=['Positive','Negative','Neutral'], marker={'colors' :['green','red','blue']}, hole = 0.4) print(tableData.columns) return [{'data':[data],'layout':layout}, {'data':[pie],'layout':layout}, html.Table(className="responsive-table", children=[ html.Thead( html.Tr( children=[ html.Th(col.title()) for col in tableData.columns.values], style={'color':app_colors['text']} ) ), html.Tbody( [ html.Tr( children=[ html.Td(data) for data in d ], style={'color':app_colors['text'], 'background-color':quick_color(d[1])} ) for d in tableData.values.tolist()]) ] )]
html.Table( [ html.Tr([ html.Tr([ html.H4('Ingresar características de la sangre'), ]), html.Tr([ html.Td('Edad:'), html.Td([ dcc.Input(id="input-1", type="number", placeholder='Age', min=0, max=100) ]), html.Td(), html.Td('Anemia:'), html.Td([ dcc.Input(id="input-2", type="number", placeholder='Anemia') ]), ]), html.Tr([ html.Td('Creatina:'), html.Td([ dcc.Input(id="input-3", type="number", placeholder='Creatina') ]), html.Td(), html.Td('Diabetes:'), html.Td([ dcc.Input(id="input-4", type="number", placeholder='Diabetes') ]), ]), html.Tr([ html.Td('Ejection Fraction:'), html.Td([ dcc.Input(id="input-5", type="number", placeholder='Ejection Fraction') ]), html.Td(), html.Td('High blood pressure:'), html.Td([ dcc.Input(id="input-6", type="number", placeholder='High blood pressure') ]), ]), html.Tr([ html.Td('Platelets:'), html.Td([ dcc.Input(id="input-7", type="number", placeholder='Platelets') ]), html.Td(), html.Td('Serum creatinine:'), html.Td([ dcc.Input(id="input-8", type="number", placeholder='Serum creatinine') ]), ]), html.Tr([ html.Td('Serum sodium:'), html.Td([ dcc.Input(id="input-9", type="number", placeholder='Serum sodium') ]), html.Td(), html.Td('Sex:'), html.Td([ dcc.Input( id="input-10", type="text", placeholder="Sex") ]), ]), html.Tr([ html.Td('Smoking:'), html.Td([ dcc.Input(id="input-11", type="number", placeholder='Smoking', min=0, max=1) ]), html.Td(), html.Td('Time:'), html.Td([ dcc.Input(id="input-12", type="number", placeholder='Time') ]), ]), ]), ], style={ "display": "inline-block", 'width': '100%', "border-style": "dashed", "border-width": "1px", "color": "black", "margin-bottom": "0px" }),
strike_row22 = html.Td(children=[html.Div(id='strike-output')], style={ 'width': '20%', 'background-color': output_colors['background'], 'font-size': 20, 'textAlign': 'center', 'border': 'None', 'margin-right': '50px' }) strike_component = html.Div(children=[ html.Table( children=[ html.Tr(children=[strike_row11, strike_row12], style={'width': '100%'}), html.Tr(children=[strike_row21, strike_row22], style={'width': '100%'}) ], # table style style={'margin': '20px'}) ]) # strike_component = html.Div(children=[ # html.Table(children=[ # html.Tr(children=[strike_row11, strike_row12], style={'width': '100%'}), # ], # # table style # style={'margin': '10px'} # ), # # html.Table(children=[
dcc.Tab(label='Bollinger Bands', value='tab-6', style=tab_style, selected_style=tab_selected_style), ], style=tabs_styles, colors={ "border": "yellow", "primary": "red", "background": "orange" }), html.Div(id='graph-output'), html.Div(children=[html.H1(children="Data Table", # html for table style={ 'textAlign': 'center', "background": "yellow"}) ] ), html.Div(children=[html.Table(id='table'), html.Div(id='table-output')]), html.Div(children=[dcc.Markdown( # markdown " © 2019 [DCAICHARA](https://github.com/dc-aichara) All Rights Reserved.")], style={ 'textAlign': 'center', "background": "yellow"}), ], style={"background": "#000080"} ) @app.callback(Output('led-display', 'children'), [Input('dropdown', 'value')]) def display_price(coin): price = get_coin_price(coin) return daq.LEDDisplay(
def create_layout(app): # Page layouts return html.Div( [ html.Div([Header(app)]), # page 1 html.Div( [ # Row 3 html.Div( [ html.Div( [ html.H5("Analysis Summary"), html.Br([]), html.P( "\ The University of Virginia has laid out an ambitious 10-year plan to accelerate the University’s sustainability goals across operations, research, curriculum, accountability and engagement – a framework of stewardship and discovery. The 2020-30 UVA Sustainability Plan includes six goals that UVA’s Board of Visitors approved in December, when the University committed to pursuing carbon neutrality by 2030 in partnership with the College of William & Mary. The full 2030 Plan also outlines strategic actions for success and adds four new goals.", style={"color": "#ffffff"}, className="row", ), ], className="product", ) ], className="row", ), # Row 4 html.Div( [ html.Div( [ html.H6(["Quick Facts"], className="subtitle padded"), html.Table(make_dash_table(df_waste)), ], className="six columns", ), html.Div( [ html.H6( "Bar Graph", className="subtitle padded", ), dcc.Graph( id="graph-1", figure={ "data": [ go.Bar( x=[ "Factor 1", "Factor 2", "Factor 3", "Factor 4", "Factor 5", ], y=[ "21.67", "11.26", "15.62", "8.37", "11.11", ], marker={ "color": "#141E3C", "line": { "color": "rgb(255, 255, 255)", "width": 2, }, }, name="Group 1", ), go.Bar( x=[ "Factor 1", "Factor 2", "Factor 3", "Factor 4", "Factor 5", ], y=[ "21.83", "11.41", "15.79", "8.50", ], marker={ "color": "#dddddd", "line": { "color": "rgb(255, 255, 255)", "width": 2, }, }, name="Group 2", ), ], "layout": go.Layout( autosize=False, bargap=0.35, font={ "family": "Raleway", "size": 10 }, height=200, hovermode="closest", legend={ "x": -0.0228945952895, "y": -0.189563896463, "orientation": "h", "yanchor": "top", }, margin={ "r": 0, "t": 20, "b": 10, "l": 10, }, showlegend=True, title="", width=330, xaxis={ "autorange": True, "range": [-0.5, 4.5], "showline": True, "title": "", "type": "category", }, yaxis={ "autorange": True, "range": [0, 22.9789473684], "showgrid": True, "showline": True, "title": "", "type": "linear", "zeroline": False, }, ), }, config={"displayModeBar": False}, ), ], className="six columns", ), ], className="row", style={"margin-bottom": "35px"}, ), ], className="sub_page", ), ], className="page", )
'label': x, 'value': x } for x in dfc1], value='India'), html.Br(), html.Br(), html.Table([ html.Tbody([ html.Tr([ html.Td("No. of Movies till date"), html.Td([html.Div(id="val1")]) ]), html.Tr([ html.Td("No. of TV Shows till date"), html.Td([html.Div(id="val2")]) ]), html.Tr([ html.Td("Top Actor"), html.Td([html.Div(id="val3")]) ]), html.Tr([ html.Td("Top Director"), html.Td([html.Div(id="val4")]) ]) ]) ]) ]) ]) ]) ]), ])
tab1_content = html.Div([ dbc.Button(id='refresh-list', children='Refresh', color='primary'), html.Div(id='wordlist'), ]) tab2_content = html.Div([ dbc.Button('Refresh', id='refresh_test', color="primary", className="mr-1"), dbc.Button('Save Result', id='save_result', color="secondary", className="mr-1"), dbc.Label('123', id='msg_bar', className='mr-1'), html.Div(id='test_table', children=[html.Table([html.Tbody(id='practice_body')])]) ]) tab3_content = html.Div(dbc.Form([ dbc.FormGroup([ dbc.Label("字/Word", className="mr-2"), dbc.Input(id='input-word', type="text", placeholder=""), ], ), dbc.FormGroup([ dbc.Label("词/Phrase", className="mr-2"), dbc.Input(id='input-phrase', type="text", placeholder=""), ], ), dbc.FormGroup([ dbc.Label("句/Sentence", className="mr-2"), dbc.Input(id='input-sentence', type="text", placeholder=""), ], ),
def extractor__to_html_row(obj__value): print("\n#49 START extractor__to_html_row() \n") this_df = obj__value[0] list_of_rows = obj__value[1] n_row = 0 row_col_id = "" list_of_row_column_pair.clear() table_head = [] list_of_tr_item = [] list_of_rd_input = [] #// list_of_this_pair=[] # A Local Storage for cell x,y coordination for k in list_of_rows: listOf_cell = list_of_rows[n_row] list_of_row_radio_items = [] list_x1 = [] # print("\n -> extractor() --> for k in list_of_rows : ", n_row ,"\n") # print("\n -> extractor() --> for k in list_of_rows --> printing this_cell ", this_cell ,"\n") print("\n -> extractor()" " \n --> for k in list_of_rows") #===================== # DESC: Loops through each column-cells in a row: n_cell = 0 # n_cell -- column cell (left to right) for this_cell in listOf_cell: cell_index = this_cell[0] # L4-1 cell_index_x = cell_index[0] #L5-1 cell_index_y = cell_index[1] #L5-2 cell_value = this_cell[2] print( "\n -> extractor()", " \n --> for k in list_of_rows" "\n --> for this_cell in listOf_cell", this_cell, "\n") if this_cell[1] == False: bg_cell = "rgb(255, 179, 153)" row_col_id = str(cell_index_x) + "_" + str(n_cell) list_of_row_column_pair.append((cell_index_x, n_cell)) else: bg_cell = "white" list_x1_2 = [ html.Td(cell_value, style={'backgroundColor': bg_cell}) ] list_x1 = list_x1 + list_x1_2 n_cell = n_cell + 1 # END (for this_cell in listOf_cell) list_x3 = [ dcc.RadioItems(id='radioitem_' + str(row_col_id), options=[{ 'label': 'Ignore', 'value': 'ign' }, { 'label': 'Delete', 'value': 'del' }], value='ign', labelStyle={'display': 'inline-block'}), #// add_to_bt_itemlist(component_id, component_value) print("\n #16 \n"), list_of_radio_items_id.append('radioitem_' + str(row_col_id)), ] list_x4 = list_x1 + list_x3 list_of_row_radio_items = list_of_row_radio_items + list_x4 #list_x1_tup = tuple(list_x1) print("\n") list_x2 = [html.Tr(list_of_row_radio_items)] list_of_tr_item = list_of_tr_item + list_x2 print("\n test_3:") print(list_of_row_radio_items) print("\n") n_row = n_row + 1 print("\n test_2 \n") print(list_of_tr_item) print("\n") # DESCRIPTION: # Table -- with rows of value + option buttons html_table = html.Table( [html.Tr([html.Th(col) for col in this_df.columns])] + list_of_tr_item) html_output = html.Div( [html_table, html.Button('Apply', id='apply_btn')], ) L2_3 = obj__value[2] data_is_clean = L2_3[1] # DEBUG PRINT: print("\n extractor__to_html_row() #14 :") print("> data_is_clean = ", data_is_clean) if data_is_clean == True: html_output = html.Div(children="Data is valid and clean") # DEBUG PRINT: print("\n printing the object: \n") print(obj__value) print("\n printing the return: \n") print(html_table) print("\n") print("#49 END extractor__to_html_row()") return html_output
def dict2table(info_dict): # Body table_content = [] for k, v in info_dict.items(): table_content += [html.Tr([html.Td(str(k)), html.Td(str(v))])] return html.Table(table_content)
html.Table( style={'width': '100%'}, # Begin of Table children children=[ ####################################################################### # Begin of First Tr html.Tr( #Begin Tr children children=[ # Begin Th html.Th( style={'width': '30%'}, # Begin Th children children=[ html. H3('Cereals to consider for purchase based on rating level ' ) # End of Th children ] # End of Th - Notice a comma is placed here to separate the next Th ), # Begin of Th html.Th( style={'width': '70%'}, # Begin of Th children children=[ html.H3('All Details of Cereals') # End of Th children ] # End of Th ) # End of Tr children ] # End of First Tr - Notice a comma is placed here to separate the next Tr ), ######################################################################### # Begin of Second Tr html.Tr( #Begin Tr children children=[ # Begin Td html.Td( # Begin Td children children=[ # Display plot graph use data from dataframe df dcc.Graph( id='life-exp-vs-gdp', figure={ 'data': [ dict( x=df2['name'], y=df2['rating'], type='bar', ) ], 'layout': { 'title': 'Rating of different Cereals' } # End of 2nd Inner DIV }) # End of Td children ] # End of Td - Notice a comma is placed here to separate the next Th ), html.Td( # Begin of Td children children=[ # Execute custom generate_table function and display data # Use data from dataframe df2 generate_table(df) # End of Td children ] # End of Td ) # End of Tr children ] # End of Tr ) ######################################################################### #End of Table Children ] # End of First Table - Notice a comma is placed here to separate the next Table ),
step=1, value=u4, updatemode='drag', className="slider" ) ], className='graph-section'), html.Div(children=[ html.Table( [ html.Tr([html.Th(""), html.Th("تمکین"), html.Th("تمرد")]) ] + [ html.Tr([html.Td("تمکین"), html.Td(html.Span(id='u1-value', children=str(u4) + "," + str(u4))), html.Td(html.Span(id='u2-value', children=str(u2) + "," + str(u1)))]), html.Tr([html.Td("تمرد"), html.Td(html.Span(id='u3-value', children=str(u1) + "," + str(u2))), html.Td(html.Span(id='u4-value', children=str(u3) + "," + str(u3)))]) ] ), ], className="section") ],), html.Hr(style={'width': '100%'}, className='graph-section'), # _______________________________________________________ # گراف شبکه در نسل آخر html.Div(children=[ html.H3(children='''