@politicalwatch/tipi-uikit 1.6.16 → 1.7.1

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.6.16",
3
+ "version": "1.7.1",
4
4
  "main": "src/components/index.js",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "core-js": "^3.32.2",
16
- "d3": "^5.14.2",
16
+ "d3": "^7.8.5",
17
17
  "d3-cloud": "^1.2.5",
18
18
  "date-fns": "^3.0.0",
19
19
  "masonry-layout": "^4.2.2",
@@ -171,9 +171,9 @@ class d3sunburst extends d3chart {
171
171
  this.svg
172
172
  .attr(
173
173
  'viewBox',
174
- `0 0 ${this.cfg.width + this.cfg.margin.left + this.cfg.margin.right} ${this.cfg.height +
175
- this.cfg.margin.top +
176
- this.cfg.margin.bottom}`
174
+ `0 0 ${this.cfg.width + this.cfg.margin.left + this.cfg.margin.right} ${
175
+ this.cfg.height + this.cfg.margin.top + this.cfg.margin.bottom
176
+ }`
177
177
  )
178
178
  .attr('width', this.cfg.width + this.cfg.margin.left + this.cfg.margin.right)
179
179
  .attr('height', this.cfg.height + this.cfg.margin.top + this.cfg.margin.bottom);
@@ -186,10 +186,10 @@ class d3sunburst extends d3chart {
186
186
  * Bind data to main elements groups
187
187
  */
188
188
  bindData() {
189
- const partition = data => {
189
+ const partition = (data) => {
190
190
  const root = d3
191
191
  .hierarchy(data)
192
- .sum(d => d[this.cfg.value])
192
+ .sum((d) => d[this.cfg.value])
193
193
  .sort((a, b) => b.name - a.name);
194
194
  return d3.partition()(root);
195
195
  };
@@ -198,7 +198,7 @@ class d3sunburst extends d3chart {
198
198
 
199
199
  this.itemg = this.gcenter
200
200
  .selectAll('.chart__slice-group')
201
- .data(this.hData, d => d.data[this.cfg.key]);
201
+ .data(this.hData, (d) => d.data[this.cfg.key]);
202
202
 
203
203
  // Set transition
204
204
  this.transition = d3
@@ -222,10 +222,10 @@ class d3sunburst extends d3chart {
222
222
 
223
223
  this.arc = d3
224
224
  .arc()
225
- .startAngle(d => this.xScale(d.x0))
226
- .endAngle(d => this.xScale(d.x1))
227
- .innerRadius(d => Math.max(0, this.yScale(d.y0)))
228
- .outerRadius(d => Math.max(0, this.yScale(d.y1)));
225
+ .startAngle((d) => this.xScale(d.x0))
226
+ .endAngle((d) => this.xScale(d.x1))
227
+ .innerRadius((d) => Math.max(0, this.yScale(d.y0)))
228
+ .outerRadius((d) => Math.max(0, this.yScale(d.y1)));
229
229
 
230
230
  // Set up color scheme
231
231
  if (this.cfg.color.scheme) {
@@ -245,8 +245,8 @@ class d3sunburst extends d3chart {
245
245
  .enter()
246
246
  .append('g')
247
247
  .attr('class', 'chart__slice-group chart__slice-group--sunburst clickable')
248
- .on('click', d => {
249
- window.event.stopPropagation();
248
+ .on('click', (event, d) => {
249
+ event.stopPropagation();
250
250
  this.focusOn(d);
251
251
  });
252
252
 
@@ -254,8 +254,8 @@ class d3sunburst extends d3chart {
254
254
  newg
255
255
  .append('path')
256
256
  .attr('class', 'chart__slice chart__slice--sunburst')
257
- .style('fill', d => this.colorElement(d.data))
258
- .on('mouseover', d => {
257
+ .style('fill', (d) => this.colorElement(d.data))
258
+ .on('mouseover', (d) => {
259
259
  const label = this.cfg.tooltip.suffixPlural
260
260
  ? pluralize(this.cfg.tooltip.suffix, d.value)
261
261
  : this.cfg.tooltip.suffix;
@@ -267,18 +267,18 @@ class d3sunburst extends d3chart {
267
267
  .on('mouseout', () => {
268
268
  this.tooltip.classed('active', false);
269
269
  })
270
- .on('mousemove', () => {
270
+ .on('mousemove', (event) => {
271
271
  this.tooltip
272
- .style('left', window.event['pageX'] - 28 + 'px')
273
- .style('top', window.event['pageY'] - 40 + 'px');
272
+ .style('left', event['pageX'] - 28 + 'px')
273
+ .style('top', event['pageY'] - 40 + 'px');
274
274
  })
275
275
  .transition(this.transition)
276
- .attrTween('d', d => {
276
+ .attrTween('d', (d) => {
277
277
  const iy0 = d3.interpolate(0, d.y0);
278
278
  const iy1 = d3.interpolate(d.y0, d.y1);
279
279
  const ix0 = d3.interpolate(0, d.x0);
280
280
  const ix1 = d3.interpolate(0, d.x1);
281
- return t => {
281
+ return (t) => {
282
282
  d.y0 = iy0(t);
283
283
  d.y1 = iy1(t);
284
284
  d.x0 = ix0(t);
@@ -292,7 +292,7 @@ class d3sunburst extends d3chart {
292
292
  .append('path')
293
293
  .attr('class', 'chart__line--hidden')
294
294
  .attr('id', (_, i) => `hiddenArc${i}`)
295
- .attr('d', d => this.middleArcLine(d));
295
+ .attr('d', (d) => this.middleArcLine(d));
296
296
 
297
297
  this.labels = newg
298
298
  .append('text')
@@ -307,7 +307,7 @@ class d3sunburst extends d3chart {
307
307
  .append('textPath')
308
308
  .attr('startOffset', '50%')
309
309
  .attr('xlink:href', (_, i) => `#hiddenArc${i}`)
310
- .text(d => d.data.name);
310
+ .text((d) => d.data.name);
311
311
  }
312
312
 
313
313
  /**
@@ -317,13 +317,13 @@ class d3sunburst extends d3chart {
317
317
  this.itemg
318
318
  .selectAll('.chart__slice')
319
319
  .transition(this.transition)
320
- .attrTween('d', d => {
321
- const d2 = this.hData.filter(j => j.data.name === d.data.name)[0];
320
+ .attrTween('d', (d) => {
321
+ const d2 = this.hData.filter((j) => j.data.name === d.data.name)[0];
322
322
  const iy0 = d3.interpolate(d.y0, d2.y0);
323
323
  const iy1 = d3.interpolate(d.y1, d2.y1);
324
324
  const ix0 = d3.interpolate(d.x0, d2.x0);
325
325
  const ix1 = d3.interpolate(d.x1, d2.x1);
326
- return t => {
326
+ return (t) => {
327
327
  d2.y0 = iy0(t);
328
328
  d2.y1 = iy1(t);
329
329
  d2.x0 = ix0(t);
@@ -331,10 +331,10 @@ class d3sunburst extends d3chart {
331
331
  return this.arc(d2);
332
332
  };
333
333
  })
334
- .style('fill', d => this.colorElement(d.data));
334
+ .style('fill', (d) => this.colorElement(d.data));
335
335
 
336
336
  this.labels
337
- .attr('display', d => (this.textFits(d) ? null : 'none'))
337
+ .attr('display', (d) => (this.textFits(d) ? null : 'none'))
338
338
  .transition(this.transition)
339
339
  .duration(this.cfg.transition.duration / 2)
340
340
  .delay(this.cfg.transition.duration / 2)
@@ -345,11 +345,7 @@ class d3sunburst extends d3chart {
345
345
  * Remove chart's elements without data
346
346
  */
347
347
  exitElements() {
348
- this.itemg
349
- .exit()
350
- .transition(this.transition)
351
- .style('opacity', 0)
352
- .remove();
348
+ this.itemg.exit().transition(this.transition).style('opacity', 0).remove();
353
349
  }
354
350
 
355
351
  /**
@@ -366,7 +362,7 @@ class d3sunburst extends d3chart {
366
362
  * Transition slice on focus
367
363
  */
368
364
  focusOn(d) {
369
- const d2 = this.hData.filter(j => j.data.name === d.data.name)[0];
365
+ const d2 = this.hData.filter((j) => j.data.name === d.data.name)[0];
370
366
  const transition = this.svg
371
367
  .transition()
372
368
  .duration(this.cfg.transition.duration)
@@ -374,24 +370,24 @@ class d3sunburst extends d3chart {
374
370
  .tween('scale', () => {
375
371
  const xd = d3.interpolate(this.xScale.domain(), [d2.x0, d2.x1]);
376
372
  const yd = d3.interpolate(this.yScale.domain(), [d2.y0, 1]);
377
- return t => {
373
+ return (t) => {
378
374
  this.xScale.domain(xd(t));
379
375
  this.yScale.domain(yd(t));
380
376
  };
381
377
  });
382
378
 
383
- transition.selectAll('.chart__slice').attrTween('d', d => () => {
384
- const d3 = this.hData.filter(j => j.data.name === d.data.name)[0];
379
+ transition.selectAll('.chart__slice').attrTween('d', (d) => () => {
380
+ const d3 = this.hData.filter((j) => j.data.name === d.data.name)[0];
385
381
  return this.arc(d3);
386
382
  });
387
383
 
388
- transition.selectAll('.chart__line--hidden').attrTween('d', da => () => {
389
- const d2 = this.hData.filter(j => j.data.name === da.data.name)[0];
384
+ transition.selectAll('.chart__line--hidden').attrTween('d', (da) => () => {
385
+ const d2 = this.hData.filter((j) => j.data.name === da.data.name)[0];
390
386
  return this.middleArcLine(d2);
391
387
  });
392
388
 
393
- transition.selectAll('.chart__labels').attrTween('display', da => () => {
394
- const d2 = this.hData.filter(j => j.data.name === da.data.name)[0];
389
+ transition.selectAll('.chart__labels').attrTween('display', (da) => () => {
390
+ const d2 = this.hData.filter((j) => j.data.name === da.data.name)[0];
395
391
  return this.textFits(d2) ? null : 'none';
396
392
  });
397
393
  }