@@ -11,6 +11,24 @@ var RubyBench = (function() {
1111 return String ( year ) + '-' + String ( month ) . padStart ( 2 , '0' ) + '-' + String ( day ) . padStart ( 2 , '0' ) ;
1212 }
1313
14+ // GitHub URL showing the ruby/ruby changes that landed between the
15+ // previous charted day's commit and this day's commit. Falls back to the
16+ // single commit when there is no earlier sha to compare against.
17+ function commitRangeUrl ( rubies , categories , index ) {
18+ var sha = rubies [ Number ( categories [ index ] ) ] ;
19+ if ( ! sha ) {
20+ return null ;
21+ }
22+ var prevSha = null ;
23+ for ( var i = index - 1 ; i >= 0 && ! prevSha ; i -- ) {
24+ prevSha = rubies [ Number ( categories [ i ] ) ] ;
25+ }
26+ if ( prevSha && prevSha !== sha ) {
27+ return 'https://github.com/ruby/ruby/compare/' + prevSha + '...' + sha ;
28+ }
29+ return 'https://github.com/ruby/ruby/commit/' + sha ;
30+ }
31+
1432 // Initialize Highcharts defaults
1533 function initHighchartsDefaults ( ) {
1634 Highcharts . setOptions ( {
@@ -65,6 +83,14 @@ var RubyBench = (function() {
6583 defaultConfig . legend = options . legend ;
6684 }
6785
86+ // Make points clickable if a handler is provided
87+ if ( options . onPointClick ) {
88+ defaultConfig . plotOptions . series . cursor = 'pointer' ;
89+ defaultConfig . plotOptions . series . point = {
90+ events : { click : options . onPointClick }
91+ } ;
92+ }
93+
6894 // Add plot lines if provided
6995 if ( options . yAxisPlotLines ) {
7096 defaultConfig . yAxis . plotLines = options . yAxisPlotLines ;
@@ -217,6 +243,7 @@ var RubyBench = (function() {
217243 // Public API
218244 return {
219245 formatDate : formatDate ,
246+ commitRangeUrl : commitRangeUrl ,
220247 initHighchartsDefaults : initHighchartsDefaults ,
221248 createBaseChartConfig : createBaseChartConfig ,
222249 plotChart : plotChart ,
0 commit comments