Fixed bug in sentiment trending, if there was no data for the avg -> there was one NaN leading to no display in the gauge.

pull/68/head
Mokaddem 2016-08-20 18:48:24 +02:00
parent ee8f26c7c4
commit 841e87eb16
3 changed files with 6 additions and 6 deletions

View File

@ -509,7 +509,7 @@ def sentiment_analysis_getplotdata():
dateStart_timestamp = calendar.timegm(dateStart.timetuple()) dateStart_timestamp = calendar.timegm(dateStart.timetuple())
to_return = {} to_return = {}
range_providers = r_serv_charts.zrangebyscore('providers_set_'+ get_date_range(1)[1], '-inf', '+inf', start=0, num=8) range_providers = r_serv_charts.zrangebyscore('providers_set_'+ get_date_range(0)[0], '-inf', '+inf', start=0, num=8)
if range_providers == []: if range_providers == []:
print 'today provider empty' print 'today provider empty'
range_providers = r_serv_charts.smembers('all_provider_set') range_providers = r_serv_charts.smembers('all_provider_set')

View File

@ -42,7 +42,6 @@
$.getJSON("/sentiment_analysis_getplotdata/", $.getJSON("/sentiment_analysis_getplotdata/",
function(data) { function(data) {
console.log(data);
var all_data = []; var all_data = [];
var plot_data = []; var plot_data = [];
var graph_avg = []; var graph_avg = [];
@ -120,6 +119,8 @@ $.getJSON("/sentiment_analysis_getplotdata/",
all_graph_hour_maxVal = Math.abs(hour_sum) > all_graph_hour_maxVal ? Math.abs(hour_sum) : all_graph_hour_maxVal; all_graph_hour_maxVal = Math.abs(hour_sum) > all_graph_hour_maxVal ? Math.abs(hour_sum) : all_graph_hour_maxVal;
var curr_avg = curr_sum / (curr_sum_elem); var curr_avg = curr_sum / (curr_sum_elem);
if(isNaN(curr_avg))
curr_avg = 0.0
//var curr_avg = curr_sum / (oneWeek/oneHour); //var curr_avg = curr_sum / (oneWeek/oneHour);
//var curr_avg = curr_sum / (spark_data.length); //var curr_avg = curr_sum / (spark_data.length);
graph_avg.push([curr_provider, curr_avg]); graph_avg.push([curr_provider, curr_avg]);
@ -134,6 +135,7 @@ $.getJSON("/sentiment_analysis_getplotdata/",
// print week // print week
var num = graphNum + 1; var num = graphNum + 1;
var placeholder = '.sparkLineStatsWeek' + num; var placeholder = '.sparkLineStatsWeek' + num;
sparklineOptions.barWidth = 2;
$(placeholder).sparkline(plot_data[graphNum], sparklineOptions); $(placeholder).sparkline(plot_data[graphNum], sparklineOptions);
$(placeholder+'t').text(curr_provider); $(placeholder+'t').text(curr_provider);
var curr_avg_text = isNaN(curr_avg) ? "No data" : curr_avg.toFixed(5); var curr_avg_text = isNaN(curr_avg) ? "No data" : curr_avg.toFixed(5);
@ -143,7 +145,6 @@ $.getJSON("/sentiment_analysis_getplotdata/",
sparklineOptions.tooltipFormat = '<span style="color: {{color}}">&#9679;</span> Avg: {{value}} </span>' sparklineOptions.tooltipFormat = '<span style="color: {{color}}">&#9679;</span> Avg: {{value}} </span>'
$(placeholder+'b').sparkline([curr_avg], sparklineOptions); $(placeholder+'b').sparkline([curr_avg], sparklineOptions);
sparklineOptions.tooltipFormat = '<span style="color: {{color}}">&#9679;</span> {{offset:names}}, {{value}} </span>' sparklineOptions.tooltipFormat = '<span style="color: {{color}}">&#9679;</span> {{offset:names}}, {{value}} </span>'
sparklineOptions.barWidth = 2;
sparklineOptions.tooltipValueLookups = { names: offset_to_time}; sparklineOptions.tooltipValueLookups = { names: offset_to_time};
sparklineOptions.chartRangeMax = max_value_day; sparklineOptions.chartRangeMax = max_value_day;
@ -180,7 +181,6 @@ $.getJSON("/sentiment_analysis_getplotdata/",
all_day_avg_maxVal = Math.abs(day_avg) > all_day_avg_maxVal ? Math.abs(day_avg) : all_day_avg_maxVal; all_day_avg_maxVal = Math.abs(day_avg) > all_day_avg_maxVal ? Math.abs(day_avg) : all_day_avg_maxVal;
$(placeholder+'b').sparkline([day_avg], sparklineOptions); $(placeholder+'b').sparkline([day_avg], sparklineOptions);
sparklineOptions.tooltipFormat = '<span style="color: {{color}}">&#9679;</span> {{offset:names}}, {{value}} </span>' sparklineOptions.tooltipFormat = '<span style="color: {{color}}">&#9679;</span> {{offset:names}}, {{value}} </span>'
sparklineOptions.barWidth = 2;
$(placeholder+'s').text(day_avg_text); $(placeholder+'s').text(day_avg_text);
avgName = ".pannelToday" + num; avgName = ".pannelToday" + num;

View File

@ -21,12 +21,12 @@
.moodtable_worst { .moodtable_worst {
background: rgba(255, 0, 0, 0.47); background: rgba(255, 0, 0, 0.47);
font-size: unset; font-size: small;
} }
.moodtable_best { .moodtable_best {
background: rgba(132, 255, 0, 0.5); background: rgba(132, 255, 0, 0.5);
font-size: unset; font-size: small;
} }
.jqstooltip{ .jqstooltip{