@politicalwatch/tipi-uikit 1.9.26 → 1.9.27

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@politicalwatch/tipi-uikit",
3
- "version": "1.9.26",
3
+ "version": "1.9.27",
4
4
  "main": "src/components/index.js",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -1,4 +1,5 @@
1
1
  import d3chart from '../d3.chart';
2
+ import { formatDuration } from 'date-fns';
2
3
  import { select, selectAll } from 'd3-selection';
3
4
  import { scaleLinear, scaleOrdinal, scaleSqrt } from 'd3-scale';
4
5
  import { hierarchy, partition } from 'd3-hierarchy';
@@ -138,7 +139,7 @@ class d3sunburst extends d3chart {
138
139
  default: '#AAA',
139
140
  axis: '#000',
140
141
  },
141
- tooltip: { label: false, suffix: false, suffixPlural: false },
142
+ tooltip: { label: false, suffix: false, suffixPlural: false, humanReadable: false },
142
143
  transition: { duration: 350, ease: 'easeLinear' },
143
144
  charSpace: 8,
144
145
  });
@@ -256,9 +257,11 @@ class d3sunburst extends d3chart {
256
257
  .attr('class', 'chart__slice chart__slice--sunburst')
257
258
  .style('fill', (d) => this.colorElement(d.data))
258
259
  .on('mouseover', (event, d) => {
259
- const label = this.cfg.tooltip.suffixPlural
260
- ? pluralize(this.cfg.tooltip.suffix, d.value)
261
- : this.cfg.tooltip.suffix;
260
+ const label = this.cfg.tooltip.humanReadable
261
+ ? formatDuration({ seconds: d.value })
262
+ : this.cfg.tooltip.suffixPlural
263
+ ? pluralize(this.cfg.tooltip.suffix, d.value)
264
+ : this.cfg.tooltip.suffix;
262
265
  const text = this.cfg.tooltip.suffix
263
266
  ? `<div>${d.data[this.cfg.key]}: ${d.value} ${label}</div>`
264
267
  : `<div>${d.data[this.cfg.key]}: ${d.value}</div>`;