@politicalwatch/tipi-uikit 1.7.0 → 1.7.2

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.0",
3
+ "version": "1.7.2",
4
4
  "main": "src/components/index.js",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -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,31 +254,32 @@ 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;
262
+
262
263
  const text = this.cfg.tooltip.suffix
263
- ? `<div>${d.data[this.cfg.key]}: ${d.value} ${label}</div>`
264
- : `<div>${d.data[this.cfg.key]}: ${d.value}</div>`;
264
+ ? `<div>${d.data[this.cfg.key] ?? 'TESTLABEL'}: ${d.value} ${label}</div>`
265
+ : `<div>${d.data[this.cfg.key] ?? 'TESTLABEL'}: ${d.value}</div>`;
265
266
  this.tooltip.html(text).classed('active', true);
266
267
  })
267
268
  .on('mouseout', () => {
268
269
  this.tooltip.classed('active', false);
269
270
  })
270
- .on('mousemove', () => {
271
+ .on('mousemove', (event) => {
271
272
  this.tooltip
272
- .style('left', window.event['pageX'] - 28 + 'px')
273
- .style('top', window.event['pageY'] - 40 + 'px');
273
+ .style('left', event['pageX'] - 28 + 'px')
274
+ .style('top', event['pageY'] - 40 + 'px');
274
275
  })
275
276
  .transition(this.transition)
276
- .attrTween('d', d => {
277
+ .attrTween('d', (d) => {
277
278
  const iy0 = d3.interpolate(0, d.y0);
278
279
  const iy1 = d3.interpolate(d.y0, d.y1);
279
280
  const ix0 = d3.interpolate(0, d.x0);
280
281
  const ix1 = d3.interpolate(0, d.x1);
281
- return t => {
282
+ return (t) => {
282
283
  d.y0 = iy0(t);
283
284
  d.y1 = iy1(t);
284
285
  d.x0 = ix0(t);
@@ -292,7 +293,7 @@ class d3sunburst extends d3chart {
292
293
  .append('path')
293
294
  .attr('class', 'chart__line--hidden')
294
295
  .attr('id', (_, i) => `hiddenArc${i}`)
295
- .attr('d', d => this.middleArcLine(d));
296
+ .attr('d', (d) => this.middleArcLine(d));
296
297
 
297
298
  this.labels = newg
298
299
  .append('text')
@@ -307,7 +308,7 @@ class d3sunburst extends d3chart {
307
308
  .append('textPath')
308
309
  .attr('startOffset', '50%')
309
310
  .attr('xlink:href', (_, i) => `#hiddenArc${i}`)
310
- .text(d => d.data.name);
311
+ .text((d) => d.data.name);
311
312
  }
312
313
 
313
314
  /**
@@ -317,13 +318,13 @@ class d3sunburst extends d3chart {
317
318
  this.itemg
318
319
  .selectAll('.chart__slice')
319
320
  .transition(this.transition)
320
- .attrTween('d', d => {
321
- const d2 = this.hData.filter(j => j.data.name === d.data.name)[0];
321
+ .attrTween('d', (d) => {
322
+ const d2 = this.hData.filter((j) => j.data.name === d.data.name)[0];
322
323
  const iy0 = d3.interpolate(d.y0, d2.y0);
323
324
  const iy1 = d3.interpolate(d.y1, d2.y1);
324
325
  const ix0 = d3.interpolate(d.x0, d2.x0);
325
326
  const ix1 = d3.interpolate(d.x1, d2.x1);
326
- return t => {
327
+ return (t) => {
327
328
  d2.y0 = iy0(t);
328
329
  d2.y1 = iy1(t);
329
330
  d2.x0 = ix0(t);
@@ -331,10 +332,10 @@ class d3sunburst extends d3chart {
331
332
  return this.arc(d2);
332
333
  };
333
334
  })
334
- .style('fill', d => this.colorElement(d.data));
335
+ .style('fill', (d) => this.colorElement(d.data));
335
336
 
336
337
  this.labels
337
- .attr('display', d => (this.textFits(d) ? null : 'none'))
338
+ .attr('display', (d) => (this.textFits(d) ? null : 'none'))
338
339
  .transition(this.transition)
339
340
  .duration(this.cfg.transition.duration / 2)
340
341
  .delay(this.cfg.transition.duration / 2)
@@ -345,11 +346,7 @@ class d3sunburst extends d3chart {
345
346
  * Remove chart's elements without data
346
347
  */
347
348
  exitElements() {
348
- this.itemg
349
- .exit()
350
- .transition(this.transition)
351
- .style('opacity', 0)
352
- .remove();
349
+ this.itemg.exit().transition(this.transition).style('opacity', 0).remove();
353
350
  }
354
351
 
355
352
  /**
@@ -366,7 +363,7 @@ class d3sunburst extends d3chart {
366
363
  * Transition slice on focus
367
364
  */
368
365
  focusOn(d) {
369
- const d2 = this.hData.filter(j => j.data.name === d.data.name)[0];
366
+ const d2 = this.hData.filter((j) => j.data.name === d.data.name)[0];
370
367
  const transition = this.svg
371
368
  .transition()
372
369
  .duration(this.cfg.transition.duration)
@@ -374,24 +371,24 @@ class d3sunburst extends d3chart {
374
371
  .tween('scale', () => {
375
372
  const xd = d3.interpolate(this.xScale.domain(), [d2.x0, d2.x1]);
376
373
  const yd = d3.interpolate(this.yScale.domain(), [d2.y0, 1]);
377
- return t => {
374
+ return (t) => {
378
375
  this.xScale.domain(xd(t));
379
376
  this.yScale.domain(yd(t));
380
377
  };
381
378
  });
382
379
 
383
- transition.selectAll('.chart__slice').attrTween('d', d => () => {
384
- const d3 = this.hData.filter(j => j.data.name === d.data.name)[0];
380
+ transition.selectAll('.chart__slice').attrTween('d', (d) => () => {
381
+ const d3 = this.hData.filter((j) => j.data.name === d.data.name)[0];
385
382
  return this.arc(d3);
386
383
  });
387
384
 
388
- transition.selectAll('.chart__line--hidden').attrTween('d', da => () => {
389
- const d2 = this.hData.filter(j => j.data.name === da.data.name)[0];
385
+ transition.selectAll('.chart__line--hidden').attrTween('d', (da) => () => {
386
+ const d2 = this.hData.filter((j) => j.data.name === da.data.name)[0];
390
387
  return this.middleArcLine(d2);
391
388
  });
392
389
 
393
- transition.selectAll('.chart__labels').attrTween('display', da => () => {
394
- const d2 = this.hData.filter(j => j.data.name === da.data.name)[0];
390
+ transition.selectAll('.chart__labels').attrTween('display', (da) => () => {
391
+ const d2 = this.hData.filter((j) => j.data.name === da.data.name)[0];
395
392
  return this.textFits(d2) ? null : 'none';
396
393
  });
397
394
  }