currently, if you have views_sparkline configured to show, say, two years worth of data, but only one year's worth of data gets returned by the view, the resulting sparkline stretches that data over the full time period of the dataset, which is an incorrect display.
there are perfectly valid reasons why less than a full set of data would be returned. in the case of project issue metrics, a project might only be a year old.
the easiest solution is to have the module examine the 'maximum items per page' setting of the view, and if less than that number of results is returned, then zero pad the data set before passing it off to the chart code.
a simple setting of pad left/pad right/don't pad would handle the most common cases of partial data. however, it would not handle, for example, a partial dataset that fell within the middle of the display range (eg. six months of no data, a year of data, six months of no data), this doesn't seem like as common of a case, and would be much more difficult to implement properly. i personally don't think that the module needs to handle any more than the basic cases.
Comments
Comment #1
mikey_p commentedConceptually the problem here is that we are using SQL (via views) to fill in the datapoints when SQL doesn't really work that way. The two scenarios here that could cause issues are the following:
Either of the first two scenarios could be handled by a setting in views_sparkline to "pad left" or "pad right" with NULL values to make sure that the correct time period is displayed on the plot. The confusing bit is that there could be a scenario where both of these conditions is true, and then the data wouldn't truly be accurate at all, and views_sparkline has no way of resolving that condition.
Possible solutions:
Comment #2
dwwOption 6: Don't care. Label the graph with the actual time period returned. The main thing for readability IMHO is that all the metrics on the same page have the same time scale. I'm assuming that'll still be true under the various scenarios here. I don't care as much that Project A has 2 years of data while Project B only has 14 weeks. So long as all the sparklines when viewing B are 14 weeks, you can still meaningfully understand trends, etc.
I'm not necessarily opposed to the other 5 solutions, but I wanted to throw #6 into the mix here for consideration. ;)
Cheers,
-Derek
Comment #3
mikey_p commentedThe thing with labeling is that the only way to accurately label would be to label each sparkline with a start and end time (and again, assume there are no gaps) and that seems very redundant considering that there would be a label for each sparkline on the page. Further, making these labels pretty would probably be as much if not more work than some of the other solutions.
Personally from what I can tell adding labels would really go against the spirit of sparklines being high-density inline data.
Comment #4
dwwAgreed. I'm not talking about labels on the sparklines themselves. I meant in project_issue where we're injecting this into the issue cockpit block. I (perhaps incorrectly) assumed there'd be an easy way to figure out how many weeks of data our sparkline views are returning, and instead of always saying "Statistics (2 Years)" or whatever, that we could just create that label based on how much data we actually have. That'd also solve my concern that if the answer is 0 weeks of data we can just hide that whole section of the block...
Comment #5
mikey_p commentedPretty much went with option #1 from my comment. Just trying to get this out so we can deploy.