faizhalas commited on
Commit
bd2b349
·
verified ·
1 Parent(s): 91d31f2

Update Home.py

Browse files
Files changed (1) hide show
  1. Home.py +38 -4
Home.py CHANGED
@@ -5,6 +5,8 @@ import numpy as np
5
  import re
6
  from eldar import Query
7
  import altair as alt
 
 
8
 
9
 
10
 
@@ -236,17 +238,49 @@ try:
236
  st.pyplot(fig)
237
  st.write(" ")
238
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
 
240
 
241
  # layout
242
  col1, col2 = st.columns(2)
243
- with col1.container(border=True, gap="medium"):
244
  st.bar_chart(jrnl_counts_df, use_container_width=True, horizontal=True, width=500, height=500)
245
- with col2.container(border=True, gap="medium"):
246
  st.line_chart(year_counts_df, use_container_width=True, width=500, height=500)
247
- with col1.container(border=True, gap="medium"):
248
  st.altair_chart(chart_ins, use_container_width=True)
249
- with col2.container(border=True, gap="medium"):
250
  st.altair_chart(chart_aut, use_container_width=True)
251
 
252
 
 
5
  import re
6
  from eldar import Query
7
  import altair as alt
8
+ from itertools import combinations
9
+ from collections import Counter
10
 
11
 
12
 
 
238
  st.pyplot(fig)
239
  st.write(" ")
240
 
241
+
242
+ #heatmap institusi
243
+ pairs = []
244
+
245
+ for row in key_df_j["Institution"]:
246
+ cities = [c.strip() for c in row.replace(";", ",").split(",")]
247
+ for c1, c2 in combinations(cities, 2):
248
+ pairs.append(tuple(sorted([c1, c2])))
249
+
250
+ # Hitung frekuensi
251
+ counter = Counter(pairs)
252
+
253
+ # Ubah jadi DataFrame pasangan
254
+ df_pairs = pd.DataFrame(
255
+ [(c1, c2, count) for (c1, c2), count in counter.items()],
256
+ columns=["Institusi 1", "Institusi 2", "Jumlah"]
257
+ )
258
+
259
+ # Heatmap Altair
260
+ heatmap = (
261
+ alt.Chart(df_pairs)
262
+ .mark_rect()
263
+ .encode(
264
+ x=alt.X("Institusi 1:N", sort=None),
265
+ y=alt.Y("Institusi 2:N", sort=None),
266
+ color=alt.Color("Jumlah:Q", scale=alt.Scale(scheme="blues")),
267
+ tooltip=["Institusi 1", "Institusi 2", "Jumlah"]
268
+ )
269
+ )
270
+
271
+ st.altair_chart(heatmap, use_container_width=True)
272
+
273
 
274
 
275
  # layout
276
  col1, col2 = st.columns(2)
277
+ with col1.container(border=True, gap="medium", height=520):
278
  st.bar_chart(jrnl_counts_df, use_container_width=True, horizontal=True, width=500, height=500)
279
+ with col2.container(border=True, gap="medium", height=520):
280
  st.line_chart(year_counts_df, use_container_width=True, width=500, height=500)
281
+ with col1.container(border=True, gap="medium", height=520):
282
  st.altair_chart(chart_ins, use_container_width=True)
283
+ with col2.container(border=True, gap="medium", height=520):
284
  st.altair_chart(chart_aut, use_container_width=True)
285
 
286