Skip to content

Commit cb4e7e3

Browse files
committed
dev
1 parent 14e1922 commit cb4e7e3

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

.idea/misc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

streamlit_app_ar_toc.py

+24-9
Original file line numberDiff line numberDiff line change
@@ -82,21 +82,36 @@ def parse_netdata_url(url):
8282
df_chart_order = pd.DataFrame.from_dict(data_chart_order).transpose().reset_index()
8383
df_chart_order.columns = ['chart', 'priority', 'context']
8484
df_chart_order = df_chart_order[['context', 'chart', 'priority']].sort_values('priority')
85+
df_chart_order['menu'] = df_chart_order['context'].str.split('.').str[0]
8586

8687
#%%
8788

8889
weights_data = requests.get(url_weights).json()
8990

91+
#%%
92+
93+
df_menu_weights = pd.DataFrame(
94+
[(context.split('.')[0], weights_data['contexts'][context]['weight']) for context in weights_data['contexts']],
95+
columns=['menu', 'weight']
96+
)
97+
menu_weights_dict = df_menu_weights.groupby('menu').mean().to_dict(orient='index')
98+
99+
#%%
100+
90101
data = OrderedDict()
91-
for context in df_chart_order['context'].unique():
92-
context_key = f"{context}: {round(weights_data['contexts'][context]['weight'],2)}"
93-
data[context_key] = dict()
94-
for chart in df_chart_order[df_chart_order['context'] == context]['chart'].unique():
95-
chart_key = f"{chart}: {round(weights_data['contexts'][context]['charts'][chart]['weight'],2)}"
96-
data[context_key][chart_key] = dict()
97-
for dim in weights_data['contexts'][context]['charts'][chart]['dimensions']:
98-
dim_key = dim
99-
data[context_key][chart_key][dim_key] = round(weights_data['contexts'][context]['charts'][chart]['dimensions'][dim], 2)
102+
for menu in df_chart_order['menu'].unique():
103+
menu_key = f"{menu}: {round(menu_weights_dict[menu]['weight']*1,2)}%"
104+
data[menu_key] = dict()
105+
for context in df_chart_order['context'].unique():
106+
if context.startswith(menu):
107+
context_key = f"{context}: {round(weights_data['contexts'][context]['weight']*1,2)}%"
108+
data[menu_key][context_key] = dict()
109+
for chart in df_chart_order[df_chart_order['context'] == context]['chart'].unique():
110+
chart_key = f"{chart}: {round(weights_data['contexts'][context]['charts'][chart]['weight'],2)}%"
111+
data[menu_key][context_key][chart_key] = dict()
112+
for dim in weights_data['contexts'][context]['charts'][chart]['dimensions']:
113+
dim_key = dim
114+
data[menu_key][context_key][chart_key][dim_key] = f"{round(weights_data['contexts'][context]['charts'][chart]['dimensions'][dim]*1, 2)}%"
100115

101116
st.json(
102117
data,

0 commit comments

Comments
 (0)