@politicalwatch/tipi-uikit 1.9.26 → 1.9.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -138,7 +138,7 @@ class d3sunburst extends d3chart {
|
|
|
138
138
|
default: '#AAA',
|
|
139
139
|
axis: '#000',
|
|
140
140
|
},
|
|
141
|
-
tooltip: { label: false, suffix: false, suffixPlural: false },
|
|
141
|
+
tooltip: { label: false, suffix: false, suffixPlural: false, humanReadable: false },
|
|
142
142
|
transition: { duration: 350, ease: 'easeLinear' },
|
|
143
143
|
charSpace: 8,
|
|
144
144
|
});
|
|
@@ -237,6 +237,19 @@ class d3sunburst extends d3chart {
|
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Format durations
|
|
242
|
+
*/
|
|
243
|
+
formatDuration(seconds) {
|
|
244
|
+
const hours = Math.floor(seconds / 3600);
|
|
245
|
+
const minutes = Math.floor((seconds % 3600) / 60);
|
|
246
|
+
const secs = seconds % 60;
|
|
247
|
+
|
|
248
|
+
return [hours, minutes, secs]
|
|
249
|
+
.map((v) => String(v).padStart(2, '0')) // Ensures two-digit format
|
|
250
|
+
.join(':');
|
|
251
|
+
}
|
|
252
|
+
|
|
240
253
|
/**
|
|
241
254
|
* Add new chart's elements
|
|
242
255
|
*/
|
|
@@ -259,9 +272,11 @@ class d3sunburst extends d3chart {
|
|
|
259
272
|
const label = this.cfg.tooltip.suffixPlural
|
|
260
273
|
? pluralize(this.cfg.tooltip.suffix, d.value)
|
|
261
274
|
: this.cfg.tooltip.suffix;
|
|
262
|
-
const text = this.cfg.
|
|
263
|
-
?
|
|
264
|
-
:
|
|
275
|
+
const text = this.cfg.humanReadable
|
|
276
|
+
? this.formatDuration(d.value)
|
|
277
|
+
: this.cfg.tooltip.suffix
|
|
278
|
+
? `<div>${d.data[this.cfg.key]}: ${d.value} ${label}</div>`
|
|
279
|
+
: `<div>${d.data[this.cfg.key]}: ${d.value}</div>`;
|
|
265
280
|
this.tooltip.html(text).classed('active', true);
|
|
266
281
|
})
|
|
267
282
|
.on('mouseout', () => {
|