From d87ffcc3be4238e787f574bd7fb936bd1f87abd2 Mon Sep 17 00:00:00 2001 From: cdtank Date: Wed, 30 Jun 2010 20:53:54 +0000 Subject: [PATCH] 1. Made changes to the sparkline logic to display last 10 years of activity (at the minimum). 2. Made changes to alter the text next to the sparklines to include the range of years considered. --- .../VisualizationCodeGenerator.java | 46 +++++++++++++++---- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/visualization/personpubcount/VisualizationCodeGenerator.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/visualization/personpubcount/VisualizationCodeGenerator.java index 7c198b817..27aa45652 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/visualization/personpubcount/VisualizationCodeGenerator.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/visualization/personpubcount/VisualizationCodeGenerator.java @@ -119,14 +119,30 @@ public class VisualizationCodeGenerator { if (yearToPublicationCount.size() > 0) { try { minPublishedYear = Integer.parseInt(Collections.min(publishedYears)); + System.out.println("min pub year - " + minPublishedYear); } catch (NoSuchElementException e1) { log.debug("vis: " + e1.getMessage() + " error occurred for " + yearToPublicationCount.toString()); } catch (NumberFormatException e2) { log.debug("vis: " + e2.getMessage() + " error occurred for " + yearToPublicationCount.toString()); } - numOfYearsToBeRendered = currentYear - minPublishedYear + 1; } + int minPubYearConsidered = 0; + + /* + * There might be a case that the author has made his first publication within the + * last 10 years but we want to make sure that the sparkline is representative of + * at least the last 10 years, so we will set the minPubYearConsidered to + * "currentYear - 10" which is also given by "shortSparkMinYear". + * */ + if (minPublishedYear > shortSparkMinYear) { + minPubYearConsidered = shortSparkMinYear; + } else { + minPubYearConsidered = minPublishedYear; + } + + numOfYearsToBeRendered = currentYear - minPubYearConsidered + 1; + visualizationCode.append("\n"); visualizationCode.append("