Skip to content

Commit

Permalink
fix share NaN
Browse files Browse the repository at this point in the history
  • Loading branch information
joewdavies committed Mar 20, 2024
1 parent 6caec8c commit 9ae81f2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
10 changes: 6 additions & 4 deletions build/dorling.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/dorling.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nutsdorlingcartogram",
"version": "1.2.23",
"version": "1.2.24",
"description": "Library for creating dorling cartograms of NUTS regions",
"main": "build/dorling.min.js",
"files": [
Expand Down
8 changes: 5 additions & 3 deletions src/dorling.js
Original file line number Diff line number Diff line change
Expand Up @@ -1915,6 +1915,10 @@ export function dorling() {
}

//set tooltip content
let share = roundToOneDecimal(
(out.sizeIndicator[id] / out.totalsIndex[id.substring(0, 2)]) * 100
)

out.tooltipElement.html(`
${/* HEADER */ ''}
Expand All @@ -1933,9 +1937,7 @@ export function dorling() {
${out.tooltip_.colorLabel}: ${out.tooltip_.colorValueTextFunction(out.colorIndicator[id])}<br>
${/* SHARE UNIT / VALUE */ ''}
${out.tooltip_.shareLabel}:\xA0${roundToOneDecimal(
(out.sizeIndicator[id] / out.totalsIndex[id.substring(0, 2)]) * 100
)}${out.tooltip_.shareUnit} <br>
${out.tooltip_.shareLabel}:\xA0${share ? share + ' ' + out.tooltip_.shareUnit : 'no data'} <br>
</div>
`)
Expand Down

0 comments on commit 9ae81f2

Please sign in to comment.