Skip to content

Commit

Permalink
chg: [charts] ensures a gradual and visible transition from light to …
Browse files Browse the repository at this point in the history
…dark blue.
  • Loading branch information
cedricbonhomme committed Dec 8, 2024
1 parent 4146d5d commit ee53971
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 26 deletions.
45 changes: 23 additions & 22 deletions newspipe/templates/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{% block head %}
{{ super() }}
<script src="{{ url_for('static', filename='npm_components/chart.js/dist/chart.umd.js') }}"></script>
<script src="{{ url_for('static', filename='npm_components/chartjs-plugin-datalabels/dist/chartjs-plugin-datalabels.min.js') }}"></script>
<style>
.chart-container {
display: block;
Expand Down Expand Up @@ -111,34 +112,34 @@ <h3>{{ year }}</h3>
title: {
display: true,
text: 'Number of aggregated articles'
},
// Data Labels Plugin Configuration
datalabels: {
display: true,
align: 'end', // Position above the bar
anchor: 'end', // Keeps it above the bar
color: '#000', // Black text color
font: {
size: 10, // Font size for labels
weight: 'bold',
},
formatter: function(value) {
return value.toLocaleString(); // Format values with commas
},
}
},
responsive: true,
onClick: function(evt) {
const points = myChart.getElementsAtEventForMode(evt, 'nearest', { intersect: true }, true);
if (points.length) {
const firstPoint = points[0];
var label = myChart.data.labels[firstPoint.index];
var value = myChart.data.datasets[firstPoint.datasetIndex].data[firstPoint.index];

if (months.includes(label)) {
the_month = months.indexOf(label)+1;
window.location = window.location + "/" + the_month;
} else {
window.location = window.location + "/" + label;
}
scales: {
x: {
display: true,
},
y: {
display: true,
beginAtZero: true,
}
}
},
scales: {
x: {
display: true,
},
y: {
display: true,
beginAtZero: true,
}
}
plugins: [ChartDataLabels] // Enable the Data Labels Plugin
});
}).catch((error) => {
console.error('Error:', error);
Expand Down
17 changes: 13 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"bootstrap": "^5.3.3",
"bootstrap-icons": "^1.11.3",
"chart.js": "^4.4.7",
"chartjs-plugin-datalabels": "^2.2.0",
"luxon": "^3.5.0",
"moment": "^2.30.1"
},
Expand Down

0 comments on commit ee53971

Please sign in to comment.