@decidables/prospectable-elements 0.5.1 → 0.6.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/prospectable-elements",
3
- "version": "0.5.1",
3
+ "version": "0.6.0",
4
4
  "description": "prospectable-elements: Web Components for visualizing Cumulative Prospect Theory",
5
5
  "keywords": [
6
6
  "web component",
@@ -49,6 +49,7 @@
49
49
  "lib"
50
50
  ],
51
51
  "scripts": {
52
+ "clean": "gulp clean",
52
53
  "lint": "gulp lint",
53
54
  "test": "gulp test -X \"$@\"",
54
55
  "build": "gulp build"
@@ -57,15 +58,15 @@
57
58
  "gulp": "^5.0.1"
58
59
  },
59
60
  "dependencies": {
60
- "@decidables/decidables-elements": "^0.5.6",
61
- "@decidables/prospectable-math": "^0.3.5",
62
- "@lit-labs/motion": "^1.0.9",
61
+ "@decidables/decidables-elements": "^0.6.0",
62
+ "@decidables/prospectable-math": "^0.3.6",
63
+ "@lit-labs/motion": "^1.1.0",
63
64
  "@observablehq/plot": "^0.6.17",
64
65
  "bayes.js": "https://github.com/akrawitz/bayes.js.git#commit=c7b091b75f85a86b6a3965a983b31e23d9ef456f",
65
66
  "color": "^5.0.3",
66
67
  "d3": "^7.9.0",
67
- "d3-3d": "^1.0.0",
68
- "lit": "^3.3.1"
68
+ "d3-3d": "^2.0.0",
69
+ "lit": "^3.3.2"
69
70
  },
70
- "gitHead": "16663799cd51d3f2963d98c72ebb140c92c5dc79"
71
+ "gitHead": "72981c711111354170ece1e403d497073da7be96"
71
72
  }
@@ -92,6 +92,7 @@ export default class CPTParameters extends ProspectableElement {
92
92
 
93
93
  decidables-slider {
94
94
  line-height: 1;
95
+
95
96
  text-align: center;
96
97
  }
97
98
 
@@ -275,9 +275,9 @@ export default class CPTProbability extends DecidablesMixinResizeable(Prospectab
275
275
 
276
276
  .curve.interactive {
277
277
  cursor: nwse-resize;
278
+ outline: none;
278
279
 
279
280
  filter: url("#shadow-2");
280
- outline: none;
281
281
  }
282
282
 
283
283
  .curve.interactive:hover {
@@ -295,7 +295,7 @@ export default class CPTProbability extends DecidablesMixinResizeable(Prospectab
295
295
  transform: translateY(0);
296
296
  }
297
297
 
298
- :host(.keyboard) .curve.interactive:focus {
298
+ .curve.interactive:focus-visible {
299
299
  filter: url("#shadow-8");
300
300
 
301
301
  /* HACK: This gets Safari to correctly apply the filter! */
@@ -304,9 +304,9 @@ export default class CPTProbability extends DecidablesMixinResizeable(Prospectab
304
304
 
305
305
  .point.interactive {
306
306
  cursor: nesw-resize;
307
+ outline: none;
307
308
 
308
309
  filter: url("#shadow-2");
309
- outline: none;
310
310
 
311
311
  /* HACK: This gets Safari to correctly apply the filter! */
312
312
  stroke: #000000;
@@ -328,7 +328,7 @@ export default class CPTProbability extends DecidablesMixinResizeable(Prospectab
328
328
  stroke: #00ff00;
329
329
  }
330
330
 
331
- :host(.keyboard) .point.interactive:focus {
331
+ .point.interactive:focus-visible {
332
332
  filter: url("#shadow-8");
333
333
 
334
334
  /* HACK: This gets Safari to correctly apply the filter! */
@@ -362,8 +362,8 @@ export default class CPTProbability extends DecidablesMixinResizeable(Prospectab
362
362
 
363
363
  .diagonal {
364
364
  stroke: var(---color-element-border);
365
- stroke-dasharray: 4;
366
365
  stroke-width: 1;
366
+ stroke-dasharray: 4;
367
367
  }
368
368
 
369
369
  .curve {
@@ -396,8 +396,8 @@ export default class CPTProbability extends DecidablesMixinResizeable(Prospectab
396
396
  font-size: 0.75rem;
397
397
 
398
398
  dominant-baseline: middle;
399
- text-anchor: middle;
400
399
 
400
+ text-anchor: middle;
401
401
  fill: var(---color-text-inverse);
402
402
  }
403
403
 
@@ -409,8 +409,8 @@ export default class CPTProbability extends DecidablesMixinResizeable(Prospectab
409
409
 
410
410
  @media (pointer: coarse) {
411
411
  .interactive .touch {
412
- stroke-linecap: round;
413
412
  stroke-width: 12;
413
+ stroke-linecap: round;
414
414
  }
415
415
  }
416
416
  `,
@@ -327,6 +327,7 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
327
327
  font-weight: 600;
328
328
 
329
329
  alignment-baseline: middle;
330
+
330
331
  text-anchor: middle;
331
332
  }
332
333
 
@@ -350,6 +351,7 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
350
351
  font-size: 0.75rem;
351
352
 
352
353
  alignment-baseline: middle;
354
+
353
355
  text-anchor: end;
354
356
  }
355
357
 
@@ -390,6 +392,7 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
390
392
  font-weight: 600;
391
393
 
392
394
  alignment-baseline: middle;
395
+
393
396
  text-anchor: middle;
394
397
  }
395
398
 
@@ -474,7 +477,7 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
474
477
  };
475
478
  const startRotationX = (-0.85 * Math.PI) / 8;
476
479
  const startRotationY = (3 * Math.PI) / 8;
477
- const startRotationZ = 0;
480
+ const startRotationZ = 0.0000001; // Avoid d3-3d bug
478
481
 
479
482
  const lineStrips3D = d33d.lineStrips3D()
480
483
  .origin(startOrigin)
@@ -578,21 +581,24 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
578
581
  lineStrips3D
579
582
  .x((datum) => { return datum.x; })
580
583
  .y(() => { return yScale.range()[0]; })
581
- .z(() => { return zScale.range()[0]; })(xAxis),
584
+ .z(() => { return zScale.range()[0]; })
585
+ .data(xAxis),
582
586
  );
583
587
  const axisYUpdate = svgMerge.selectAll('.axis-y')
584
588
  .data(
585
589
  lineStrips3D
586
590
  .x(() => { return xScale.range()[0]; })
587
591
  .y((datum) => { return datum.y; })
588
- .z(() => { return zScale.range()[1]; })(yAxis),
592
+ .z(() => { return zScale.range()[1]; })
593
+ .data(yAxis),
589
594
  );
590
595
  const axisZUpdate = svgMerge.selectAll('.axis-z')
591
596
  .data(
592
597
  lineStrips3D
593
598
  .x(() => { return xScale.range()[0]; })
594
599
  .y(() => { return yScale.range()[0]; })
595
- .z((datum) => { return datum.z; })(zAxis),
600
+ .z((datum) => { return datum.z; })
601
+ .data(zAxis),
596
602
  );
597
603
  // ENTER
598
604
  const axisXEnter = axisXUpdate.enter().append('path')
@@ -622,7 +628,8 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
622
628
  return datum.id === 'min' ? datum.x - this.rem * 20 : datum.x + this.rem * 20;
623
629
  })
624
630
  .y(() => { return yScale.range()[0] + this.rem * 1.75; })
625
- .z(() => { return zScale.range()[0] + this.rem * 1.75; })(xAxis),
631
+ .z(() => { return zScale.range()[0] + this.rem * 1.75; })
632
+ .data(xAxis),
626
633
  );
627
634
  const titlePathYUpdate = svgMerge.selectAll('.title-path-y')
628
635
  .data(
@@ -631,7 +638,8 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
631
638
  .y((datum) => {
632
639
  return datum.id === 'min' ? datum.y + this.rem * 20 : datum.y - this.rem * 20;
633
640
  })
634
- .z(() => { return zScale.range()[1] - this.rem * 1.75; })(yAxis),
641
+ .z(() => { return zScale.range()[1] - this.rem * 1.75; })
642
+ .data(yAxis),
635
643
  );
636
644
  const titlePathZUpdate = svgMerge.selectAll('.title-path-z')
637
645
  .data(
@@ -640,21 +648,40 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
640
648
  .y(() => { return yScale.range()[0] + this.rem * 1.75; })
641
649
  .z((datum) => {
642
650
  return datum.id === 'min' ? datum.z - this.rem * 20 : datum.z + this.rem * 20;
643
- })(zAxis),
651
+ })
652
+ .data(zAxis),
644
653
  );
645
654
  const titleXUpdate = svgMerge.selectAll('.title-x')
646
655
  .data(
647
- xAxis,
656
+ lineStrips3D
657
+ .x((datum) => {
658
+ return datum.id === 'min' ? datum.x - this.rem * 20 : datum.x + this.rem * 20;
659
+ })
660
+ .y(() => { return yScale.range()[0] + this.rem * 1.75; })
661
+ .z(() => { return zScale.range()[0] + this.rem * 1.75; })
662
+ .data(xAxis),
648
663
  (datum) => { return datum[0].title; },
649
664
  );
650
665
  const titleYUpdate = svgMerge.selectAll('.title-y')
651
666
  .data(
652
- yAxis,
667
+ lineStrips3D
668
+ .x(() => { return xScale.range()[0] - this.rem * 1.75; })
669
+ .y((datum) => {
670
+ return datum.id === 'min' ? datum.y + this.rem * 20 : datum.y - this.rem * 20;
671
+ })
672
+ .z(() => { return zScale.range()[1] - this.rem * 1.75; })
673
+ .data(yAxis),
653
674
  (datum) => { return datum[0].title; },
654
675
  );
655
676
  const titleZUpdate = svgMerge.selectAll('.title-z')
656
677
  .data(
657
- zAxis,
678
+ lineStrips3D
679
+ .x(() => { return xScale.range()[0] - this.rem * 1.75; })
680
+ .y(() => { return yScale.range()[0] + this.rem * 1.75; })
681
+ .z((datum) => {
682
+ return datum.id === 'min' ? datum.z - this.rem * 20 : datum.z + this.rem * 20;
683
+ })
684
+ .data(zAxis),
658
685
  (datum) => { return datum[0].title; },
659
686
  );
660
687
  // ENTER
@@ -741,7 +768,8 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
741
768
  })
742
769
  .z((datum) => {
743
770
  return datum.id === 'min' ? zScale.range()[0] : zScale.range()[0] + this.rem * 0.35;
744
- })(xTicks),
771
+ })
772
+ .data(xTicks),
745
773
  );
746
774
  const ticksYUpdate = svgMerge.selectAll('.tick-y')
747
775
  .data(
@@ -752,7 +780,8 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
752
780
  .y((datum) => { return datum.y; })
753
781
  .z((datum) => {
754
782
  return datum.id === 'min' ? zScale.range()[1] : zScale.range()[1] - this.rem * 0.35;
755
- })(yTicks),
783
+ })
784
+ .data(yTicks),
756
785
  );
757
786
  const ticksZUpdate = svgMerge.selectAll('.tick-z')
758
787
  .data(
@@ -763,7 +792,8 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
763
792
  .y((datum) => {
764
793
  return datum.id === 'min' ? yScale.range()[0] : yScale.range()[0] + this.rem * 0.35;
765
794
  })
766
- .z((datum) => { return datum.z; })(zTicks),
795
+ .z((datum) => { return datum.z; })
796
+ .data(zTicks),
767
797
  );
768
798
  // ENTER
769
799
  const ticksXEnter = ticksXUpdate.enter().append('path')
@@ -799,7 +829,8 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
799
829
  return datum.id === 'min'
800
830
  ? zScale.range()[0] + this.rem * 4
801
831
  : zScale.range()[0] + this.rem * 0.5;
802
- })(xTicks),
832
+ })
833
+ .data(xTicks),
803
834
  (datum) => { return datum[0].label; },
804
835
  );
805
836
  const labelPathsYUpdate = svgMerge.selectAll('.label-path-y')
@@ -815,7 +846,8 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
815
846
  return datum.id === 'min'
816
847
  ? zScale.range()[1] - this.rem * 0.5
817
848
  : zScale.range()[1] - this.rem * 4;
818
- })(yTicks),
849
+ })
850
+ .data(yTicks),
819
851
  (datum) => { return datum[0].label; },
820
852
  );
821
853
  const labelPathsZUpdate = svgMerge.selectAll('.label-path-z')
@@ -831,22 +863,59 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
831
863
  ? yScale.range()[0] + this.rem * 4
832
864
  : yScale.range()[0] + this.rem * 0.5;
833
865
  })
834
- .z((datum) => { return datum.z; })(zTicks),
866
+ .z((datum) => { return datum.z; })
867
+ .data(zTicks),
835
868
  (datum) => { return datum[0].label; },
836
869
  );
837
870
  const labelsXUpdate = svgMerge.selectAll('.label-x')
838
871
  .data(
839
- xTicks,
872
+ lineStrips3D
873
+ .x((datum) => { return datum.x; })
874
+ .y((datum) => {
875
+ return datum.id === 'min'
876
+ ? yScale.range()[0] + this.rem * 4
877
+ : yScale.range()[0] + this.rem * 0.5;
878
+ })
879
+ .z((datum) => {
880
+ return datum.id === 'min'
881
+ ? zScale.range()[0] + this.rem * 4
882
+ : zScale.range()[0] + this.rem * 0.5;
883
+ })
884
+ .data(xTicks),
840
885
  (datum) => { return datum[0].label; },
841
886
  );
842
887
  const labelsYUpdate = svgMerge.selectAll('.label-y')
843
888
  .data(
844
- yTicks,
889
+ lineStrips3D
890
+ .x((datum) => {
891
+ return datum.id === 'min'
892
+ ? xScale.range()[0] - this.rem * 0.5
893
+ : xScale.range()[0] - this.rem * 4;
894
+ })
895
+ .y((datum) => { return datum.y; })
896
+ .z((datum) => {
897
+ return datum.id === 'min'
898
+ ? zScale.range()[1] - this.rem * 0.5
899
+ : zScale.range()[1] - this.rem * 4;
900
+ })
901
+ .data(yTicks),
845
902
  (datum) => { return datum[0].label; },
846
903
  );
847
904
  const labelsZUpdate = svgMerge.selectAll('.label-z')
848
905
  .data(
849
- zTicks,
906
+ lineStrips3D
907
+ .x((datum) => {
908
+ return datum.id === 'min'
909
+ ? xScale.range()[0] - this.rem * 4
910
+ : xScale.range()[0] - this.rem * 0.5;
911
+ })
912
+ .y((datum) => {
913
+ return datum.id === 'min'
914
+ ? yScale.range()[0] + this.rem * 4
915
+ : yScale.range()[0] + this.rem * 0.5;
916
+ })
917
+ .z((datum) => { return datum.z; })
918
+ .data(zTicks),
850
919
  (datum) => { return datum[0].label; },
851
920
  );
852
921
  // ENTER
@@ -908,7 +977,8 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
908
977
  points3d
909
978
  .x((datum) => { return xScale(datum.a); })
910
979
  .y((datum) => { return yScale(datum.g); })
911
- .z((datum) => { return zScale(datum.l); })(
980
+ .z((datum) => { return zScale(datum.l); })
981
+ .data(
912
982
  this.point
913
983
  ? [{
914
984
  a: this.a,
@@ -987,7 +1057,8 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
987
1057
  .rows(d3.range(this.range.g.start, this.range.g.stop + 0.01, this.range.g.step).length)
988
1058
  .x((datum) => { return xScale(datum.a); })
989
1059
  .y((datum) => { return yScale(datum.g); })
990
- .z((datum) => { return zScale(datum.l); })(this.boundary)
1060
+ .z((datum) => { return zScale(datum.l); })
1061
+ .data(this.boundary)
991
1062
  .filter((datum) => {
992
1063
  return (
993
1064
  (datum[0].a >= this.range.a.start && datum[0].a <= this.range.a.stop)
@@ -1024,7 +1095,8 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
1024
1095
  .rows(d3.range(this.range.g.start, this.range.g.stop + 0.01, this.range.g.step).length)
1025
1096
  .x((datum) => { return xScale(datum.a); })
1026
1097
  .y((datum) => { return yScale(datum.g); })
1027
- .z((datum) => { return zScale(datum.l); })(this.mapXY),
1098
+ .z((datum) => { return zScale(datum.l); })
1099
+ .data(this.mapXY),
1028
1100
  );
1029
1101
  const mapXZUpdate = svgMerge.selectAll('.map-xz')
1030
1102
  .data(
@@ -1032,7 +1104,8 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
1032
1104
  .rows(d3.range(this.range.l.start, this.range.l.stop + 0.01, this.range.l.step).length)
1033
1105
  .x((datum) => { return xScale(datum.a); })
1034
1106
  .y((datum) => { return yScale(datum.g); })
1035
- .z((datum) => { return zScale(datum.l); })(this.mapXZ),
1107
+ .z((datum) => { return zScale(datum.l); })
1108
+ .data(this.mapXZ),
1036
1109
  );
1037
1110
  const mapYZUpdate = svgMerge.selectAll('.map-yz')
1038
1111
  .data(
@@ -1040,7 +1113,8 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
1040
1113
  .rows(d3.range(this.range.l.start, this.range.l.stop + 0.01, this.range.l.step).length)
1041
1114
  .x((datum) => { return xScale(datum.a); })
1042
1115
  .y((datum) => { return yScale(datum.g); })
1043
- .z((datum) => { return zScale(datum.l); })(this.mapYZ),
1116
+ .z((datum) => { return zScale(datum.l); })
1117
+ .data(this.mapYZ),
1044
1118
  );
1045
1119
  // ENTER
1046
1120
  const mapXYEnter = mapXYUpdate.enter().append('path')
@@ -1089,7 +1163,7 @@ export default class CPTSpace extends DecidablesMixinResizeable(ProspectableElem
1089
1163
  mapYZUpdate.exit().remove();
1090
1164
 
1091
1165
  // Depth sorting
1092
- d3.select(this.renderRoot).selectAll('.d3-3d').sort(points3d.sort);
1166
+ d3.select(this.renderRoot).selectAll('.d3-3d').sort(d33d.sort);
1093
1167
 
1094
1168
  // Color Legend
1095
1169
  // DATA-JOIN
@@ -289,9 +289,9 @@ export default class CPTValue extends DecidablesMixinResizeable(ProspectableElem
289
289
  .curve-p.interactive,
290
290
  .curve-n.interactive {
291
291
  cursor: nwse-resize;
292
+ outline: none;
292
293
 
293
294
  filter: url("#shadow-2");
294
- outline: none;
295
295
  }
296
296
 
297
297
  .curve-p.interactive:hover,
@@ -311,8 +311,8 @@ export default class CPTValue extends DecidablesMixinResizeable(ProspectableElem
311
311
  transform: translateY(0);
312
312
  }
313
313
 
314
- :host(.keyboard) .curve-p.interactive:focus,
315
- :host(.keyboard) .curve-n.interactive:focus {
314
+ .curve-p.interactive:focus-visible,
315
+ .curve-n.interactive:focus-visible {
316
316
  filter: url("#shadow-8");
317
317
 
318
318
  /* HACK: This gets Safari to correctly apply the filter! */
@@ -321,9 +321,9 @@ export default class CPTValue extends DecidablesMixinResizeable(ProspectableElem
321
321
 
322
322
  .point.interactive {
323
323
  cursor: nesw-resize;
324
+ outline: none;
324
325
 
325
326
  filter: url("#shadow-2");
326
- outline: none;
327
327
 
328
328
  /* HACK: This gets Safari to correctly apply the filter! */
329
329
  stroke: #000000;
@@ -345,7 +345,7 @@ export default class CPTValue extends DecidablesMixinResizeable(ProspectableElem
345
345
  stroke: #00ff00;
346
346
  }
347
347
 
348
- :host(.keyboard) .point.interactive:focus {
348
+ .point.interactive:focus-visible {
349
349
  filter: url("#shadow-8");
350
350
 
351
351
  /* HACK: This gets Safari to correctly apply the filter! */
@@ -385,8 +385,8 @@ export default class CPTValue extends DecidablesMixinResizeable(ProspectableElem
385
385
 
386
386
  .diagonal {
387
387
  stroke: var(---color-element-border);
388
- stroke-dasharray: 4;
389
388
  stroke-width: 1;
389
+ stroke-dasharray: 4;
390
390
  }
391
391
 
392
392
  .curve-p,
@@ -420,8 +420,8 @@ export default class CPTValue extends DecidablesMixinResizeable(ProspectableElem
420
420
  font-size: 0.75rem;
421
421
 
422
422
  dominant-baseline: middle;
423
- text-anchor: middle;
424
423
 
424
+ text-anchor: middle;
425
425
  fill: var(---color-text-inverse);
426
426
  }
427
427
 
@@ -433,8 +433,8 @@ export default class CPTValue extends DecidablesMixinResizeable(ProspectableElem
433
433
 
434
434
  @media (pointer: coarse) {
435
435
  .interactive .touch {
436
- stroke-linecap: round;
437
436
  stroke-width: 12;
437
+ stroke-linecap: round;
438
438
  }
439
439
  }
440
440
  `,