diff --git a/app/javascript/controllers/time_series_chart_controller.js b/app/javascript/controllers/time_series_chart_controller.js
index 750fceb1..c37ccf6a 100644
--- a/app/javascript/controllers/time_series_chart_controller.js
+++ b/app/javascript/controllers/time_series_chart_controller.js
@@ -50,7 +50,7 @@ export default class extends Controller {
...d,
date: new Date(d.date),
value: d.value.amount ? +d.value.amount : +d.value,
- currency: d.value.currency || "USD",
+ currency: d.value.currency
}))
}
@@ -250,17 +250,31 @@ export default class extends Controller {
#tooltipTemplate(data) {
- return(`
-
- ${d3.timeFormat("%b %d, %Y")(data.date)}
-
-
-
- ${this.#currencyValue(data)} ${this.#currencyChange(data)} (${data.trend.percent}%)
-
- `)
+ if (data.currency) {
+ return(`
+
+ ${d3.timeFormat("%b %d, %Y")(data.date)}
+
+
+
+ ${this.#currencyValue(data)} ${this.#currencyChange(data)} (${data.trend.percent}%)
+
+ `)
+ } else {
+ return(`
+
+ ${d3.timeFormat("%b %d, %Y")(data.date)}
+
+
+
+ ${data.value} ${this.#decimalChange(data)} (${data.trend.percent}%)
+
+ `)
+ }
}
#dataTrendColor(data) {
@@ -274,18 +288,25 @@ export default class extends Controller {
#currencyValue(data) {
return Intl.NumberFormat(undefined, {
style: "currency",
- currency: data.currency || "USD",
+ currency: data.currency,
}).format(data.value)
}
#currencyChange(data) {
return Intl.NumberFormat(undefined, {
style: "currency",
- currency: data.currency || "USD",
+ currency: data.currency,
signDisplay: "always",
}).format(data.trend.value.amount)
}
+ #decimalChange(data) {
+ return Intl.NumberFormat(undefined, {
+ style: "decimal",
+ signDisplay: "always",
+ }).format(data.trend.value)
+ }
+
#createMainSvg() {
return this.#d3Container