[llvm-commits] CVS: llvm-www/pubs/index.html pubs.js
Misha Brukman
brukman at cs.uiuc.edu
Mon Jun 29 09:43:45 PDT 2009
Changes in directory llvm-www/pubs:
index.html updated: 1.91 -> 1.92
pubs.js updated: 1.46 -> 1.47
---
Log message:
Added a histogram of publications over years as a chart.
---
Diffs of the changes: (+56 -3)
index.html | 9 ++++++---
pubs.js | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 56 insertions(+), 3 deletions(-)
Index: llvm-www/pubs/index.html
diff -u llvm-www/pubs/index.html:1.91 llvm-www/pubs/index.html:1.92
--- llvm-www/pubs/index.html:1.91 Fri Dec 26 12:43:11 2008
+++ llvm-www/pubs/index.html Mon Jun 29 11:39:50 2009
@@ -1,11 +1,14 @@
<!--#include virtual="../header.incl" -->
<div class="www_sectiontitle">LLVM Related Publications</div>
-<div id='pubs_list'>
-</div>
+<span id='pubs_chart' style="float:right"></span>
+<div id='pubs_list'></div>
<script src="pubs.js" type="text/javascript"></script>
-<script type="text/javascript">displayAllPubs('pubs_list');</script>
+<script type="text/javascript">
+ displayAllPubs('pubs_list');
+ displayPubsHistogram('pubs_chart');
+</script>
<noscript><p>Please enable Javascript to view this page properly.</p></noscript>
<!--#include virtual="../footer.incl" -->
Index: llvm-www/pubs/pubs.js
diff -u llvm-www/pubs/pubs.js:1.46 llvm-www/pubs/pubs.js:1.47
--- llvm-www/pubs/pubs.js:1.46 Mon Jun 29 10:27:34 2009
+++ llvm-www/pubs/pubs.js Mon Jun 29 11:39:51 2009
@@ -858,3 +858,53 @@
}
}
+/**
+ * Displays a histogram of publications by year as a chart, using Google Chart
+ * API. See http://code.google.com/apis/chart/ for more info.
+ *
+ * @param {string} id ID of the element that will serve as the parent of
+ * the chart.
+ */
+function displayPubsHistogram(id) {
+ var histogram = {};
+ for (var i = 0; i < PUBS.length; ++i) {
+ var pub = PUBS[i];
+ if (isDef(pub.year)) {
+ if (isDef(histogram[pub.year])) {
+ histogram[pub.year]++;
+ } else {
+ histogram[pub.year] = 1;
+ }
+ }
+ }
+
+ // Sort the years in the histogram map to use for x-axis labels.
+ var sortedYears = [];
+ for (var year in histogram) {
+ sortedYears.push(year);
+ }
+ sortedYears.sort(function(a, b) { return a - b; });
+
+ // Get the data that corresponds to the sorted x-axis labels to be used as
+ // y-axis data. Also get the max count to use in chart scaling.
+ var countDataBySortedYear = [];
+ var maxCount = 0;
+ for (var i = 0; i < sortedYears.length; ++i) {
+ var count = histogram[sortedYears[i]];
+ countDataBySortedYear.push(count);
+ maxCount = (count > maxCount) ? count : maxCount;
+ }
+
+ var container = document.getElementById(id);
+ var image = document.createElement('img');
+ image.src = 'http://www.google.com/chart?cht=bvs' + // vertical bars
+ '&chs=300x200' + // size
+ '&chtt=Histogram' + // title
+ '&chdl=Count' + // label in legend
+ '&chxt=x,y' + // axes
+ '&chxl=0:|' + sortedYears.join('|') + // x-axis labels
+ '&chxr=1,0,' + (maxCount + 5) + // y-axis range
+ '&chds=0,' + (maxCount + 5) + // scaling
+ '&chd=t:' + countDataBySortedYear.join(','); // chart data
+ container.appendChild(image);
+}
More information about the llvm-commits
mailing list