-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Wrap conducting data analysis js inside onload. (#70)
- Loading branch information
Showing
5 changed files
with
94 additions
and
84 deletions.
There are no files selected for viewing
166 changes: 84 additions & 82 deletions
166
parsifal/apps/reviews/conducting/static/js/conducting_data_analysis.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,92 @@ | ||
google.load('visualization', '1.0', {'packages':['corechart']}); | ||
google.setOnLoadCallback(drawChartCallback); | ||
$(function () { | ||
google.load('visualization', '1.0', {'packages':['corechart']}); | ||
google.setOnLoadCallback(drawChartCallback); | ||
|
||
function drawChartCallback() { | ||
drawChart(); | ||
drawYearLines(); | ||
} | ||
|
||
function drawPieChart(rows) { | ||
var data = new google.visualization.DataTable(); | ||
data.addColumn('string', 'Source'); | ||
data.addColumn('number', 'Number of Aticles'); | ||
data.addRows(rows); | ||
var options = {'height': 400}; | ||
var chart = new google.visualization.PieChart(document.getElementById('articles-selection-pie')); | ||
chart.draw(data, options); | ||
} | ||
|
||
function drawColumnChart(rows) { | ||
var data = google.visualization.arrayToDataTable(rows); | ||
var options = { | ||
vAxis: {title: 'Number of Articles', titleTextStyle: {color: '#3A3D40'}}, | ||
'height': 400 | ||
}; | ||
var chart = new google.visualization.ColumnChart(document.getElementById('articles-selection-column')); | ||
chart.draw(data, options); | ||
} | ||
function drawChartCallback() { | ||
drawChart(); | ||
drawYearLines(); | ||
} | ||
|
||
function drawLineChart(rows) { | ||
var data = google.visualization.arrayToDataTable(rows); | ||
var options = { | ||
vAxis: {title: 'Number of Articles', titleTextStyle: {color: '#3A3D40'}}, | ||
'height': 400 | ||
}; | ||
var chart = new google.visualization.LineChart(document.getElementById('articles-selection-line')); | ||
chart.draw(data, options); | ||
} | ||
function drawPieChart(rows) { | ||
var data = new google.visualization.DataTable(); | ||
data.addColumn('string', 'Source'); | ||
data.addColumn('number', 'Number of Articles'); | ||
data.addRows(rows); | ||
var options = {'height': 400}; | ||
var chart = new google.visualization.PieChart(document.getElementById('articles-selection-pie')); | ||
chart.draw(data, options); | ||
} | ||
|
||
function drawChart() { | ||
$.ajax({ | ||
url: '/reviews/conducting/articles_selection_chart/', | ||
data: {'review-id': $("#review-id").val()}, | ||
type: 'get', | ||
cache: false, | ||
beforeSend: function () { | ||
$("#articles-selection-pie").spinner(false); | ||
$("#articles-selection-column").spinner(false); | ||
}, | ||
success: function (data) { | ||
var source_data = data.split(","); | ||
var rows_pie = []; | ||
var rows_chart = [['Source', 'Selected', 'Accepted']]; | ||
for (var i = source_data.length - 1; i >= 0; i--) { | ||
row = source_data[i].split(":"); | ||
rows_pie.push([row[0], parseInt(row[1])]); | ||
rows_chart.push([row[0], parseInt(row[1]), parseInt(row[2])]); | ||
function drawColumnChart(rows) { | ||
var data = google.visualization.arrayToDataTable(rows); | ||
var options = { | ||
vAxis: {title: 'Number of Articles', titleTextStyle: {color: '#3A3D40'}}, | ||
'height': 400 | ||
}; | ||
drawPieChart(rows_pie); | ||
drawColumnChart(rows_chart); | ||
}, | ||
complete: function () { | ||
$("#articles-selection-pie").spinner(); | ||
$("#articles-selection-column").spinner(); | ||
var chart = new google.visualization.ColumnChart(document.getElementById('articles-selection-column')); | ||
chart.draw(data, options); | ||
} | ||
}); | ||
} | ||
|
||
function drawYearLines() { | ||
$.ajax({ | ||
url: '/reviews/conducting/articles_per_year/', | ||
data: {'review-id': $("#review-id").val()}, | ||
type: 'get', | ||
cache: false, | ||
beforeSend: function () { | ||
$("#articles-selection-line").spinner(false); | ||
}, | ||
success: function (data) { | ||
var source_data = data.split(","); | ||
var rows = [['Year', 'Number of Articles']]; | ||
for (var i = source_data.length - 1; i >= 0; i--) { | ||
row = source_data[i].split(":"); | ||
rows.push([row[0], parseInt(row[1])]); | ||
function drawLineChart(rows) { | ||
var data = google.visualization.arrayToDataTable(rows); | ||
var options = { | ||
vAxis: {title: 'Number of Articles', titleTextStyle: {color: '#3A3D40'}}, | ||
'height': 400 | ||
}; | ||
drawLineChart(rows); | ||
}, | ||
complete: function () { | ||
$("#articles-selection-line").spinner(); | ||
var chart = new google.visualization.LineChart(document.getElementById('articles-selection-line')); | ||
chart.draw(data, options); | ||
} | ||
|
||
function drawChart() { | ||
$.ajax({ | ||
url: '/reviews/conducting/articles_selection_chart/', | ||
data: {'review-id': $("#review-id").val()}, | ||
type: 'get', | ||
cache: false, | ||
beforeSend: function () { | ||
$("#articles-selection-pie").spinner(false); | ||
$("#articles-selection-column").spinner(false); | ||
}, | ||
success: function (data) { | ||
var source_data = data.split(","); | ||
var rows_pie = []; | ||
var rows_chart = [['Source', 'Selected', 'Accepted']]; | ||
for (var i = source_data.length - 1; i >= 0; i--) { | ||
row = source_data[i].split(":"); | ||
rows_pie.push([row[0], parseInt(row[1])]); | ||
rows_chart.push([row[0], parseInt(row[1]), parseInt(row[2])]); | ||
} | ||
drawPieChart(rows_pie); | ||
drawColumnChart(rows_chart); | ||
}, | ||
complete: function () { | ||
$("#articles-selection-pie").spinner(); | ||
$("#articles-selection-column").spinner(); | ||
} | ||
}); | ||
} | ||
|
||
function drawYearLines() { | ||
$.ajax({ | ||
url: '/reviews/conducting/articles_per_year/', | ||
data: {'review-id': $("#review-id").val()}, | ||
type: 'get', | ||
cache: false, | ||
beforeSend: function () { | ||
$("#articles-selection-line").spinner(false); | ||
}, | ||
success: function (data) { | ||
var source_data = data.split(","); | ||
var rows = [['Year', 'Number of Articles']]; | ||
for (var i = source_data.length - 1; i >= 0; i--) { | ||
row = source_data[i].split(":"); | ||
rows.push([row[0], parseInt(row[1])]); | ||
} | ||
drawLineChart(rows); | ||
}, | ||
complete: function () { | ||
$("#articles-selection-line").spinner(); | ||
} | ||
}); | ||
} | ||
}); | ||
} | ||
}); |
6 changes: 4 additions & 2 deletions
6
parsifal/apps/reviews/conducting/templates/conducting/conducting_data_analysis.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Fix data analysis load state for charts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,3 +22,7 @@ exclude = ''' | |
| migrations | ||
)/ | ||
''' | ||
|
||
[tool.towncrier] | ||
package = "parsifal" | ||
filename = "CHANGELOG.md" |