diff --git a/uvote/api/votes/bars.php b/uvote/api/votes/bars.php index 3755b42..4c7cc3d 100644 --- a/uvote/api/votes/bars.php +++ b/uvote/api/votes/bars.php @@ -49,7 +49,7 @@ class bars{ sum(case when uvote_data.choice != uvote_votes_per_party.choice then 1 else 0 end) class_MISSMATCH FROM uvote_data INNER JOIN uvote_votes_per_party ON uvote_data.poll_ID = uvote_votes_per_party.poll_ID - WHERE user_ID = ? AND uvote_data.choice = ? GROUP BY party;', + WHERE user_ID = ? AND uvote_votes_per_party.choice = ? GROUP BY party;', array(\SYSTEM\SECURITY\Security::getUser()->id, $choice)); $i = 0; while($row = $res->next()){ @@ -87,7 +87,7 @@ class bars{ sum(case when uvote_data.choice != uvote_votes.bt_choice then 1 else 0 end) class_MISSMATCH FROM uvote_data INNER JOIN uvote_votes ON uvote_data.poll_ID = uvote_votes.ID - WHERE user_ID = ? AND uvote_data.choice = ? GROUP by user_ID;', + WHERE user_ID = ? AND uvote_votes.bt_choice = ? GROUP by user_ID;', array(\SYSTEM\SECURITY\Security::getUser()->id, $choice)); $i = 0; diff --git a/uvote/api/votes/graphs.php b/uvote/api/votes/graphs.php index 12f2815..3032ebf 100644 --- a/uvote/api/votes/graphs.php +++ b/uvote/api/votes/graphs.php @@ -37,7 +37,7 @@ class graphs { public static function donut_party_to_user_overall ($returnasjson = true){ $result = array(); - $res = \SQL\UVOTE_DATA_USER_TO_PARTIES_OVERALL::QQ(array(13)); + $res = \SQL\UVOTE_DATA_USER_TO_PARTIES_OVERALL::QQ(array(\SYSTEM\SECURITY\Security::getUser()->id)); while ($row = $res->next()){ $result[] = array( 0 => $row['party'], 'class_match' => $row['class_MATCH']); diff --git a/uvote/page/default_page/js/loadtexts.js b/uvote/page/default_page/js/loadtexts.js index 99dc6d1..82396d4 100644 --- a/uvote/page/default_page/js/loadtexts.js +++ b/uvote/page/default_page/js/loadtexts.js @@ -144,7 +144,7 @@ function send_feedback (feedback) { var val = JSON.stringify(feedback); console.log("feedback called"); $.ajax({ - url: 'http://mojotrollz.eu/web/uVote/api.php', + url: './api.php', // contentType : "application/json; charset=utf-8", data : { 'call': 'vote', @@ -224,155 +224,3 @@ function loadApiPic(id) { }); } -function load_visualisation(id, timespan){ - $('img#loader').show(); - $.getJSON('./api.php?call=graph_bt_to_uvote_overall_by_time',function(json){ - if(!json || json.status != true || !json.result){ - $('img#loader').hide(); - return; - } - json = json.result; - $('img#loader').hide(); - var data = new google.visualization.DataTable(); - first = true; - $.each(json[0], function(key, value){ - if(first){ - data.addColumn('datetime',key); - first = false; - } else { - data.addColumn('number',key); - } - }); - $.each(json, function(key, value){ - first = true; - data.addRow($.map(value, function(v) { if(first){first=false;return [new Date(v)];}else{return [parseFloat(v)];}}));}); - - console.log(data); - var options = {title: 'Übereinstimmung uVote Community/Bundestag', aggregationTarget: 'category', selectionMode: 'multiple', /*curveType: 'function',*/ /*focusTarget: 'category',*/ chartArea:{}, vAxis:{format:'#%', logScale: false}, interpolateNulls: false, width: "300", height: "250"}; - //LineChart - new google.visualization.ColumnChart(document.getElementById(id)).draw(data, options); - }); -} -function load_visualisation_urvote(id, timespan){ - $('img#loader').show(); - $.getJSON('./api.php?call=graph_bt_to_user_overall_by_time',function(json){ - if(!json || json.status != true || !json.result){ - $('img#loader').hide(); - return; - } - json = json.result; - $('img#loader').hide(); - var data = new google.visualization.DataTable(); - first = true; - $.each(json[0], function(key, value){ - if(first){ - data.addColumn('datetime',key); - first = false; - } else { - data.addColumn('number',key); - } - }); - $.each(json, function(key, value){ - first = true; - data.addRow($.map(value, function(v) { if(first){first=false;return [new Date(v)];}else{return [parseFloat(v)];}}));}); - - var options = {title: id, aggregationTarget: 'category', selectionMode: 'multiple', curveType: 'function', /*focusTarget: 'category',*/ chartArea:{}, vAxis:{logScale: false}, interpolateNulls: false, width: "300", height: "250"}; - new google.visualization.LineChart(document.getElementById(id)).draw(data, options); - }); -} - -function load_visualisation_user_to_party_overall(id, party, timespan){ - $('img#loader').show(); - $.getJSON('./api.php?call=graph_party_to_user_overall_by_time&party=' + party,function(json){ - if(!json || json.status != true || !json.result){ - $('img#loader').hide(); - return; - } - json = json.result; - $('img#loader').hide(); - var data = new google.visualization.DataTable(); - first = true; - $.each(json[0], function(key, value){ - if(first){ - data.addColumn('datetime',key); - first = false; - } else { - data.addColumn('number',key); - } - }); - $.each(json, function(key, value){ - first = true; - data.addRow($.map(value, function(v) { if(first){first=false;return [new Date(v)];}else{return [parseFloat(v)];}}));}); - - - var options = { title: 'Übereinstimmung mit ' + party, - aggregationTarget: 'category', - selectionMode: 'multiple', - legend: 'none', - chartArea:{}, -// vAxis:{logScale: false}, - vAxis: {viewWindow: {min: 0, max: 100}}, - lineWidth: 7, - interpolateNulls: false, - width: "800", - height: "250"}; - new google.visualization.LineChart(document.getElementById(id)).draw(data, options); - }); -} -function load_visualisation_user_to_parties_overall(id, timespan){ - $('img#loader').show(); - $.getJSON('./api.php?call=donut_party_to_user_overall',function(json){ - if(!json || json.status != true || !json.result){ - $('img#loader').hide(); - return; - } - json = json.result; - $('img#loader').hide(); - var data = new google.visualization.DataTable(); - console.log(json); - first = true; - $.each(json[0], function(key, value){ - if(first){ - data.addColumn('string',key); - first = false; - } else { - data.addColumn('number',key); - } - }); - $.each(json, function(key, value){ - first = true; - data.addRow($.map(value, function(v) { if(first){first=false;return v;}else{return [parseFloat(v)];}}));}); - var options = { title: 'Übereinstimmung mit den Fraktionen relativ zueinander', - titleTextStyle: {fontSize: 14, bold: 0, italic: 0}, - pieSliceText: 'label', - legend: 'none', - colors: ['#000736', '#0022FF', '#33FF00', '#D2067A', '#F20101'], - pieHole: '0.4', - chartArea:{}, - width: "500", - height: "400"}; - new google.visualization.PieChart(document.getElementById(id)).draw(data, options); - }); -} -function load_visualisation_user(id, timespan){ -google.load("visualization", "1", {packages:["corechart"]}); - google.setOnLoadCallback(drawChart); - function drawChart() { - var data = google.visualization.arrayToDataTable([ - ['Task', 'Hours per Day'], - ['Work', 11], - ['Eat', 2], - ['Commute', 2], - ['Watch TV', 2], - ['Sleep', 7] - ]); - - var options = { - title: 'My Daily Activities', - pieHole: 0.4, - }; - - var chart = new google.visualization.PieChart(document.getElementById('donutchart')); - chart.draw(data, options); - } - } \ No newline at end of file diff --git a/uvote/page/user_main_analysis/js/user_main_analysis.js b/uvote/page/user_main_analysis/js/user_main_analysis.js index d83dc9e..dfed045 100644 --- a/uvote/page/user_main_analysis/js/user_main_analysis.js +++ b/uvote/page/user_main_analysis/js/user_main_analysis.js @@ -1,5 +1,139 @@ function init_user_main_analysis(){ +load_visualisation_user_to_party_overall('graph_user_to_party_overall_cdu', 'cdu', 84600); +load_visualisation_user_to_party_overall('graph_user_to_party_overall_csu', 'csu', 84600); +load_visualisation_user_to_party_overall('graph_user_to_party_overall_spd', 'spd', 84600); +load_visualisation_user_to_party_overall('graph_user_to_party_overall_gruene', 'gruene', 84600); +load_visualisation_user_to_party_overall('graph_user_to_party_overall_linke', 'linke', 84600); +load_visualisation_user_to_parties_overall('donut_user_to_party_overall', 84600); +} +function load_visualisation(id, timespan){ + $('img#loader').show(); + $.getJSON('./api.php?call=graph_bt_to_uvote_overall_by_time',function(json){ + if(!json || json.status != true || !json.result){ + $('img#loader').hide(); + return; + } + json = json.result; + $('img#loader').hide(); + var data = new google.visualization.DataTable(); + first = true; + $.each(json[0], function(key, value){ + if(first){ + data.addColumn('datetime',key); + first = false; + } else { + data.addColumn('number',key); + } + }); + $.each(json, function(key, value){ + first = true; + data.addRow($.map(value, function(v) { if(first){first=false;return [new Date(v)];}else{return [parseFloat(v)];}}));}); + + var options = {title: 'Übereinstimmung uVote Community/Bundestag', aggregationTarget: 'category', selectionMode: 'multiple', /*curveType: 'function',*/ /*focusTarget: 'category',*/ chartArea:{}, vAxis:{format:'#%', logScale: false}, interpolateNulls: false, width: "300", height: "250"}; + //LineChart + new google.visualization.ColumnChart(document.getElementById(id)).draw(data, options); + }); +} +function load_visualisation_urvote(id, timespan){ + $('img#loader').show(); + $.getJSON('./api.php?call=graph_bt_to_user_overall_by_time',function(json){ + if(!json || json.status != true || !json.result){ + $('img#loader').hide(); + return; + } + json = json.result; + $('img#loader').hide(); + var data = new google.visualization.DataTable(); + first = true; + $.each(json[0], function(key, value){ + if(first){ + data.addColumn('datetime',key); + first = false; + } else { + data.addColumn('number',key); + } + }); + $.each(json, function(key, value){ + first = true; + data.addRow($.map(value, function(v) { if(first){first=false;return [new Date(v)];}else{return [parseFloat(v)];}}));}); + + var options = {title: id, aggregationTarget: 'category', selectionMode: 'multiple', curveType: 'function', /*focusTarget: 'category',*/ chartArea:{}, vAxis:{logScale: false}, interpolateNulls: false, width: "300", height: "250"}; + new google.visualization.LineChart(document.getElementById(id)).draw(data, options); + }); +} + +function load_visualisation_user_to_party_overall(id, party, timespan){ + $('img#loader').show(); + $.getJSON('./api.php?call=graph_party_to_user_overall_by_time&party=' + party,function(json){ + if(!json || json.status != true || !json.result){ + $('img#loader').hide(); + return; + } + json = json.result; + $('img#loader').hide(); + var data = new google.visualization.DataTable(); + first = true; + $.each(json[0], function(key, value){ + if(first){ + data.addColumn('datetime',key); + first = false; + } else { + data.addColumn('number',key); + } + }); + $.each(json, function(key, value){ + first = true; + data.addRow($.map(value, function(v) { if(first){first=false;return [new Date(v)];}else{return [parseFloat(v)];}}));}); + + + var options = { title: 'Übereinstimmung mit ' + party, + aggregationTarget: 'category', + selectionMode: 'multiple', + legend: 'none', + chartArea:{}, +// vAxis:{logScale: false}, + vAxis: {viewWindow: {min: 0, max: 100}}, + lineWidth: 7, + interpolateNulls: false, + width: "800", + height: "250"}; + new google.visualization.LineChart(document.getElementById(id)).draw(data, options); + }); +} +function load_visualisation_user_to_parties_overall(id, timespan){ + $('img#loader').show(); + $.getJSON('./api.php?call=donut_party_to_user_overall',function(json){ + if(!json || json.status != true || !json.result){ + $('img#loader').hide(); + return; + } + json = json.result; + $('img#loader').hide(); + var data = new google.visualization.DataTable(); + first = true; + $.each(json[0], function(key, value){ + if(first){ + data.addColumn('string',key); + first = false; + } else { + data.addColumn('number',key); + } + }); + $.each(json, function(key, value){ + first = true; + data.addRow($.map(value, function(v) { if(first){first=false;return v;}else{return [parseFloat(v)];}}));}); + var options = { title: 'Übereinstimmung mit den Fraktionen relativ zueinander', + titleTextStyle: {fontSize: 14, bold: 0, italic: 0}, + pieSliceText: 'label', + legend: 'none', + colors: ['#000736', '#0022FF', '#33FF00', '#D2067A', '#F20101'], + pieHole: '0.4', + chartArea:{}, + width: "500", + height: "400"}; + new google.visualization.PieChart(document.getElementById(id)).draw(data, options); + }); } \ No newline at end of file diff --git a/uvote/page/user_main_analysis/tpl/user_main_analysis.tpl b/uvote/page/user_main_analysis/tpl/user_main_analysis.tpl index fcd08ae..610f073 100644 --- a/uvote/page/user_main_analysis/tpl/user_main_analysis.tpl +++ b/uvote/page/user_main_analysis/tpl/user_main_analysis.tpl @@ -25,13 +25,23 @@