This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
Streamlit, | |
StreamlitComponentBase, | |
withStreamlitConnection | |
} from "streamlit-component-lib"; | |
import { ReactNode} from "react"; | |
class MainComponent extends StreamlitComponentBase { | |
public render = (): ReactNode => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit.components.v1 as components | |
def weighted_path(conn, country): | |
country = country.drop([0]).reset_index(drop=True) | |
country = country.to_string(index=False) | |
_map_compoent = components.declare_component("United States", url="http://localhost:3000") | |
component_value=_map_compoent(name="weighted", key=country) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_chart(data): | |
bars = alt.Chart(data).mark_bar().encode( | |
x = alt.X('sum(score):Q', stack='zero'), | |
y = alt.Y('name:N', sort='-x'), | |
color = alt.Color('centrality'), | |
tooltip='score', | |
).properties( | |
width=1000 | |
) | |
return bars |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def combine_data(source, idx, res, cent_name): | |
for i in range(len(source)): | |
name = source.loc[i, 'name'] | |
score = source.loc[i, 'score'] | |
centrality = cent_name | |
res.loc[idx] = [name, score, centrality] | |
idx += 1 | |
return res, idx | |
def overall_chart(bc, cc, dc, pr): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pydeck as pdk | |
import streamlit as st | |
def set_map(data): | |
st.pydeck_chart(pdk.Deck( | |
map_style="mapbox://styles/mapbox/light-v9", | |
initial_view_state=pdk.data_utils.compute_view(data[['lng','lat']]), | |
tooltip={"text": "{Vertex_ID}\n{name}"}, | |
layers=[ | |
pdk.Layer( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def degreeCentrality(conn, country): | |
if (country == "None"): | |
return | |
params = "country=" + country | |
# conn.debug = True | |
res = conn.runInstalledQuery('dc_by_country', params=params, timeout=16000) | |
res = pd.DataFrame(res[0]["@@topScores"]) | |
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class Answer extends StatelessWidget { | |
final Function selectHandler; | |
final String answerText; | |
Answer(this.selectHandler, this.answerText); | |
@override | |
Widget build(BuildContext context) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/cupertino.dart'; | |
class Question extends StatelessWidget { | |
final String questionText; | |
Question(this.questionText) {} | |
@override | |
Widget build(BuildContext context) { | |
// container take full size of screen now |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
class Result extends StatelessWidget { | |
final int resultScore; | |
final Function resetHandler; | |
Result(this.resultScore, this.resetHandler); | |
String get resultPhrase { | |
String resultText; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import './question.dart'; | |
import './answer.dart'; | |
class Quiz extends StatelessWidget { | |
final List<Map<String, Object>> questions; | |
final int questionIndex; | |
final Function answerQuestion; |