@politicalwatch/tipi-uikit 1.7.16 → 1.7.18

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.7.16",
3
+ "version": "1.7.18",
4
4
  "main": "src/components/index.js",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -405,10 +405,10 @@ class d3barchart extends d3chart {
405
405
  })
406
406
  .attr('height', 0)
407
407
  .attr('width', 0)
408
- .on('mouseover', (d, i) => {
409
- console.log('cfg in barchart', this.cfg);
410
- console.log('MOUSEOVER in barchart', d);
411
- const key = this.cfg.values[i % this.cfg.values.length];
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 = this.cfg.tooltip.suffix
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', (d, i) => {
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,14 +187,11 @@ 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
192
  .sum((d) => d[this.cfg.value])
194
193
  .sort((a, b) => b.name - a.name);
195
- return d3
196
- .partition()(root)
197
- .each((d) => (d.current = d));
194
+ return d3.partition()(root);
198
195
  };
199
196
 
200
197
  this.hData = partition(this.data[0]).descendants();
@@ -258,14 +255,15 @@ class d3sunburst extends d3chart {
258
255
  .append('path')
259
256
  .attr('class', 'chart__slice chart__slice--sunburst')
260
257
  .style('fill', (d) => this.colorElement(d.data))
261
- .on('mouseover', (d) => {
262
- console.log('MOUSEOVER in sunburst', d);
258
+ .on('mouseover', (event, d) => {
259
+ console.log('event', event);
260
+ console.log('d', d);
263
261
  const label = this.cfg.tooltip.suffixPlural
264
- ? pluralize(this.cfg.tooltip.suffix, d.target.__data__.data.value)
262
+ ? pluralize(this.cfg.tooltip.suffix, d.value)
265
263
  : this.cfg.tooltip.suffix;
266
264
  const text = this.cfg.tooltip.suffix
267
- ? `<div>${d.target.__data__.data[this.cfg.key]}: ${d.target.__data__.data.value} ${label}</div>`
268
- : `<div>${d.target.__data__.data[this.cfg.key]}: ${d.target.__data__.data.value}</div>`;
265
+ ? `<div>${d.data[this.cfg.key]}: ${d.value} ${label}</div>`
266
+ : `<div>${d.data[this.cfg.key]}: ${d.value}</div>`;
269
267
  this.tooltip.html(text).classed('active', true);
270
268
  })
271
269
  .on('mouseout', () => {
@@ -257,13 +257,15 @@ class d3wordscloud extends d3chart {
257
257
  .attr('text-anchor', 'middle')
258
258
  .attr('fill', (d) => d.color)
259
259
  .attr('transform', (d) => `translate(${[d.x, d.y]})rotate(${d.rotate})`)
260
- .on('mouseover', (d) => {
260
+ .on('mouseover', (event, d) => {
261
+ console.log('d', d);
262
+ console.log('event', event);
261
263
  const label = this.cfg.tooltip.suffixPlural
262
- ? pluralize(this.cfg.tooltip.suffix, d.target.__data__.value)
264
+ ? pluralize(this.cfg.tooltip.suffix, d.value)
263
265
  : this.cfg.tooltip.suffix;
264
266
  const text = this.cfg.tooltip.suffix
265
- ? `<div>${d.target.__data__.text}: ${d.target.__data__.value} ${label}</div>`
266
- : `<div>${d.target.__data__.text}: ${d.target.__data__.value}</div>`;
267
+ ? `<div>${d.text}: ${d.value} ${label}</div>`
268
+ : `<div>${d.text}: ${d.value}</div>`;
267
269
  this.tooltip.html(text).classed('active', true);
268
270
  })
269
271
  .on('mouseout', () => {