Skip to content

Commit d5a3a50

Browse files
committed
fix js errors
1 parent 5e765cb commit d5a3a50

File tree

4 files changed

+67
-54
lines changed

4 files changed

+67
-54
lines changed

_includes/head.html

+2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
<script src="/assets/js/vendor/bootstrap/transition.js"></script>
2020
<script src="/assets/js/vendor/bootstrap/tooltip.js"></script>
2121
<script src="/assets/js/vendor/bootstrap/popover.js"></script>
22+
<script src="/assets/js/vendor/Chart.min.js"></script>
2223
<script src="/assets/js/vendor/jquery.githubRepoWidget.js"></script>
2324
<script src="/assets/js/custom.js"></script>
2425
<script src="/assets/js/bib_stats.js"></script>
26+
<script defer src="https://unpkg.com/[email protected]/dist/cdn.min.js"></script>
2527
</head>

assets/js/bib_stats.js

+53-51
Original file line numberDiff line numberDiff line change
@@ -69,58 +69,60 @@ $(document).ready(function () {
6969
// Render the Chart
7070
//
7171
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+
);
122123

123-
$(".year-btn-group").removeClass("hidden");
124+
$(".year-btn-group").removeClass("hidden");
125+
}
124126
});
125127

126128
function appendJsonToModal() {

assets/js/vendor/Chart.min.js

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

references/index.html

+1-3
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,4 @@ <h2 id="year0004" class="year">2000 - 2004 <span class="count-stat"></span></h2>
8585
{% bibliography --file pint -q @*[year>=1990 && year<=1994] %} {% include references_year_nav.html %} <h2
8686
id="year90" class="year">Pre 1990 <span class="count-stat"></span></h2>
8787

88-
{% bibliography --file pint -q @*[year<=1989] %} {% include references_year_nav.html %} <script
89-
src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js" type="text/javascript">
90-
</script>
88+
{% bibliography --file pint -q @*[year<=1989] %} {% include references_year_nav.html %}

0 commit comments

Comments
 (0)