Continued Development on draft version of viz
This commit is contained in:
parent
b2315a3f2d
commit
951eadd5cd
93 changed files with 10856 additions and 73 deletions
|
|
@ -1,4 +1,5 @@
|
|||
var score_timeseries = document.getElementById('timeseries');
|
||||
var mil = d3.format('$.3s')
|
||||
var data = {
|
||||
'size': {
|
||||
'height': 300
|
||||
|
|
@ -44,6 +45,7 @@ var data = {
|
|||
'axis': {
|
||||
'rotated': false,
|
||||
'x': {
|
||||
'type': 'timeseries',
|
||||
'tick': {
|
||||
'count': 10,
|
||||
'values': false,
|
||||
|
|
@ -61,12 +63,46 @@ var data = {
|
|||
'show': true
|
||||
}
|
||||
},
|
||||
'zoom': {}
|
||||
'zoom': {'enabled': true},
|
||||
'tooltip': {
|
||||
'contents': function (data)
|
||||
{
|
||||
var date = Date(data[0]['x'])
|
||||
var year = data[0]['x'].getYear()+1900
|
||||
var score = data[0].value
|
||||
var gross = mil(data[1].value)
|
||||
$('#year').html(year)
|
||||
$('#score').html(score)
|
||||
$('#gross').html(gross)
|
||||
update_words_year(year)
|
||||
t = data
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
word_coud_settings = {
|
||||
width: 500,
|
||||
height: 350,
|
||||
classPattern: null,
|
||||
colors: ['#bd0026', '#e31a1c', '#800026', '#fc4e2a', '#fd8d3c', '#feb24c', '#fed976'],// '#ffeda0', '#ffffcc'],
|
||||
fontSize: {
|
||||
from: 0.1,
|
||||
to: 0.02
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
data['axis']['y']['tick']['format'] = d3.format('$.3s')
|
||||
data['axis']['y2']['tick']['format'] = d3.format('.3s')
|
||||
data['bindto']='#timeseries-chart'
|
||||
|
||||
var _top = $('#top')
|
||||
var language = $('#language')
|
||||
var country = $('#country')
|
||||
var genre = $('#genre')
|
||||
var start_year = $('#start_year')
|
||||
var end_year = $('#end_year')
|
||||
|
||||
|
||||
$('#top').change(function(){update_all()})
|
||||
$('#language').change(function(){update_all()})
|
||||
|
|
@ -78,6 +114,7 @@ $('#end_year').change(function(){update_all()})
|
|||
jQuery(document).ready(function(){
|
||||
jQuery(".chosen").chosen();
|
||||
score_timeseries = c3.generate(data);
|
||||
$('#word_cloud').jQCloud([{'text':'pyDataVizDay', 'weight':1}], word_coud_settings)
|
||||
update_all()
|
||||
|
||||
});
|
||||
|
|
@ -87,61 +124,60 @@ function update_all(){
|
|||
update_ts()
|
||||
}
|
||||
|
||||
function update_ts(){
|
||||
var _top = $('#top').val()
|
||||
var language = $('#language').val()
|
||||
var country = $('#country').val()
|
||||
var genre = $('#genre').val()
|
||||
var start_year = $('#start_year').val()
|
||||
var end_year = $('#end_year').val()
|
||||
|
||||
url = '/api/score_timeseries?'
|
||||
|
||||
if (_top.length>0){url = url + 'top=' + _top + '&'}
|
||||
if (language.length>0){url = url + 'language=' + language + '&'}
|
||||
if (country.length>0){url = url + 'country=' + country + '&'}
|
||||
if (genre.length>0){url = url + 'genre=' + genre + '&'}
|
||||
if (start_year.length>0){url = url + 'start_year=' + start_year + '&'}
|
||||
if (end_year.length>0){url = url + 'end_year=' + end_year + '&'}
|
||||
function url_params(base)
|
||||
{
|
||||
var url = base
|
||||
if (_top.val().length>0){url = url + 'top=' + _top.val() + '&'}
|
||||
if (language.val().length>0){url = url + 'language=' + language.val() + '&'}
|
||||
if (country.val().length>0){url = url + 'country=' + country.val() + '&'}
|
||||
if (genre.val().length>0){url = url + 'genre=' + genre.val() + '&'}
|
||||
if (start_year.val().length>0){url = url + 'start_year=' + start_year.val() + '&'}
|
||||
if (end_year.val().length>0){url = url + 'end_year=' + end_year.val() + '&'}
|
||||
|
||||
return url
|
||||
}
|
||||
|
||||
function update_ts()
|
||||
{
|
||||
url = url_params('/api/score_timeseries?')
|
||||
score_timeseries.unload()
|
||||
var updatedData = $.get(url);
|
||||
updatedData.done(function(results){
|
||||
console.log(updatedData.responseJSON)
|
||||
updatedData.done(function(results)
|
||||
{
|
||||
score_timeseries.load(updatedData.responseJSON)
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function update_words(){
|
||||
var _top = $('#top').val()
|
||||
var language = $('#language').val()
|
||||
var country = $('#country').val()
|
||||
var genre = $('#genre').val()
|
||||
var start_year = $('#start_year').val()
|
||||
var end_year = $('#end_year').val()
|
||||
|
||||
url = '/api/keywords?'
|
||||
|
||||
if (_top.length>0){url = url + 'top=' + _top + '&'}
|
||||
if (language.length>0){url = url + 'language=' + language + '&'}
|
||||
if (country.length>0){url = url + 'country=' + country + '&'}
|
||||
if (genre.length>0){url = url + 'genre=' + genre + '&'}
|
||||
if (start_year.length>0){url = url + 'start_year=' + start_year + '&'}
|
||||
if (end_year.length>0){url = url + 'end_year=' + end_year + '&'}
|
||||
function update_words()
|
||||
{
|
||||
url = url_params('/api/keywords?')
|
||||
|
||||
var words = $.get(url)
|
||||
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
|
||||
}
|
||||
});
|
||||
words.done(function(data)
|
||||
{
|
||||
$('#word_cloud').jQCloud('update', words.responseJSON)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
function update_words_year(year)
|
||||
{
|
||||
|
||||
var url = '/api/keywords?start_year=' + String(parseInt(year) - 1) + '&end_year=' + String(parseInt(year) + 1) + '&'
|
||||
if (_top.val().length>0){url = url + 'top=' + _top.val() + '&'}
|
||||
if (language.val().length>0){url = url + 'language=' + language.val() + '&'}
|
||||
if (country.val().length>0){url = url + 'country=' + country.val() + '&'}
|
||||
if (genre.val().length>0){url = url + 'genre=' + genre.val() + '&'}
|
||||
|
||||
var words = $.get(url)
|
||||
words.done(function(data)
|
||||
{
|
||||
// $('#word_cloud').html('')
|
||||
$('#word_cloud').jQCloud('update', words.responseJSON);
|
||||
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue