@politicalwatch/tipi-uikit 1.7.15 → 1.7.17
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
|
@@ -405,10 +405,10 @@ class d3barchart extends d3chart {
|
|
|
405
405
|
})
|
|
406
406
|
.attr('height', 0)
|
|
407
407
|
.attr('width', 0)
|
|
408
|
-
.on('mouseover', (
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
const key = this.cfg.values[
|
|
408
|
+
.on('mouseover', (event, d) => {
|
|
409
|
+
const bars = d3.selectAll('.chart__bar--barchart').nodes();
|
|
410
|
+
const index = bars.indexOf(event.currentTarget);
|
|
411
|
+
const key = this.cfg.values[index % this.cfg.values.length];
|
|
412
412
|
const label = this.cfg.tooltip.suffixPlural
|
|
413
413
|
? pluralize(this.cfg.tooltip.suffix, d[key])
|
|
414
414
|
: this.cfg.tooltip.suffix;
|
|
@@ -417,9 +417,7 @@ class d3barchart extends d3chart {
|
|
|
417
417
|
|
|
418
418
|
const percentage = this.calculatePercentage(d[key], totals[key]).toFixed(2);
|
|
419
419
|
|
|
420
|
-
const text =
|
|
421
|
-
? `<div>${labelKey}: ${percentage}% ${label}</div>`
|
|
422
|
-
: `<div>${labelKey}: ${percentage}%</div>`;
|
|
420
|
+
const text = `<div>${labelKey}: ${percentage}%</div>`;
|
|
423
421
|
this.tooltip.html(text).classed('active', true);
|
|
424
422
|
})
|
|
425
423
|
.on('mouseout', () => {
|
|
@@ -279,7 +279,7 @@ class d3sliceschart extends d3chart {
|
|
|
279
279
|
// .style('left', window.event['pageX'] - 28 + 'px')
|
|
280
280
|
// .style('top', window.event['pageY'] - 40 + 'px');
|
|
281
281
|
//})
|
|
282
|
-
.on('mouseover', (
|
|
282
|
+
.on('mouseover', (event, d) => {
|
|
283
283
|
console.log('MOUSEOVER in sliceschart', d);
|
|
284
284
|
const total = d3.sum(this.data, (d) => d.value);
|
|
285
285
|
const value = d.data.value > 0 && total > 0 ? Math.round((d.data.value / total) * 100) : 0;
|
|
@@ -187,10 +187,9 @@ class d3sunburst extends d3chart {
|
|
|
187
187
|
*/
|
|
188
188
|
bindData() {
|
|
189
189
|
const partition = (data) => {
|
|
190
|
-
console.log(data);
|
|
191
190
|
const root = d3
|
|
192
191
|
.hierarchy(data)
|
|
193
|
-
.sum((d) => d.value)
|
|
192
|
+
.sum((d) => d[this.cfg.value])
|
|
194
193
|
.sort((a, b) => b.name - a.name);
|
|
195
194
|
return d3.partition()(root);
|
|
196
195
|
};
|
|
@@ -257,14 +256,16 @@ class d3sunburst extends d3chart {
|
|
|
257
256
|
.attr('class', 'chart__slice chart__slice--sunburst')
|
|
258
257
|
.style('fill', (d) => this.colorElement(d.data))
|
|
259
258
|
.on('mouseover', (d) => {
|
|
260
|
-
console.log('MOUSEOVER in sunburst', d);
|
|
261
259
|
const label = this.cfg.tooltip.suffixPlural
|
|
262
260
|
? pluralize(this.cfg.tooltip.suffix, d.target.__data__.data.value)
|
|
263
261
|
: this.cfg.tooltip.suffix;
|
|
264
262
|
const text = this.cfg.tooltip.suffix
|
|
265
|
-
? `<div>${d.target.__data__.data[this.cfg.key]}: ${
|
|
263
|
+
? `<div>${d.target.__data__.data[this.cfg.key]}: ${
|
|
264
|
+
d.target.__data__.data.value
|
|
265
|
+
} ${label}</div>`
|
|
266
266
|
: `<div>${d.target.__data__.data[this.cfg.key]}: ${d.target.__data__.data.value}</div>`;
|
|
267
|
-
|
|
267
|
+
// TODO fix values in tooltip for parent elements
|
|
268
|
+
if (d.target.__data__.data.value) this.tooltip.html(text).classed('active', true);
|
|
268
269
|
})
|
|
269
270
|
.on('mouseout', () => {
|
|
270
271
|
this.tooltip.classed('active', false);
|