adollbo commited on
Commit
dd30f5c
·
1 Parent(s): e8a8bfe

moved functions to utils file

Browse files
Files changed (1) hide show
  1. visual_components.py +0 -65
visual_components.py DELETED
@@ -1,65 +0,0 @@
1
- import streamlit.components.v1 as components
2
- import streamlit as st
3
- import pandas as pd
4
-
5
-
6
- def create_data_input_table(datapoint, col_names):
7
- st.subheader("Flagged Transaction:")
8
- data = datapoint.iloc[0].tolist()
9
- data[7:12] = [bool(value) for value in data[7:12]]
10
- df = pd.DataFrame({"Feature name": col_names, "Value": data })
11
- st.dataframe(df, hide_index=True, width=450, height=35*len(df)+38)
12
-
13
- # Create a function to generate a table
14
- def create_table(texts, values, title):
15
- # TODO: change color dataframe header -> tried many different options but none worked see below
16
- # header_style = '''s
17
- # <style>
18
- # th{
19
- # background-color: #00052D;
20
- # }
21
- # </style>
22
- # '''
23
- df = pd.DataFrame({"Feature Explanation": texts, 'Value': values})
24
- # df = df.style.set_properties(**{
25
- # 'selector': 'th',
26
- # 'props': [
27
- # ('background-color', 'black'),``
28
- # ('color', 'cyan')]
29
- # })
30
- # df = df.style.set_properties(**{'background-color': 'black',
31
- # 'color': 'green'})
32
-
33
- st.markdown(f'#### {title}') # Markdown for styling
34
- # headers = {
35
- # 'selector': 'th',
36
- # 'props': 'background-color' '#67c5a4'#'background-color: #000066; color: white;'
37
- # }
38
- header = {
39
- 'selector': 'th',
40
- 'props': 'background-color: #000066; color: white;'
41
- }
42
-
43
- # df = df.style.set_table_styles({
44
- # ('Feature Explanation', 'Value'): [{'selector': 'th', 'props': 'border-left: 1px solid white'},
45
- # {'selector': 'td', 'props': 'border-left: 1px solid #000066'}]
46
- # }, axis=0)
47
- df = df.style.set_table_styles([header])
48
-
49
- # df.style.set_table_styles([headers])
50
- st.dataframe(df, hide_index=True, width=450) # Display a simple table
51
- # st.markdown(header_style, unsafe_allow_html=True)
52
-
53
- def ChangeButtonColour(widget_label, font_color, background_color='transparent'):
54
- htmlstr = f"""
55
- <script>
56
- var elements = window.parent.document.querySelectorAll('button');
57
- for (var i = 0; i < elements.length; ++i) {{
58
- if (elements[i].innerText == '{widget_label}') {{
59
- elements[i].style.color ='{font_color}';
60
- elements[i].style.background = '{background_color}'
61
- }}
62
- }}
63
- </script>
64
- """
65
- components.html(f"{htmlstr}", height=0, width=0)