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 math | |
import numpy as np | |
import pandas as pd | |
from bokeh.embed import components | |
from bokeh.models import ColumnDataSource, HoverTool, PrintfTickFormatter | |
from bokeh.plotting import figure | |
from bokeh.transform import factor_cmap | |
from flask import Flask, render_template, request |
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
palette = ['#ba32a0', '#f85479', '#f8c260', '#00c2ba'] | |
chart_font = 'Helvetica' | |
chart_title_font_size = '16pt' | |
chart_title_alignment = 'center' | |
axis_label_size = '14pt' | |
axis_ticks_size = '12pt' | |
default_padding = 30 | |
chart_inner_left_padding = 0.015 | |
chart_font_style_title = 'bold italic' |
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
app = Flask(__name__) | |
@app.route('/') | |
def chart(): | |
return render_template('index.html') | |
if __name__ == '__main__': | |
app.run(debug=True) |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous"> | |
<link href="http://cdn.pydata.org/bokeh/release/bokeh-1.2.0.min.css" rel="stylesheet"> | |
<link href="http://cdn.pydata.org/bokeh/release/bokeh-widgets-1.2.0.min.css" rel="stylesheet"> | |
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
{% extends 'base.html' %} | |
{% block content %} | |
{% include 'navbar.html' %} | |
<div class="container"> | |
<div class="row mt-5"> | |
<div class="col-6"> | |
<p>Lorem ipsum dolor sit, amet consectetur adipisicing elit. Corporis provident ducimus incidunt dicta aliquam nesciunt quod laudantium tempore iusto ab veritatis, aperiam iste aspernatur quisquam consequuntur, accusamus ipsam magni perferendis ullam recusandae inventore? Cupiditate fugit recusandae reiciendis libero placeat esse saepe suscipit, sit eveniet ratione natus totam similique distinctio quas repudiandae ipsa excepturi sunt est nam molestias quibusdam dicta ab. Maiores provident reiciendis non porro ipsam vitae amet quas temporibus, molestiae odit laborum debitis voluptas quisquam esse ullam incidunt repellat ipsa quae sunt explicabo a? Perferendis, reprehenderit ab aspernatur id voluptatem explicabo cum reiciendis. Facere ipsam expedita, autem neque temporibus sequi impedit a ut nihil architecto! Numquam, excepturi a |
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
.submit-btn { | |
padding:8px 16px; | |
border-radius:4px; | |
margin-left:8px; | |
background-color:#ba32a0; | |
border:2px solid #fff; | |
color:#fff; | |
font-weight:bold; | |
transition: 0.2s; | |
} |
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 survived_bar_chart(dataset, pass_class, cpalette=palette[1:3]): | |
surv_data = dataset[dataset['Pclass'] == int(pass_class)] | |
surv_possibilities = list(surv_data['Survived'].value_counts().index) | |
surv_values = list(surv_data['Survived'].value_counts().values) | |
surv_possibilities_text = ['Did not Survive', 'Survived'] | |
source = ColumnDataSource(data={ | |
'possibilities': surv_possibilities, | |
'possibilities_txt': surv_possibilities_text, | |
'values': surv_values |
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 class_titles_bar_chart(dataset, pass_class, cpalette=palette): | |
ttl_data = dataset[dataset['Pclass'] == int(pass_class)] | |
title_possibilities = list(ttl_data['Title'].value_counts().index) | |
title_values = list(ttl_data['Title'].value_counts().values) | |
int_possibilities = np.arange(len(title_possibilities)) | |
source = ColumnDataSource(data={ | |
'titles': title_possibilities, | |
'titles_int': int_possibilities, | |
'values': title_values |
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 age_hist(dataset, pass_class, color=palette[1]): | |
hist, edges = np.histogram(dataset[dataset['Pclass'] == int(pass_class)]['Age'].fillna(df['Age'].mean()), bins=25) | |
source = ColumnDataSource({ | |
'hist': hist, | |
'edges_left': edges[:-1], | |
'edges_right': edges[1:] | |
}) | |
hover_tool = HoverTool( |
OlderNewer