Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dashboard][Study Progression] Add tooltip visualising of Total in line chart #8123

Merged
3 changes: 3 additions & 0 deletions modules/statistics/css/recruitment.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
background-color: #2FA4E7;
}

.c3-chart-line.c3-target.c3-target-Total{
display: none !important;
}
34 changes: 28 additions & 6 deletions modules/statistics/js/studyprogression.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,38 @@ $(document).ready(function() {
dataset.push(data.datasets[i].name);
processedData.push(dataset.concat(data.datasets[i].data));
}
var totals = new Array();
totals.push("Total");
for(var j=0; j<data.datasets[0].data.length; j++){
var total=0;
for(var i=0;i<data.datasets.length;i++){
total+=parseInt(data.datasets[i].data[j]);
}
totals.push(total);
}
processedData.push(totals);
return processedData;
}

function maxY(data){
var maxi=0;
for(var j=0; j<data.datasets[0].data.length; j++){
for(var i=0;i<data.datasets.length;i++){
maxi=Math.max(maxi,parseInt(data.datasets[i].data[j]));
}
}
return maxi;
}


// AJAX to get scan line chart data
$.ajax({
url: loris.BaseURL + '/statistics/charts/scans_bymonth',
type: 'get',
success: function(data) {
let lengendNames = [];
let legendNames = [];
for (let j=0; j<data.datasets.length; j++) {
lengendNames.push(data.datasets[j].name);
legendNames.push(data.datasets[j].name);
}
let scanLineData = formatLineData(data);
scanLineChart = c3.generate({
Expand All @@ -74,6 +94,7 @@ $(document).ready(function() {
}
},
y: {
max: maxY(data),
label: 'Scans'
}
},
Expand All @@ -87,7 +108,7 @@ $(document).ready(function() {
d3.select('.scanChartLegend')
.insert('div', '.scanChart')
.attr('class', 'legend')
.selectAll('div').data(lengendNames).enter()
.selectAll('div').data(legendNames).enter()
.append('div')
.attr('data-id', function(id) {
return id;
Expand Down Expand Up @@ -119,9 +140,9 @@ $(document).ready(function() {
url: loris.BaseURL + '/statistics/charts/siterecruitment_line',
type: 'get',
success: function(data) {
let lengendNames = [];
let legendNames = [];
for (let j=0; j<data.datasets.length; j++) {
lengendNames.push(data.datasets[j].name);
legendNames.push(data.datasets[j].name);
}
let recruitmentLineData = formatLineData(data);
recruitmentLineChart = c3.generate({
Expand All @@ -146,6 +167,7 @@ $(document).ready(function() {
}
},
y: {
max: maxY(data),
label: 'Candidates registered'
}
},
Expand All @@ -159,7 +181,7 @@ $(document).ready(function() {
d3.select('.recruitmentChartLegend')
.insert('div', '.recruitmentChart')
.attr('class', 'legend')
.selectAll('div').data(lengendNames).enter()
.selectAll('div').data(legendNames).enter()
.append('div')
.attr('data-id', function(id) {
return id;
Expand Down