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