@decidables/detectable-elements 0.4.5 → 0.5.0

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": "@decidables/detectable-elements",
3
- "version": "0.4.5",
3
+ "version": "0.5.0",
4
4
  "description": "detectable-elements: Web Components for visualizing Signal Detection Theory",
5
5
  "keywords": [
6
6
  "web component",
@@ -54,11 +54,13 @@
54
54
  "gulp": "^5.0.1"
55
55
  },
56
56
  "dependencies": {
57
- "@decidables/decidables-elements": "^0.5.5",
57
+ "@decidables/decidables-elements": "^0.5.6",
58
58
  "@decidables/detectable-math": "^0.2.5",
59
+ "color": "^5.0.3",
59
60
  "d3": "^7.9.0",
61
+ "d3-interpolate-path": "^2.3.0",
60
62
  "jstat": "^1.9.6",
61
63
  "lit": "^3.3.1"
62
64
  },
63
- "gitHead": "045955a4696ea4b38440d84d467cad3ddaad812d"
65
+ "gitHead": "8c39b095d6cc3cf6a5f49457048bebf53e7158c1"
64
66
  }
@@ -1,5 +1,5 @@
1
1
 
2
- import {html, css} from 'lit';
2
+ import {css, html} from 'lit';
3
3
 
4
4
  import '@decidables/decidables-elements/button';
5
5
  import '@decidables/decidables-elements/slider';
@@ -1,5 +1,5 @@
1
1
 
2
- import {html, css} from 'lit';
2
+ import {css, html} from 'lit';
3
3
 
4
4
  import '@decidables/decidables-elements/button';
5
5
 
@@ -1,5 +1,5 @@
1
1
 
2
- import {html, css} from 'lit';
2
+ import {css, html} from 'lit';
3
3
 
4
4
  import '@decidables/decidables-elements/spinner';
5
5
  import DecidablesConverterSet from '@decidables/decidables-elements/converter-set';
@@ -1,5 +1,5 @@
1
1
 
2
- import {html, css} from 'lit';
2
+ import {css, html} from 'lit';
3
3
  import * as d3 from 'd3';
4
4
 
5
5
  import {DecidablesMixinResizeable} from '@decidables/decidables-elements';
@@ -1,6 +1,8 @@
1
1
 
2
- import {html, css} from 'lit';
2
+ import {css, html, render} from 'lit';
3
3
  import * as d3 from 'd3';
4
+ import {interpolatePath} from 'd3-interpolate-path';
5
+ import color from 'color';
4
6
 
5
7
  import {DecidablesMixinResizeable} from '@decidables/decidables-elements';
6
8
  import SDTMath from '@decidables/detectable-math';
@@ -362,9 +364,7 @@ export default class ROCSpace extends DecidablesMixinResizeable(DetectableElemen
362
364
  }
363
365
 
364
366
  render() { /* eslint-disable-line class-methods-use-this */
365
- return html`
366
- ${DetectableElement.svgFilters}
367
- `;
367
+ return html``;
368
368
  }
369
369
 
370
370
  willUpdate() {
@@ -477,7 +477,11 @@ export default class ROCSpace extends DecidablesMixinResizeable(DetectableElemen
477
477
  }]);
478
478
  // ENTER
479
479
  const svgEnter = svgUpdate.enter().append('svg')
480
- .classed('main', true);
480
+ .classed('main', true)
481
+ .each((datum, index, nodes) => {
482
+ // Filters for shadows
483
+ render(DetectableElement.svgFilters, nodes[index]);
484
+ });
481
485
  // MERGE
482
486
  const svgMerge = svgEnter.merge(svgUpdate)
483
487
  .attr('viewBox', `0 0 ${elementSize} ${elementSize}`);
@@ -558,23 +562,29 @@ export default class ROCSpace extends DecidablesMixinResizeable(DetectableElemen
558
562
  const contours = d3.contours()
559
563
  .size([n, n])
560
564
  .thresholds(contourThresholds);
561
- const contourColorStart = this.getComputedStyleValue((this.contour === 'bias')
562
- ? '---color-element-background'
563
- : (this.contour === 'sensitivity')
564
- ? '---color-d'
565
- : (this.contour === 'accuracy')
566
- ? '---color-acc-dark'
567
- : null);
568
- const contourColorEnd = this.getComputedStyleValue((this.contour === 'bias')
569
- ? '---color-c'
570
- : (this.contour === 'sensitivity')
565
+ const contourColorStart = this.getComputedStyleValue(
566
+ (this.contour === 'bias')
571
567
  ? '---color-element-background'
572
- : (this.contour === 'accuracy')
568
+ : (this.contour === 'sensitivity')
569
+ ? '---color-d'
570
+ : (this.contour === 'accuracy')
571
+ ? '---color-acc-dark'
572
+ : null,
573
+ );
574
+ const contourColorEnd = this.getComputedStyleValue(
575
+ (this.contour === 'bias')
576
+ ? '---color-c'
577
+ : (this.contour === 'sensitivity')
573
578
  ? '---color-element-background'
574
- : null);
579
+ : (this.contour === 'accuracy')
580
+ ? '---color-element-background'
581
+ : null,
582
+ );
575
583
  const contourColor = d3.scaleLinear()
576
584
  .domain(d3.extent(contourThresholds))
577
- .interpolate(() => { return d3.interpolateRgb(contourColorStart, contourColorEnd); });
585
+ .interpolate(() => {
586
+ return d3.interpolateRgb(color(contourColorStart).hex(), color(contourColorEnd).hex());
587
+ });
578
588
  // DATA-JOIN
579
589
  const contourPlotUpdate = underlayerMerge.selectAll('.plot-contour')
580
590
  .data([this.contour]);
@@ -595,8 +605,15 @@ export default class ROCSpace extends DecidablesMixinResizeable(DetectableElemen
595
605
  contoursEnter.merge(contoursUpdate).transition()
596
606
  .duration(transitionDuration * 2) // Extra long transition!
597
607
  .ease(d3.easeCubicOut)
598
- .attr('d', d3.geoPath(d3.geoIdentity().scale(width / n))) // ????
608
+ // .attr('d', d3.geoPath(d3.geoIdentity().scale(width / n))) // ????
609
+ .attrTween('d', (datum, index, elements) => {
610
+ const element = elements[index];
611
+ const previous = d3.select(element).attr('d');
612
+ const current = d3.geoPath(d3.geoIdentity().scale(width / n))(datum);
613
+ return interpolatePath(previous, current);
614
+ })
599
615
  .attr('fill', (datum) => { return contourColor(datum.value); });
616
+
600
617
  // EXIT
601
618
  contoursUpdate.exit().remove();
602
619
 
@@ -1,5 +1,5 @@
1
1
 
2
- import {html, css} from 'lit';
2
+ import {css, html, render} from 'lit';
3
3
  import * as d3 from 'd3';
4
4
  import jStat from 'jstat';
5
5
 
@@ -269,6 +269,7 @@ export default class SDTModel extends DecidablesMixinResizeable(DetectableElemen
269
269
  filter: url("#shadow-4");
270
270
 
271
271
  /* HACK: This gets Safari to correctly apply the filter! */
272
+ /* https://github.com/emilbjorklund/svg-weirdness/issues/27 */
272
273
  transform: translateX(0);
273
274
  }
274
275
 
@@ -459,9 +460,7 @@ export default class SDTModel extends DecidablesMixinResizeable(DetectableElemen
459
460
  }
460
461
 
461
462
  render() { /* eslint-disable-line class-methods-use-this */
462
- return html`
463
- ${DetectableElement.svgFilters}
464
- `;
463
+ return html``;
465
464
  }
466
465
 
467
466
  sendEvent() {
@@ -665,7 +664,11 @@ export default class SDTModel extends DecidablesMixinResizeable(DetectableElemen
665
664
  }]);
666
665
  // ENTER
667
666
  const svgEnter = svgUpdate.enter().append('svg')
668
- .classed('main', true);
667
+ .classed('main', true)
668
+ .each((datum, index, nodes) => {
669
+ // Filters for shadows
670
+ render(DetectableElement.svgFilters, nodes[index]);
671
+ });
669
672
  // MERGE
670
673
  const svgMerge = svgEnter.merge(svgUpdate)
671
674
  .attr('viewBox', `0 0 ${elementWidth} ${elementHeight}`);
@@ -1,5 +1,5 @@
1
1
 
2
- import {html, css} from 'lit';
2
+ import {css, html} from 'lit';
3
3
 
4
4
  import '@decidables/decidables-elements/slider';
5
5
  import SDTMath from '@decidables/detectable-math';
@@ -1,5 +1,5 @@
1
1
 
2
- import {html, css} from 'lit';
2
+ import {css, html} from 'lit';
3
3
 
4
4
  import DetectableElement from '../detectable-element';
5
5