1. Changes the logic for language to be displayed along with different sparklines in different cases. co-authorship & co-investigatorship is done.

This commit is contained in:
cdtank 2011-01-25 18:29:54 +00:00
parent acdf0981a4
commit 6abdc3a78e
2 changed files with 163 additions and 47 deletions

View file

@ -18,14 +18,20 @@
function drawCoauthorsSparklineVisualization(providedSparklineImgTD) { function drawCoauthorsSparklineVisualization(providedSparklineImgTD) {
var unknownYearPublicationCounts = ${sparklineVO.unknownYearPublications};
var onlyUnknownYearPublications = false;
var data = new google.visualization.DataTable(); var data = new google.visualization.DataTable();
data.addColumn('string', 'Year'); data.addColumn('string', 'Year');
data.addColumn('number', 'Unique co-authors'); data.addColumn('number', 'Unique co-authors');
data.addRows(${sparklineVO.yearToEntityCountDataTable?size}); data.addRows(${sparklineVO.yearToEntityCountDataTable?size});
var knownYearPublicationCounts = 0;
<#list sparklineVO.yearToEntityCountDataTable as yearToUniqueCoauthorsDataElement> <#list sparklineVO.yearToEntityCountDataTable as yearToUniqueCoauthorsDataElement>
data.setValue(${yearToUniqueCoauthorsDataElement.yearToEntityCounter}, 0, '${yearToUniqueCoauthorsDataElement.year}'); data.setValue(${yearToUniqueCoauthorsDataElement.yearToEntityCounter}, 0, '${yearToUniqueCoauthorsDataElement.year}');
data.setValue(${yearToUniqueCoauthorsDataElement.yearToEntityCounter}, 1, ${yearToUniqueCoauthorsDataElement.currentEntitiesCount}); data.setValue(${yearToUniqueCoauthorsDataElement.yearToEntityCounter}, 1, ${yearToUniqueCoauthorsDataElement.currentEntitiesCount});
knownYearPublicationCounts += ${yearToUniqueCoauthorsDataElement.currentEntitiesCount};
</#list> </#list>
<#-- Create a view of the data containing only the column pertaining to coauthors count. --> <#-- Create a view of the data containing only the column pertaining to coauthors count. -->
@ -55,6 +61,16 @@
chartLabel: 'r' chartLabel: 'r'
} }
/*
This means that all the publications have unknown years & we do not need to display
the sparkline.
*/
if (unknownYearPublicationCounts > 0 && knownYearPublicationCounts < 1) {
onlyUnknownYearPublications = true;
} else {
/* /*
Test if we want to go for the approach when serving visualizations from a secure site.. Test if we want to go for the approach when serving visualizations from a secure site..
If "https:" is not found in location.protocol then we do everything normally. If "https:" is not found in location.protocol then we do everything normally.
@ -107,6 +123,10 @@
} }
}
var totalPublicationCount = knownYearPublicationCounts + unknownYearPublicationCounts;
<#if sparklineVO.shortVisMode> <#if sparklineVO.shortVisMode>
<#-- We want to display how many coauthors were considered, so this is used to calculate this. --> <#-- We want to display how many coauthors were considered, so this is used to calculate this. -->
@ -117,10 +137,27 @@
renderedShortSparks += data.getValue(value, 1); renderedShortSparks += data.getValue(value, 1);
}); });
$('#${sparklineContainerID} td.sparkline_number').text(parseInt(renderedShortSparks) + parseInt(${sparklineVO.unknownYearPublications})).css("font-weight", "bold").attr("class", "grey").append("<span style='color: #2485AE;'> co-author(s) <br/></span>"); /*
In case that there are only unknown publications we want the text to mention these counts,
which would not be mentioned in the other case because the renderedShortSparks only hold counts
of publications which have any date associated with it.
*/
var totalPubs = onlyUnknownYearPublications ? unknownYearPublicationCounts : renderedShortSparks;
if (totalPubs === 1) {
var pubDisplay = "co-author";
} else {
var pubDisplay = "co-authors";
}
$('#${sparklineContainerID} td.sparkline_number').text(totalPubs).css("font-weight", "bold").attr("class", "grey").append("<span style='color: #2485AE;'> " + pubDisplay + " <br/></span>");
var sparksText = ' within the last 10 years'; var sparksText = ' within the last 10 years';
if (totalPubs !== totalPublicationCount) {
sparksText += ' (' + totalPublicationCount + ' total)';
}
<#else> <#else>
/* /*
@ -128,15 +165,36 @@
* any year associated with it. Hence. * any year associated with it. Hence.
* */ * */
var renderedSparks = ${sparklineVO.renderedSparks}; var renderedSparks = ${sparklineVO.renderedSparks};
$('#${sparklineContainerID} td.sparkline_number').text(parseInt(renderedSparks) + parseInt(${sparklineVO.unknownYearPublications})).css("font-weight", "bold").attr("class", "grey").append("<span style='color: #2485AE;'> co-author(s) <br/></span>");
/*
In case that there are only unknown publications we want the text to mention these counts,
which would not be mentioned in the other case because the renderedSparks only hold counts
of publications which have any date associated with it.
*/
var totalPubs = onlyUnknownYearPublications ? unknownYearPublicationCounts : renderedSparks;
if ( totalPubs == 1 ) {
var pubDisplay = "co-author";
} else {
var pubDisplay = "co-authors";
}
$('#${sparklineContainerID} td.sparkline_number').text(totalPubs).css("font-weight", "bold").attr("class", "grey").append("<span style='color: #2485AE;'> " + pubDisplay + " <br/></span>");
var sparksText = ' from <span class="sparkline_range">${sparklineVO.earliestYearConsidered?c}' var sparksText = ' from <span class="sparkline_range">${sparklineVO.earliestYearConsidered?c}'
+ ' to ${sparklineVO.latestRenderedPublicationYear?c}</span> ' + ' to ${sparklineVO.latestRenderedPublicationYear?c}</span>';
+ ' <br /><a href="${sparklineVO.downloadDataLink}">(.CSV File)</a> ';
if (totalPubs !== totalPublicationCount) {
sparksText += ' (' + totalPublicationCount + ' total)';
}
sparksText += ' <br /><a href="${sparklineVO.downloadDataLink}">(.CSV File)</a> ';
</#if> </#if>
if (!onlyUnknownYearPublications) {
$('#${sparklineContainerID} td.sparkline_text').html(sparksText); $('#${sparklineContainerID} td.sparkline_text').html(sparksText);
}
} }

View file

@ -18,14 +18,20 @@
function drawCoInvestigatorsSparklineVisualization(providedSparklineImgTD) { function drawCoInvestigatorsSparklineVisualization(providedSparklineImgTD) {
var unknownYearGrantCounts = ${sparklineVO.unknownYearGrants};
var onlyUnknownYearGrants = false;
var data = new google.visualization.DataTable(); var data = new google.visualization.DataTable();
data.addColumn('string', 'Year'); data.addColumn('string', 'Year');
data.addColumn('number', 'Unique co-investigators'); data.addColumn('number', 'Unique co-investigators');
data.addRows(${sparklineVO.yearToEntityCountDataTable?size}); data.addRows(${sparklineVO.yearToEntityCountDataTable?size});
var knownYearGrantCounts = 0;
<#list sparklineVO.yearToEntityCountDataTable as yearToUniqueCoinvestigatorsDataElement> <#list sparklineVO.yearToEntityCountDataTable as yearToUniqueCoinvestigatorsDataElement>
data.setValue(${yearToUniqueCoinvestigatorsDataElement.yearToEntityCounter}, 0, '${yearToUniqueCoinvestigatorsDataElement.year}'); data.setValue(${yearToUniqueCoinvestigatorsDataElement.yearToEntityCounter}, 0, '${yearToUniqueCoinvestigatorsDataElement.year}');
data.setValue(${yearToUniqueCoinvestigatorsDataElement.yearToEntityCounter}, 1, ${yearToUniqueCoinvestigatorsDataElement.currentEntitiesCount}); data.setValue(${yearToUniqueCoinvestigatorsDataElement.yearToEntityCounter}, 1, ${yearToUniqueCoinvestigatorsDataElement.currentEntitiesCount});
knownYearGrantCounts += ${yearToUniqueCoinvestigatorsDataElement.currentEntitiesCount};
</#list> </#list>
<#-- Create a view of the data containing only the column pertaining to coinvestigators count. --> <#-- Create a view of the data containing only the column pertaining to coinvestigators count. -->
@ -55,6 +61,16 @@
chartLabel: 'r' chartLabel: 'r'
} }
/*
This means that all the publications have unknown years & we do not need to display
the sparkline.
*/
if (unknownYearGrantCounts > 0 && knownYearGrantCounts < 1) {
onlyUnknownYearGrants = true;
} else {
/* /*
Test if we want to go for the approach when serving visualizations from a secure site.. Test if we want to go for the approach when serving visualizations from a secure site..
If "https:" is not found in location.protocol then we do everything normally. If "https:" is not found in location.protocol then we do everything normally.
@ -107,6 +123,9 @@
} }
}
var totalGrantCount = knownYearGrantCounts + unknownYearGrantCounts;
<#if sparklineVO.shortVisMode> <#if sparklineVO.shortVisMode>
@ -118,10 +137,28 @@
renderedShortSparks += data.getValue(value, 1); renderedShortSparks += data.getValue(value, 1);
}); });
$('#${sparklineContainerID} td.sparkline_number').text(parseInt(renderedShortSparks) + parseInt(${sparklineVO.unknownYearGrants})).css("font-weight", "bold").attr("class", "grey").append("<span style='color: #2485AE;'> co-investigator(s) <br/></span>"); /*
In case that there are only unknown grants we want the text to mention these counts,
which would not be mentioned in the other case because the renderedShortSparks only hold counts
of grants which have any date associated with it.
*/
var totalGrants = onlyUnknownYearGrants ? unknownYearGrantCounts : renderedShortSparks;
if (totalGrants === 1) {
var grantDisplay = "co-investigator";
} else {
var grantDisplay = "co-investigators";
}
$('#${sparklineContainerID} td.sparkline_number').text(totalGrants).css("font-weight", "bold").attr("class", "grey").append("<span style='color: #2485AE;'> " + grantDisplay + " <br/></span>");
var sparksText = ' within the last 10 years'; var sparksText = ' within the last 10 years';
if (totalGrants !== totalGrantCount) {
sparksText += ' (' + totalGrantCount + ' total)';
}
<#else> <#else>
/* /*
@ -129,14 +166,35 @@
* any year associated with it. Hence. * any year associated with it. Hence.
* */ * */
var renderedSparks = ${sparklineVO.renderedSparks}; var renderedSparks = ${sparklineVO.renderedSparks};
$('#${sparklineContainerID} td.sparkline_number').text(parseInt(renderedSparks) + parseInt(${sparklineVO.unknownYearGrants})).css("font-weight", "bold").attr("class", "grey").append("<span style='color: #2485AE;'> co-investigator(s) <br/></span>");
/*
In case that there are only unknown grants we want the text to mention these counts,
which would not be mentioned in the other case because the renderedSparks only hold counts
of grants which have any date associated with it.
*/
var totalGrants = onlyUnknownYearGrants ? unknownYearGrantCounts : renderedSparks;
if (totalGrants === 1) {
var grantDisplay = "co-investigator";
} else {
var grantDisplay = "co-investigators";
}
$('#${sparklineContainerID} td.sparkline_number').text(totalGrants).css("font-weight", "bold").attr("class", "grey").append("<span style='color: #2485AE;'> " + grantDisplay + " <br/></span>");
var sparksText = ' from <span class="sparkline_range">${sparklineVO.earliestYearConsidered?c}' var sparksText = ' from <span class="sparkline_range">${sparklineVO.earliestYearConsidered?c}'
+ ' to ${sparklineVO.latestRenderedGrantYear?c}</span> ' + ' to ${sparklineVO.latestRenderedGrantYear?c}</span>';
+ '<br /> <a href="${sparklineVO.downloadDataLink}">(.CSV File)</a> ';
if (totalGrants !== totalGrantCount) {
sparksText += ' (' + totalGrantCount + ' total)';
}
sparksText += '<br /> <a href="${sparklineVO.downloadDataLink}">(.CSV File)</a> ';
</#if> </#if>
if (!onlyUnknownYearGrants) {
$('#${sparklineContainerID} td.sparkline_text').html(sparksText).css("font-weight", "bold"); $('#${sparklineContainerID} td.sparkline_text').html(sparksText).css("font-weight", "bold");
}
} }