@@ -69,58 +69,60 @@ $(document).ready(function () {
69
69
// Render the Chart
70
70
//
71
71
Chart . defaults . global . responsive = true ;
72
- var ctx = $ ( "#pint-pubs-chart" ) . get ( 0 ) . getContext ( "2d" ) ;
73
- // This will get the first returned node in the jQuery collection.
74
- var data = {
75
- labels : years ,
76
- datasets : [
77
- {
78
- label : "Number Publications per Year" ,
79
- data : counts ,
80
- } ,
81
- ] ,
82
- } ;
83
- var options = {
84
- //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
85
- scaleBeginAtZero : true ,
86
- //Boolean - Whether grid lines are shown across the chart
87
- scaleShowGridLines : true ,
88
- //String - Colour of the grid lines
89
- scaleGridLineColor : "rgba(0,0,0,.05)" ,
90
- //Number - Width of the grid lines
91
- scaleGridLineWidth : 1 ,
92
- //Boolean - Whether to show horizontal lines (except X axis)
93
- scaleShowHorizontalLines : true ,
94
- //Boolean - Whether to show vertical lines (except Y axis)
95
- scaleShowVerticalLines : false ,
96
- //Boolean - If there is a stroke on each bar
97
- barShowStroke : false ,
98
- //Number - Pixel width of the bar stroke
99
- barStrokeWidth : 0 ,
100
- //Number - Spacing between each of the X value sets
101
- barValueSpacing : 1 ,
102
- //Number - Spacing between data sets within X values
103
- barDatasetSpacing : 0 ,
104
- //String - A legend template
105
- legendTemplate :
106
- '{% raw %}<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>{% endraw %}' ,
107
- } ;
108
- Chart . defaults . global . responsive = false ;
109
- Chart . defaults . global . maintainAspectRatio = false ;
110
- Chart . defaults . global . tooltipXOffset = 0 ;
111
- Chart . defaults . global . tooltipYOffset = 0 ;
112
- var pint_pub_chart = new Chart ( ctx ) . Bar ( data , options ) ;
113
- $ ( "#stats-buttons" ) . append (
114
- '<div role="group"><button class="button" onclick="appendJsonToModal()" data-toggle="modal" data-target="#json-modal">JSON data of plot</button></div>'
115
- ) ;
116
- $ ( "#chart-raw-data" ) . html (
117
- "<pre>" + JSON . stringify ( years_counts , null , 2 ) + "</pre>"
118
- ) ;
119
- $ ( "#image-download-docu" ) . text (
120
- "To download the plot and use it in your publications, right-click it. It is licensed under a Creative Commons Attribution 3.0 license. If you use the BibTex file or figure in a publication, a reference to this website would be much appreciated."
121
- ) ;
72
+ if ( $ ( "#pint-pubs-chart" ) . length > 0 ) {
73
+ var ctx = $ ( "#pint-pubs-chart" ) . get ( 0 ) . getContext ( "2d" ) ;
74
+ // This will get the first returned node in the jQuery collection.
75
+ var data = {
76
+ labels : years ,
77
+ datasets : [
78
+ {
79
+ label : "Number Publications per Year" ,
80
+ data : counts ,
81
+ } ,
82
+ ] ,
83
+ } ;
84
+ var options = {
85
+ //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value
86
+ scaleBeginAtZero : true ,
87
+ //Boolean - Whether grid lines are shown across the chart
88
+ scaleShowGridLines : true ,
89
+ //String - Colour of the grid lines
90
+ scaleGridLineColor : "rgba(0,0,0,.05)" ,
91
+ //Number - Width of the grid lines
92
+ scaleGridLineWidth : 1 ,
93
+ //Boolean - Whether to show horizontal lines (except X axis)
94
+ scaleShowHorizontalLines : true ,
95
+ //Boolean - Whether to show vertical lines (except Y axis)
96
+ scaleShowVerticalLines : false ,
97
+ //Boolean - If there is a stroke on each bar
98
+ barShowStroke : false ,
99
+ //Number - Pixel width of the bar stroke
100
+ barStrokeWidth : 0 ,
101
+ //Number - Spacing between each of the X value sets
102
+ barValueSpacing : 1 ,
103
+ //Number - Spacing between data sets within X values
104
+ barDatasetSpacing : 0 ,
105
+ //String - A legend template
106
+ legendTemplate :
107
+ '{% raw %}<ul class="<%=name.toLowerCase()%>-legend"><% for (var i=0; i<datasets.length; i++){%><li><span style="background-color:<%=datasets[i].fillColor%>"></span><%if(datasets[i].label){%><%=datasets[i].label%><%}%></li><%}%></ul>{% endraw %}' ,
108
+ } ;
109
+ Chart . defaults . global . responsive = false ;
110
+ Chart . defaults . global . maintainAspectRatio = false ;
111
+ Chart . defaults . global . tooltipXOffset = 0 ;
112
+ Chart . defaults . global . tooltipYOffset = 0 ;
113
+ var pint_pub_chart = new Chart ( ctx ) . Bar ( data , options ) ;
114
+ $ ( "#stats-buttons" ) . append (
115
+ '<div role="group"><button class="button" onclick="appendJsonToModal()" data-toggle="modal" data-target="#json-modal">JSON data of plot</button></div>'
116
+ ) ;
117
+ $ ( "#chart-raw-data" ) . html (
118
+ "<pre>" + JSON . stringify ( years_counts , null , 2 ) + "</pre>"
119
+ ) ;
120
+ $ ( "#image-download-docu" ) . text (
121
+ "To download the plot and use it in your publications, right-click it. It is licensed under a Creative Commons Attribution 3.0 license. If you use the BibTex file or figure in a publication, a reference to this website would be much appreciated."
122
+ ) ;
122
123
123
- $ ( ".year-btn-group" ) . removeClass ( "hidden" ) ;
124
+ $ ( ".year-btn-group" ) . removeClass ( "hidden" ) ;
125
+ }
124
126
} ) ;
125
127
126
128
function appendJsonToModal ( ) {
0 commit comments