Skip to content

Commit

Permalink
Enable tooltip for stats dashboards
Browse files Browse the repository at this point in the history
- import popper
- use data-bs-toggle instead of data-toggle
- enable tooltips as described here https://getbootstrap.com/docs/5.2/components/tooltips/#enable-tooltips
  • Loading branch information
juffardm committed Dec 4, 2024
1 parent 8ca342d commit c53056a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion incidents/static/custom_js/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,15 @@ function generate_stacked_chart(selector, url, width, height, label, legend) {
.attr("y", function(d) { return y(d.y1); })
.attr("height", function(d) { return y(d.y0) - y(d.y1); })
.attr('title', function(d) { return d.y1-d.y0})
.attr('data-toggle', 'tooltip')
.attr('data-bs-toggle', 'tooltip')
.style("fill", function(d) {
return color(d.name)
});

// enable tooltips
const tooltipTriggerList = document.querySelectorAll('[data-bs-toggle="tooltip"]')
const tooltipList = [...tooltipTriggerList].map(tooltipTriggerEl => new bootstrap.Tooltip(tooltipTriggerEl))


var legend = svg.selectAll(".legend")
.data(color.domain().slice().reverse())
Expand Down
1 change: 1 addition & 0 deletions incidents/templates/stats/quarterly.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ <h1>{% blocktrans with bl_name=bl.name %}Incidents quarterly statistics for <br

<script src="{% static "js/d3.v3.min.js" %}"></script>
<script src="{% static "custom_js/stats.js" %}"></script>
<script src="{% static "js/popper.min.js" %}"></script>

{%endblock%}

Expand Down
1 change: 1 addition & 0 deletions incidents/templates/stats/sandbox.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ <h1>{% trans "Sandbox" %}</h1>
{% block custom_js_top %}
<script src="{% static "js/d3.v3.min.js" %}"></script>
<script src="{% static "custom_js/stats.js" %}"></script>
<script src="{% static "js/popper.min.js" %}"></script>
{% endblock%}

{% block custom_js %}
Expand Down
1 change: 1 addition & 0 deletions incidents/templates/stats/yearly.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ <h1>{% trans "Yearly stats" %}</h1>
{% block custom_js_top %}
<script src="{% static "js/d3.v3.min.js" %}"></script>
<script src="{% static "custom_js/stats.js" %}"></script>
<script src="{% static "js/popper.min.js" %}"></script>

{%endblock%}

Expand Down
1 change: 1 addition & 0 deletions incidents/templates/stats/yearly_compare.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ <h1>{% blocktrans with current_year=year previous_year=year|add:-1 %}Comparison
{% block custom_js_top %}
<script src="{% static "js/d3.v3.min.js" %}"></script>
<script src="{% static "custom_js/stats.js" %}"></script>
<script src="{% static "js/popper.min.js" %}"></script>

{%endblock%}

Expand Down

0 comments on commit c53056a

Please sign in to comment.