1. Improved bar graph DOM generation for temp vis.

This commit is contained in:
cdtank 2011-04-15 21:41:49 +00:00
parent 3c1afb45a0
commit c52e8362bc

View file

@ -703,41 +703,55 @@ function renderBarAndLabel(entity, divBar, divLabel, spanElement) {
var sum = combinedCount.knownYearCount + combinedCount.unknownYearCount;
var normalizedWidth = getNormalizedWidth(entity, sum);
var knownNormalizedWidth = getNormalizedWidth(entity, combinedCount.knownYearCount - combinedCount.currentYearCount);
if (combinedCount.unknownYearCount) {
var unknownNormalizedWidth = getNormalizedWidth(entity, combinedCount.unknownYearCount);
} else {
var unknownNormalizedWidth = 0;
}
if (combinedCount.currentYearCount) {
var currentNormalizedWidth = getNormalizedWidth(entity, combinedCount.currentYearCount);
} else {
var currentNormalizedWidth = 0;
}
divBar.css("width", normalizedWidth + 5);
divBar.children(".known-bar").html(" ").css("background-color", colorToAssign).css("width", knownNormalizedWidth);
divBar.children(".current-year-bar").html(" ").css("background-color", colorToAssign).css("width", currentNormalizedWidth);
divBar.children(".unknown-bar").children(".unknown-inner-bar").html(" ").css("background-color", colorToAssign).css("width", unknownNormalizedWidth);
if (combinedCount.knownYearCount - combinedCount.currentYearCount) {
var knownNormalizedWidth = getNormalizedWidth(entity, combinedCount.knownYearCount - combinedCount.currentYearCount);
var countExplanation = (combinedCount.knownYearCount - combinedCount.currentYearCount) + ' of '
+ sum + ' were ' + COMPARISON_PARAMETERS_INFO[currentParameter].verbName + " in a completed year";
divBar.children(".known-bar").attr("title", countExplanation);
countExplanation = combinedCount.currentYearCount + ' of '
divBar.children(".known-bar").html(" ").css("background-color", colorToAssign).css("width", knownNormalizedWidth);
} else {
divBar.children(".known-bar").hide();
}
if (combinedCount.unknownYearCount) {
var unknownNormalizedWidth = getNormalizedWidth(entity, combinedCount.unknownYearCount);
var countExplanation = combinedCount.unknownYearCount + ' of '
+ sum + ' have an unknown ' + COMPARISON_PARAMETERS_INFO[currentParameter].name + " year (not charted above)";
divBar.children(".unknown-bar").attr("title", countExplanation);
divBar.children(".unknown-bar").children(".unknown-inner-bar").html(" ").css("background-color", colorToAssign).css("width", unknownNormalizedWidth);
} else {
divBar.children(".unknown-bar").hide();
}
if (combinedCount.currentYearCount) {
var currentNormalizedWidth = getNormalizedWidth(entity, combinedCount.currentYearCount);
var countExplanation = combinedCount.currentYearCount + ' of '
+ sum + ' were ' + COMPARISON_PARAMETERS_INFO[currentParameter].verbName + ' in the current incomplete year (not charted above)';
divBar.children(".current-year-bar").attr("title", countExplanation);
countExplanation = combinedCount.unknownYearCount + ' of '
+ sum + ' have an unknown ' + COMPARISON_PARAMETERS_INFO[currentParameter].name + " year (not charted above)";
divBar.children(".current-year-bar").html(" ").css("background-color", colorToAssign).css("width", currentNormalizedWidth);
divBar.children(".unknown-bar").attr("title", countExplanation);
} else {
divBar.children(".current-year-bar").hide();
}
var entityLabelForLegend = divLabel.find(".entity-label-url");
entityLabelForLegend.html(entity.label);