Permalink
Browse files

charts use same feeling color as main vis

  • Loading branch information...
1 parent 9280708 commit d580af66d45a0903348c5582e970c12b53977075 @arturhoo committed Jul 14, 2012
Showing with 10 additions and 8 deletions.
  1. +4 −4 website/app.py
  2. +2 −2 website/static/js/charts.js
  3. +4 −2 website/static/js/pre_data_processing_for_charts.js
View
8 website/app.py
@@ -113,22 +113,22 @@ def hello():
feelings_percentages_last_hours = []
weather_conditions_count_for_feelings = []
feelings_percentages_and_mean_last_hours = []
- print feelings
if 'feeling' in request.args:
for feeling in request.args.getlist('feeling'):
+ feeling_color = get_feeling_color(feeling, feelings)
fplh = get_feeling_percentages_last_hours(db, feeling)
if len(request.args.getlist('feeling')) > 1:
- feelings_percentages_last_hours.append((feeling, fplh))
+ feelings_percentages_last_hours.append((feeling, fplh, feeling_color))
weather_conditions_count_for_feelings.append((feeling, get_weather_conditions_count_for_feeling(db, feeling, weather_translations)))
# Chart with mean
- feeling_color = get_feeling_color(feeling, feelings)
feelings_percentages_and_mean_last_hours.append((feeling, fplh, get_feeling_mean_percentages_for_hours(db, feeling, fplh[len(fplh) - 1][0]), feeling_color))
if not 'state' in request.args and not 'feeling' in request.args:
today_top_feelings = get_today_top_feelings(db)
for feeling in today_top_feelings[:5]:
+ feeling_color = get_feeling_color(feeling, feelings)
# dt = datetime.strptime('2012-07-06 06', '%Y-%m-%d %H')
- feelings_percentages_last_hours.append((feeling, get_feeling_percentages_last_hours(db, feeling)))
+ feelings_percentages_last_hours.append((feeling, get_feeling_percentages_last_hours(db, feeling), feeling_color))
for feeling in today_top_feelings[:10]:
weather_conditions_count_for_feelings.append((feeling, get_weather_conditions_count_for_feeling(db, feeling, weather_translations)))
View
4 website/static/js/charts.js
@@ -112,10 +112,10 @@ function cf_feelings_percentages_for_state(categories, dataset, state, container
});
}
-function cf_feelings_percentages_last_hours(categories, dataset, names, title, container) {
+function cf_feelings_percentages_last_hours(categories, dataset, names, colors, title, container) {
var new_series = [];
for(var i=0; i<names.length; i++) {
- new_series.push({name: names[i], data: dataset[i]});
+ new_series.push({name: names[i], data: dataset[i], color: colors[i]});
}
return new Highcharts.Chart({
chart: {
View
6 website/static/js/pre_data_processing_for_charts.js
@@ -39,6 +39,7 @@ function do_feelings_percentages_last_hours(feelings_percentages_last_hours) {
var dataset = [];
var names = [];
var categories = [];
+ var feelings_colors = [];
for(var i=0; i<feelings_percentages_last_hours.length; i++) {
entry = feelings_percentages_last_hours[i];
if(i === 0) {
@@ -48,6 +49,7 @@ function do_feelings_percentages_last_hours(feelings_percentages_last_hours) {
}
}
names.push(entry[0]);
+ feelings_colors.push(entry[2]);
data_entry = [];
for(var k=0; k<entry[1].length; k++) {
data = entry[1][k];
@@ -69,9 +71,9 @@ function do_feelings_percentages_last_hours(feelings_percentages_last_hours) {
}).appendTo('#stats');
var feelings_chart = null;
if (location.search.substring(1))
- feelings_chart = cf_feelings_percentages_last_hours(categories, dataset, names, 'Sentimentos escolhidos nas últimas 24 horas', 'feelings_chart_inner');
+ feelings_chart = cf_feelings_percentages_last_hours(categories, dataset, names, feelings_colors, 'Sentimentos escolhidos nas últimas 24 horas', 'feelings_chart_inner');
else
- feelings_chart = cf_feelings_percentages_last_hours(categories, dataset, names, 'Sentimentos mais frequentes nas últimas 24 horas', 'feelings_chart_inner');
+ feelings_chart = cf_feelings_percentages_last_hours(categories, dataset, names, feelings_colors, 'Sentimentos mais frequentes nas últimas 24 horas', 'feelings_chart_inner');
}
}

0 comments on commit d580af6

Please sign in to comment.