added form

This commit is contained in:
walkews 2017-07-11 17:03:08 -05:00
parent 1b0d9bbe9d
commit 43ec7e5ca8
8 changed files with 307 additions and 4 deletions

View file

@ -41,12 +41,20 @@ parser.add_argument('color', help='"Color" or "Black and White"', required=False
data = etl.Data() data = etl.Data()
inputs = ['top', 'start_year', 'end_year']
dropdowns = {'genre': data.genre.genres.dropna().drop_duplicates().values.tolist(),
'country':data.movie.country.dropna().drop_duplicates().values.tolist(),
'language':data.movie.language.dropna().drop_duplicates().values.tolist()
}
@app.route('/') @app.route('/')
def index(): def index():
return render_template('index.html', body='Hello') return render_template('index.html', body='Hello')
@app.route('/investor') @app.route('/investor')
def investor(): def investor():
form = render_template('data_form.html', dropdowns=dropdowns, inputs=inputs)
top = 5 top = 5
top_countries = (data.movie.groupby('country') top_countries = (data.movie.groupby('country')
.sum()['budget'].sort_values(ascending=False) .sum()['budget'].sort_values(ascending=False)
@ -61,7 +69,7 @@ def investor():
title=f'Budget Trend for top {top} countries', title=f'Budget Trend for top {top} countries',
colors=pal.todays_outfit) colors=pal.todays_outfit)
return render_template('investor.html', body=c3_plot) return render_template('investor.html', body=form)
@app.route('/enthusiast') @app.route('/enthusiast')
def enthusiast(): def enthusiast():
@ -69,7 +77,8 @@ def enthusiast():
@app.route('/slides') @app.route('/slides')
def slides(): def slides():
slide_body = render_template('slide_body.html')
slide_body = render_template('slide_body.html', filters=filters)
return render_template('slides.html', body=slide_body) return render_template('slides.html', body=slide_body)
@api.route('/keywords') @api.route('/keywords')

View file

@ -7,7 +7,28 @@ body{
font-weight:10; font-weight:10;
} }
.chosen{ .text_input{
height:75px; height:75px;
width:75%; width:75%;
max-width: 300px;
} }
.chosen{
height:75px;
width:75%;
max-width: 300px;
}
.col-sm-3{
padding:5px;
}
.row{
padding:5px;
}
.text_input{
float:right;
height:30px;
width:70%;
}

View file

@ -0,0 +1,98 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>reveal.js The HTML Presentation Framework</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/black.css" id="theme">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/zenburn.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = window.location.search.match( /print-pdf/gi ) ? 'css/print/pdf.css' : 'css/print/paper.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<div class="reveal">
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section data-markdown data-separator="^\n----\n$" data-vertical="^\n-----\n$">
<script type="text/template">
# pyDataVizDay
*a python implementation for Data Viz Day*
![python](https://www.python.org/static/opengraph-icon-200x200.png)
----
# New Slide
``` python
import pandas as pd
l = [1, 2, 3]
for item in l:
print('this is an item from l')
print(l)
```
</script>
</section>
</div>
</div>
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// More info https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
history: true,
center: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// More info https://github.com/hakimel/reveal.js#dependencies
dependencies: [
{ src: 'lib/js/classList.js', condition: function() { return !document.body.classList; } },
{ src: 'plugin/markdown/marked.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/markdown/markdown.js', condition: function() { return !!document.querySelector( '[data-markdown]' ); } },
{ src: 'plugin/highlight/highlight.js', async: true, callback: function() { hljs.initHighlightingOnLoad(); } },
{ src: 'plugin/zoom-js/zoom.js', async: true },
{ src: 'plugin/notes/notes.js', async: true }
]
});
</script>
</body>
</html>

104
src/static/test_form.html Normal file
View file

@ -0,0 +1,104 @@
<!DOCTYPE html>
<html lang="en">
<head>
{% block head %}
<title>{% block title %}{% endblock %} - pyDataVizDay</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="node_modules/chosen-js/chosen.css">
<link href='https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.css' rel='stylesheet' type='text/css'/>
<link rel='stylesheet' type='text/css' href='css/custom.css'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="node_modules/chosen-js/chosen.jquery.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
{% endblock %}
</head>
<body>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
</button>
<a class="navbar-brand" href="/">pyDataVizDay</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
{% for href, id, caption in navigation_bar %}
<li{% if id == active_page %} class="active"{% endif%}>
<a href="{{ href|e }}">{{ caption|e }}</a></li>
{% endfor %}
</ul>
</div>
</div>
</nav>
<div class="container" padding:50px>
<div class="row" min-height:100px>
<div class="col-sm-4" padding:10px>
items:
<select id='items' class="chosen" multiple="true">
<option>jQuery</option>
<option selected="selected">MooTools</option>
<option>Prototype</option>
<option selected="selected">Dojo Toolkit</option>
</select>
</div>
<div class="col-sm-4" padding:10px>
items:
<select id='items' class="chosen" multiple="true">
<option>jQuery</option>
<option selected="selected">MooTools</option>
<option>Prototype</option>
<option selected="selected">Dojo Toolkit</option>
</select>
</div>
<div class="col-sm-4" padding:10px>
items:
<select id='items' class="chosen" multiple="true">
<option>jQuery</option>
<option selected="selected">MooTools</option>
<option>Prototype</option>
<option selected="selected">Dojo Toolkit</option>
</select>
</div>
</div>
<div class="row" style="min-height:100px">
<div class="col-sm-6">
<p>KPI: <span class='kpi' id='kpi1'></span> things.</p>
</div>
<div class="col-sm-1">
1 of 3
</div>
<div class="col-sm-1">
1 of 3
</div>
</div>
</div>
{{ body | safe }}
</body>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery(".chosen").chosen();
update_kpi1()
});
$('#items').change(function(){
update_kpi1()
})
function update_kpi1(){
$('#kpi1').html($('#items').val())
}
</script>
</html>

View file

@ -0,0 +1,57 @@
<h2> Filter </h2>
<div class="container" padding:50px>
<div class="row" min-height:150px>
{% for input in inputs %}
<div class='col-sm-3'>
{{ input }}: <input type='text' class='text_input' id={{ input }} name='{{ input }}'>
</div>
{% endfor %}
</div>
<div class="row" min-height:150px>
{% for dropdown in dropdowns %}
<div class="col-sm-3">
{{ dropdown }}:
<select id={{ dropdown }} class="chosen" multiple="true">
{% for item in dropdowns[dropdown] %}
<option>{{ item }}</option>
{% endfor %}
</select>
</div>
{% endfor %}
</div>
</div>
</div>
<div id='word_cloud'></div>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery(".chosen").chosen();
update_words()
});
$('#top').change(function(){update_words()})
function update_words(){
var top = $('#top').val()
//+ '&language=' + language + '&country=' + country + '&genre=' + genre + '&end_year=' + end_year + ' &start_year=' + start_year
var words = $.get('http://localhost:5000/api/keywords?top=' + top)
words.done(function(data){
$('#word_cloud').html('')
$('#word_cloud').jQCloud(words.responseJSON, {
width: 500,
height: 350,
classPattern: null,
colors: ['#800026', '#bd0026', '#e31a1c', '#fc4e2a', '#fd8d3c', '#feb24c', '#fed976', '#ffeda0', '#ffffcc'],
fontSize: {
from: 0.1,
to: 0.02
}
});
})
}
</script>

View file

@ -4,7 +4,13 @@
{% block head %} {% block head %}
{{ super() }} {{ super() }}
<!-- Load d3.js and c3.js --> <!-- Load d3.js and c3.js -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqcloud/1.0.4/jqcloud.css">
<script src='http://d3js.org/d3.v3.min.js' charset='utf-8'></script> <script src='http://d3js.org/d3.v3.min.js' charset='utf-8'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.js'></script> <script src='http://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.js'></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="static/node_modules/chosen-js/chosen.css">
<script src="static/node_modules/chosen-js/chosen.jquery.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jqcloud/1.0.4/jqcloud-1.0.4.min.js'></script>
<link rel='stylesheet' type='text/css' href='static/css/custom.css'>
{% endblock %} {% endblock %}

View file

@ -4,7 +4,12 @@
{% block head %} {% block head %}
{{ super() }} {{ super() }}
<!-- Load d3.js and c3.js --> <!-- Load d3.js and c3.js -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jqcloud/1.0.4/jqcloud.css">
<script src='http://d3js.org/d3.v3.min.js' charset='utf-8'></script> <script src='http://d3js.org/d3.v3.min.js' charset='utf-8'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.js'></script> <script src='http://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.js'></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<link rel="stylesheet" href="static/node_modules/chosen-js/chosen.css">
<script src="static/node_modules/chosen-js/chosen.jquery.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jqcloud/1.0.4/jqcloud-1.0.4.min.js'></script>
<link rel='stylesheet' type='text/css' href='static/css/custom.css/'>
{% endblock %} {% endblock %}

View file

@ -10,6 +10,9 @@
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href='https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.css' rel='stylesheet' type='text/css'/> <link href='https://cdnjs.cloudflare.com/ajax/libs/c3/0.4.10/c3.min.css' rel='stylesheet' type='text/css'/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel='stylesheet' type='text/css' href='static/css/custom.css'>
{% endblock %} {% endblock %}
</head> </head>