Skip to content

Instantly share code, notes, and snippets.

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) {
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
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(
@Chico-Chen
Chico-Chen / overall_chart.py
Created April 1, 2021 01:15
graph centrality
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):
@Chico-Chen
Chico-Chen / set_chart.py
Created April 1, 2021 01:17
hackathon graph centrality
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
@Chico-Chen
Chico-Chen / weighted.py
Last active April 1, 2021 12:57
streamlit react
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)
import {
Streamlit,
StreamlitComponentBase,
withStreamlitConnection
} from "streamlit-component-lib";
import { ReactNode} from "react";
class MainComponent extends StreamlitComponentBase {
public render = (): ReactNode => {
const cred = {
'HOST': 'YOUR_HOST',
"PASSWORD": "YOUR_PASSWORD",
"SECRET": "SECRET",
"TOKEN": "TOKEN",
}
module.exports = cred;
const express = require('express'),
bodyParser = require('body-parser'),
port = process.env.port || 3030,
tgjs = require('tigergraph.js'),
cred = require('./config');
const app = express();
app.use(bodyParser.json());
app.use((req, res, next) => {
res.setHeader('Access-Control-Allow-Origin', "*");
import React, { useEffect, useRef, useState } from 'react';
import './Map.css';
interface IMap {
mapType: google.maps.MapTypeId,
mapTypeControl?: boolean,
countries: string[],
}
type GoolgeLatLng = google.maps.LatLng;