def event_to_html(cls, midgame_section, number: int, event: ScenarioEvent): midgame_section += [ Div([ H6(number, style={ "position": "absolute", "font-size": "x-large", "color": "#861c21", "margin": "5px" }), Img(src="./assets/rule.png", className="d-flex", style={"max-width": "400px"}) ], className="d-flex justify-content-center align-items-center") ] midgame_section += cls.text_to_html(event.text) midgame_section += cls.create_html_section('Special Rules', event.special_rules) midgame_section += cls.create_html_section('Boss Special 1', event.boss_special_1) midgame_section += cls.create_html_section('Boss Special 2', event.boss_special_2) return midgame_section
def lerz_spectrograms(): return Col([ Row( Col([ H3('Spectrograms'), RefreshButton(btnid='lerz-refresh-spectrograms-btn') ], **dict(className='text-center'))), Row([ Col(Img(id='lerz-pensive-plot', src=''), size=5, **dict(className='offset-md-1')), Col(Img(id='lerz-ipensive-plot', src=''), size=5), ]) ], bp='md', size=12)
def create_global_banner_imgs(self): global_achievements = [ self.get_global_achievement(t) for t in self.global_achievements ] return [ Img(src=f'{ga.banner}', className="banners") for ga in global_achievements ]
def summit_tiltv(): return Col([ Row( Col([ H3('Tilt Vectors'), RefreshButton(btnid='kism-refresh-tiltv-btn') ], **dict(className='text-center'))), Row(Col(Img(id='kism-tiltv-plot', src='', width='100%'))) ])
def ash3d(): return Col([ Row( Col([H3('Ash3d'), RefreshButton(btnid='refresh-ash3d-btn')], **dict(className='text-center'))), Row(Col(Img(id='ash3d-img', src='', width='100%'))) ], size=5)
def lerz_helicorder(): return Col([ Row( Col([ H3('KLUD'), RefreshButton(btnid='lerz-refresh-helicorder-btn') ], **dict(className='text-center'))), Row(Col(Img(id='lerz-helicorder-plot', src='', width='100%'))) ])
def summit_helicorder(): return Col([ Row( Col([ H3('RIMD'), RefreshButton(btnid='kism-refresh-helicorder-btn') ], **dict(className='text-center'))), Row(Col(Img(id='kism-helicorder-plot', src='', width='100%'))) ])
def lerz_hypos(): return Col([ Row(Col(H3('Seismicity', style=dict(textAlign='center')))), Row([ Col(dcc.RadioItems(id='lerz-hypos-radio', options=[{ 'label': 'Time', 'value': 'T' }, { 'label': 'Depth', 'value': 'A' }], value='A'), bp='md', size=6, **dict(className='text-center')), Col(dcc.Dropdown(id='lerz-seismic-time-dropdown', options=[{ 'label': i.split('_')[1], 'value': PERIODS[i] } for i in sorted(list(PERIODS.keys()))], value=28800000, searchable=False, clearable=False), bp='md', size=2) ]), Row([ Col( Col([ Iframe(id='lerz-hypos-plot', srcDoc='', width='100%', height=400), Img(id='lerz-hypos-legend', src='', width='100%') ], bp='md', size=11, **dict(className='offset-md-1'))), Col( Col(DataTable( rows=[{}], columns=('date', 'lat', 'lon', 'depth', 'prefMag'), column_widths=[None, 125, 125, 75, 75], filterable=True, sortable=True, id='lerz-datatable-hypos'), bp='md', size=11)) ]) ], bp='md', size=12)
def card(img_src, title, text, btn_text, btn_href): body = Div([ Div([ Img(src=img_src, className='card-img-top', width='100%') ]), Div([ H5(title, className='card-title'), P(text, className='card-text') ], className='card-body'), Div([ dcc.Link(btn_text, href=btn_href, className='btn btn-primary', style={'color': 'white'}) ], className='card-footer') ], className='card') return body
def make_word_cloud(imagemaskurl, nwords, text, customstopwords): if imagemaskurl is not None and imagemaskurl != '': try: r = requests.get(imagemaskurl) b = r.content image_bytes = io.BytesIO(b) im = Image.open(image_bytes).convert('RGBA') canvas = Image.new('RGBA', im.size, (255, 255, 255, 255)) canvas.paste(im, mask=im) mask = np.array(canvas) width, height = im.size except: mask = None text = 'Invalid Image Mask!' else: mask = None from wordcloud import STOPWORDS STOPWORDS = list(STOPWORDS) for word in customstopwords: STOPWORDS.append(word) STOPWORDS.append(word + 's') STOPWORDS.append(word + "'s") cloud = WordCloud( width=width, height=height, mask=mask, background_color='white', ).generate(text) try: coloring = ImageColorGenerator(mask) cloud.recolor(color_func=coloring) except: pass image = cloud.to_image() byte_io = io.BytesIO() image.save(byte_io, 'PNG') byte_io.seek(0) data_uri = base64.b64encode(byte_io.getvalue()).decode('utf-8').replace( '\n', '') src = 'data:image/png;base64,{0}'.format(data_uri) x = np.array(list(cloud.words_.keys())) y = np.array(list(cloud.words_.values())) order = np.argsort(y)[::-1] x = x[order] y = y[order] trace = go.Bar(x=x, y=y) layout = go.Layout(title='Relative frequency of words') fig = go.Figure(data=[trace], layout=layout) children = [ Img(src=src, width=image.size[0], height=image.size[1], style={ 'maxWidth': '100%', 'height': 'auto', 'margin': '0 auto', 'display': 'block' }), ] return children
def make_word_cloud(imagemaskurl, relative_scaling, nwords, text, title, customstopwords, width, height, color, colormap, maxfont, minfont, scale): if imagemaskurl is not None and imagemaskurl != '': # imgstr = re.search(r'base64,(.*)', imagemask).group(1) try: if imagemaskurl.startswith('data:image'): imgstr = re.search(r'base64,(.*)', imagemask).group(1) b = base64.b64decode(imgstr) else: r = requests.get(imagemaskurl) b = r.content image_bytes = io.BytesIO(b) im = Image.open(image_bytes).convert('RGBA') canvas = Image.new('RGBA', im.size, (255, 255, 255, 255)) canvas.paste(im, mask=im) mask = np.array(canvas) width, height = im.size except: mask = None text = 'Invalid Image Mask!' else: mask = None from wordcloud import STOPWORDS STOPWORDS = list(STOPWORDS) for word in customstopwords: STOPWORDS.append(word) STOPWORDS.append(word + 's') STOPWORDS.append(word + "'s") if color == '': color = None cloud = WordCloud(width=width, height=height, mask=mask, background_color=color, stopwords=STOPWORDS, max_words=nwords, colormap=colormap, max_font_size=maxfont, min_font_size=minfont, random_state=42, scale=scale, mode='RGBA', relative_scaling=relative_scaling).generate(text) try: coloring = ImageColorGenerator(mask) cloud.recolor(color_func=coloring) except: pass image = cloud.to_image() byte_io = io.BytesIO() image.save(byte_io, 'PNG') byte_io.seek(0) data_uri = base64.b64encode(byte_io.getvalue()).decode('utf-8').replace('\n', '') src = 'data:image/png;base64,{0}'.format(data_uri) x = np.array(list(cloud.words_.keys())) y = np.array(list(cloud.words_.values())) order = np.argsort(y)[::-1] x = x[order] y = y[order] trace = go.Bar(x=x, y=y) layout = go.Layout(margin=go.Margin(l=10, r=00), title='Relative frequency of words/bigrams') fig = go.Figure(data=[trace], layout=layout) children = [ H2(title, className='card-title'), Img(src=src, width=image.size[0], height=image.size[1], style={'maxWidth': '100%', 'height': 'auto', 'margin': '0 auto', 'display': 'block'}), # Details([ # Summary('View Frequency Plot'), # dcc.Graph(id='word-freq', figure=fig, config={'displayModeBar': False}) # ]) ] return children
# Layout app.layout = Div( [ Div([Store(x + "-store-" + str(i)) for x in TAB_DICT.keys() for i in [1, 2]]), # header Div( Div( children=[ Span( "Using an ‘agent based model’ for data policy decision-making" ), Div( A( Img( src="/assets/basic-W-48px.png", height="80%", style={"align": "center"}, ), href="https://theodi.org", target="_blank", ), className="brandimage", ), ], className="insideheader", ), className="header", ), Div( Details( [
Div([ Div([ H1("Copy & Paste Word Cloud Generator", className='display-4'), Hr(), P('This is the copy & paste word cloud generator. Simply copy and paste the text into the box below.' ), ], className='container') ], className="jumbotron jumbotron-fluid"), Div([ Div([ Div('Text Field Wordcloud', className='card-header'), dcc.Loading(Div([ H2('', className='card-title'), Div([Img(src='', className='card-img-top', width='100%')], style={'height': 500}), ], className='card-body', id='text-field-wordcloud'), style={ 'paddingTop': 200, 'paddingBottom': 200 }, type='dot'), Div([ P('This is the text field word cloud generator. Simply copy and paste the text into the box below.' ), Div([ Div([ dcc.Textarea(id='text-field',
H5(title, className='card-title'), P(text, className='card-text') ], className='card-body'), Div([ dcc.Link(btn_text, href=btn_href, className='btn btn-primary', style={'color': 'white'}) ], className='card-footer') ], className='card') return body body = Div([ Div([ Div([ Div([ H1("Word Cloud World", className='display-4 text-center'), Img(src="/static/world.png", width="300", height="300", alt="", style={'display': 'block', 'margin': '0 auto'}) ], className=''), P("Welcome!", className="lead text-center"), Hr() ], className='container') ], className="jumbotron jumbotron-fluid", style={'background-image': '/static/world.png'}), Div([ P("""Welcome to Word Cloud World! Word clouds are a creative way to visually represent textual data. They allow you to see the most significant or frequent words used in any body of text. Here at Word Cloud World we have created automated apps to visualise Wikipedia articles or Song lyrics. You can also create your own word cloud by cutting and pasting text or by uploading a textfile! You can customize your word cloud by changing its colour, shape and size. """), H5('Some Inspiration'), Div([ card('/static/wiki-word-cloud.png',
def tracking_pixel_img(action_name="EC_Dash_Pixel"): url = f"https://matomo.everyonecounts.de/matomo.php?idsite=1&rec=1&action_name={action_name}" return Img(src=url, style={"border": 0}, alt="")
def modifier_card_to_html(self, card: str): return Img(src=f'./assets/attack-modifiers/monster/{card}.png')
'Inventory_Level':inventory_level_list }) return inventory_DF # UI layout - DASH app app.layout = Div([ H3('Inventory Management using Discrete Event Simulation created by Karthik Anumalasetty'), Div([A([Img( src='data:image/png;base64,{}'.format(linkedin_image.decode()), style={ 'height' : '4%', 'width' : '4%', 'float' : 'right', 'position' : 'relative', 'padding-top' : 0, 'padding-right' : 0 })], href="https://www.linkedin.com/in/karthikanumalasetty/", target="_blank", )]), Div([A([Img( src='data:image/jpg;base64,{}'.format(github_image.decode()), style={ 'height' : '8%', 'width' : '8%', 'float' : 'right', 'padding-top' : 0, 'padding-right' : 0 })], href="https://github.com/KKAnumalasetty/simulation-app-heroku", target="_blank", )]),
from dash_html_components import Iframe, Div, Script, A, Img img = Img(src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&MarketPlace=US&ASIN=B071ZTJWM7&ServiceVersion=20070822&ID=AsinImage&WS=1&Format=_SL250_&tag=1071a1-20", style={"margin":"0 auto", "display": "block"}) a = A(img, target="_blank", href="https://www.amazon.com/gp/product/B071ZTJWM7/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B071ZTJWM7&linkCode=as2&tag=1071a1-20&linkId=3ec0629eca960378dc9f3d5e4de50601") img2 = Img(src="//ir-na.amazon-adsystem.com/e/ir?t=1071a1-20&l=am2&o=1&a=B071ZTJWM7", width="1", height="1", alt="", style={"border": "none !important", "margin":"0px !important"}) amazonMusicProduct = Div([ a,img2 ]) img = Img(src="//ws-na.amazon-adsystem.com/widgets/q?_encoding=UTF8&MarketPlace=US&ASIN=B00N28818A&ServiceVersion=20070822&ID=AsinImage&WS=1&Format=_SL250_&tag=1071a1-20", style={"margin":"0 auto", "display": "block"}) a = A(img, target="_blank", href="https://www.amazon.com/gp/product/B00N28818A/ref=as_li_tl?ie=UTF8&camp=1789&creative=9325&creativeASIN=B00N28818A&linkCode=as2&tag=1071a1-20&linkId=188e6e60a5d7dc73a5b047453861d955") img2 = Img(src="//ir-na.amazon-adsystem.com/e/ir?t=1071a1-20&l=am2&o=1&a=B00N28818A", width="1", height="1", alt="", style={"border": "none !important", "margin":"0px !important"}) amazonPrimeVideoProduct = Div([ a,img2 ])
def to_html(self): return [Img(src=f'./assets/scenario_layouts/{self.id}.png', className="w-100")]
def makeRoot_ToolsBar(): _ = \ [ Col([ NavbarBrand( [ Img( src = 'assets/logo.gif', height = '36px', width = '144px', className = 'nop nom' ), ], className = 'nop nom', ), ], className = 'dis nop', width = 2, ), Col([ Label('corporation'), Div(id = 'tools-corp-div', children = Dropdown( id = 'tools-corp', placeholder = 'Select Corporation', options = [{'label' : f'{k} ({v})', 'value' : k} for k, v in data['hdict'].items()], value = 'Apple', searchable = True) ), Tooltip( children = 'Select Corporation to See Stock Market Performance and M & A History', id = 'tools-corp-tip', target = 'tools-corp-div', placement = 'right') ], className = 'dis nop r1p', width = 2, ), Col([ makeRoot_MandABar(), makeRoot_RisksBar() ], className = 'nop r1p', width = 6, ), Col([ Label('current view'), DropdownMenu( [ DropdownMenuItem('Mergers & Acquisitions', id = 'manda-pick'), DropdownMenuItem('Corporate Global Risks', id = 'risks-pick'), ], id = 'views-pick', label = 'Corporate Global Risks', color = 'primary', style = {'lineHeight' : '22px'}, className = '' ), Tooltip( children = 'Select Activity View', id = 'views-pick-tip', target = 'views-pick', placement = 'left') ], className = 'dis nop', width = 2 ) ] return Navbar(id='extra-bar', className='rounded v1m', children=Container(_, className='nom nop', fluid=True))