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("