@politicalwatch/tipi-uikit 1.9.29 → 1.9.30
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
|
@@ -240,14 +240,42 @@ class d3sunburst extends d3chart {
|
|
|
240
240
|
/**
|
|
241
241
|
* Format durations
|
|
242
242
|
*/
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
243
|
+
to_duration(duration) {
|
|
244
|
+
if (duration > 60 * 60 * 1000) {
|
|
245
|
+
return this.to_hour_duration(duration);
|
|
246
|
+
} else if (duration > 60 * 1000) {
|
|
247
|
+
return this.to_min_duration(duration);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return this.to_secs_duration(duration);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
to_secs_duration(duration) {
|
|
254
|
+
const total_secs = duration / 1000;
|
|
255
|
+
const secs = total_secs % 60;
|
|
256
|
+
|
|
257
|
+
return `${Math.floor(secs)} segundos`;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
to_min_duration(duration) {
|
|
261
|
+
const total_secs = duration / 1000;
|
|
262
|
+
const minutes = total_secs / 60;
|
|
263
|
+
const secs = total_secs % 60;
|
|
264
|
+
|
|
265
|
+
return `${Math.floor(minutes)}:${('' + Math.floor(secs)).padStart(2, 0)} min`;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
to_hour_duration(duration) {
|
|
269
|
+
const total_secs = duration / 1000;
|
|
270
|
+
const total_minutes = total_secs / 60;
|
|
271
|
+
const hours = total_minutes / 60;
|
|
272
|
+
const minutes = total_minutes % 60;
|
|
273
|
+
const secs = total_secs % 60;
|
|
274
|
+
|
|
275
|
+
return `${('' + Math.floor(hours)).padStart(2, 0)}:${('' + Math.floor(minutes)).padStart(
|
|
276
|
+
2,
|
|
277
|
+
0
|
|
278
|
+
)}:${('' + Math.floor(secs)).padStart(2, 0)} horas`;
|
|
251
279
|
}
|
|
252
280
|
|
|
253
281
|
/**
|
|
@@ -273,7 +301,7 @@ class d3sunburst extends d3chart {
|
|
|
273
301
|
? pluralize(this.cfg.tooltip.suffix, d.value)
|
|
274
302
|
: this.cfg.tooltip.suffix;
|
|
275
303
|
const text = this.cfg.tooltip.humanReadable
|
|
276
|
-
? `<div>${d.data[this.cfg.key]}: ${this.
|
|
304
|
+
? `<div>${d.data[this.cfg.key]}: ${this.to_duration(d.value)}</div>`
|
|
277
305
|
: this.cfg.tooltip.suffix
|
|
278
306
|
? `<div>${d.data[this.cfg.key]}: ${d.value} ${label}</div>`
|
|
279
307
|
: `<div>${d.data[this.cfg.key]}: ${d.value}</div>`;
|