Skip to content

Commit b12c798

Browse files
author
Daniel Blaichinger
committed
Only show the tooltip value if there is one available. Otherwise the given currency is printed without any value
1 parent 4f61681 commit b12c798

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/scripts/chartist-plugin-tooltip.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
} else {
8080

8181
meta = '<span class="chartist-tooltip-meta">' + meta + '</span>';
82-
value = '<span class="chartist-tooltip-value">' + value + '</span>';
8382

8483
if (hasMeta) {
8584
tooltipText += meta + '<br>';
@@ -94,10 +93,13 @@
9493
}
9594
}
9695

97-
if (options.currency) {
98-
value = options.currency + value.replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,");
96+
if (value) {
97+
value = '<span class="chartist-tooltip-value">' + value + '</span>';
98+
if (options.currency) {
99+
value = options.currency + value.replace(/(\d)(?=(\d{3})+(?:\.\d+)?$)/g, "$1,");
100+
}
101+
tooltipText += value;
99102
}
100-
tooltipText += value;
101103
}
102104

103105
$toolTip.innerHTML = tooltipText;

0 commit comments

Comments
 (0)