@decidables/accumulable-elements 0.3.4 → 0.3.5

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.
@@ -8111,8 +8111,13 @@
8111
8111
  }
8112
8112
  }
8113
8113
 
8114
- .measure {
8115
- stroke-width: 2;
8114
+ .measure .line.short {
8115
+ stroke-width: 0;
8116
+ }
8117
+
8118
+ .measure .markers {
8119
+ fill: none;
8120
+ stroke-width: 0;
8116
8121
  }
8117
8122
 
8118
8123
  .measure .label {
@@ -8130,12 +8135,6 @@
8130
8135
  text-anchor: end;
8131
8136
  }
8132
8137
 
8133
- /* Hack to avoid lack of context-stroke and context-fill in Safari */
8134
- .measure-arrow.a {
8135
- fill: var(---color-a);
8136
- stroke: var(---color-a);
8137
- }
8138
-
8139
8138
  .measure.z .line {
8140
8139
  stroke: var(---color-z);
8141
8140
  }
@@ -8147,12 +8146,6 @@
8147
8146
  text-anchor: start;
8148
8147
  }
8149
8148
 
8150
- /* Hack to avoid lack of context-stroke and context-fill in Safari */
8151
- .measure-arrow.z {
8152
- fill: var(---color-z);
8153
- stroke: var(---color-z);
8154
- }
8155
-
8156
8149
  .measure.v .line {
8157
8150
  stroke: var(---color-v);
8158
8151
  }
@@ -8162,12 +8155,6 @@
8162
8155
  text-anchor: start;
8163
8156
  }
8164
8157
 
8165
- /* Hack to avoid lack of context-stroke and context-fill in Safari */
8166
- .measure-arrow.v {
8167
- fill: var(---color-v);
8168
- stroke: var(---color-v);
8169
- }
8170
-
8171
8158
  .measure.t0 .line {
8172
8159
  stroke: var(---color-t0);
8173
8160
  }
@@ -8177,6 +8164,37 @@
8177
8164
  text-anchor: middle;
8178
8165
  }
8179
8166
 
8167
+ .measure-arrow {
8168
+ fill: context-stroke;
8169
+ stroke: context-stroke;
8170
+ }
8171
+
8172
+ .measure-arrow .arrow {
8173
+ stroke-width: 1;
8174
+ }
8175
+
8176
+ .measure-arrow.capped .cap {
8177
+ stroke-width: 2;
8178
+ }
8179
+
8180
+ /* Hack to avoid lack of context-stroke and context-fill in Safari */
8181
+ .measure-arrow.a {
8182
+ fill: var(---color-a);
8183
+ stroke: var(---color-a);
8184
+ }
8185
+
8186
+ /* Hack to avoid lack of context-stroke and context-fill in Safari */
8187
+ .measure-arrow.z {
8188
+ fill: var(---color-z);
8189
+ stroke: var(---color-z);
8190
+ }
8191
+
8192
+ /* Hack to avoid lack of context-stroke and context-fill in Safari */
8193
+ .measure-arrow.v {
8194
+ fill: var(---color-v);
8195
+ stroke: var(---color-v);
8196
+ }
8197
+
8180
8198
  /* Hack to avoid lack of context-stroke and context-fill in Safari */
8181
8199
  .measure-arrow.t0 {
8182
8200
  fill: var(---color-t0);
@@ -8443,19 +8461,19 @@
8443
8461
  // Arrowhead marker for measures
8444
8462
  const measureArrow = parameter => {
8445
8463
  /* Hack to avoid lack of context-stroke and context-fill in Safari */
8446
- svgDefs.append('marker').attr('id', `measure-arrow-${parameter}`).attr('class', `measure-arrow ${parameter}`).attr('orient', 'auto-start-reverse').attr('markerUnits', 'userSpaceOnUse').attr('viewBox', '-5 -5 10 10').attr('refX', '2').attr('refY', '0').attr('markerWidth', '10').attr('markerHeight', '10').append('path').attr('stroke', 'context-stroke').attr('fill', 'context-stroke').attr('d', 'M -3 -3 l 6 3 l -6 3 z');
8464
+ svgDefs.append('marker').attr('id', `measure-arrow-${parameter}`).attr('class', `measure-arrow ${parameter}`).attr('orient', 'auto-start-reverse').attr('markerUnits', 'userSpaceOnUse').attr('viewBox', '-10 -6 12 12').attr('refX', '0').attr('refY', '0').attr('markerWidth', '12').attr('markerHeight', '12').append('path').attr('class', 'arrow').attr('d', 'M -7 -3 l 6 3 l -6 3 z');
8447
8465
  };
8448
- const measureArrowCap = parameter => {
8466
+ const measureCappedArrow = parameter => {
8449
8467
  /* Hack to avoid lack of context-stroke and context-fill in Safari */
8450
- const marker = svgDefs.append('marker').attr('id', `measure-arrow-cap-${parameter}`).attr('class', `measure-arrow cap ${parameter}`).attr('orient', 'auto-start-reverse').attr('markerUnits', 'userSpaceOnUse').attr('viewBox', '-5 -5 10 10').attr('refX', '2').attr('refY', '0').attr('markerWidth', '10').attr('markerHeight', '10');
8451
- marker.append('path').attr('stroke', 'context-stroke').attr('fill', 'context-stroke').attr('d', 'M -3 -3 l 6 3 l -6 3 z');
8452
- marker.append('path').attr('stroke', 'context-stroke').attr('fill', 'context-stroke').attr('stroke-width', '2').attr('d', 'M 4 -4 l 0 8');
8468
+ const marker = svgDefs.append('marker').attr('id', `measure-capped-arrow-${parameter}`).attr('class', `measure-arrow capped ${parameter}`).attr('orient', 'auto-start-reverse').attr('markerUnits', 'userSpaceOnUse').attr('viewBox', '-10 -6 12 12').attr('refX', '0').attr('refY', '0').attr('markerWidth', '12').attr('markerHeight', '12');
8469
+ marker.append('path').attr('class', 'arrow').attr('d', 'M -7 -3 l 6 3 l -6 3 z');
8470
+ marker.append('path').attr('class', 'cap').attr('d', 'M 0 -4 l 0 8');
8453
8471
  };
8454
8472
  measureArrow('a');
8455
8473
  measureArrow('z');
8456
- measureArrowCap('v');
8474
+ measureCappedArrow('v');
8457
8475
  measureArrow('t0');
8458
- measureArrowCap('t0');
8476
+ measureCappedArrow('t0');
8459
8477
  // Flat markers for SDs
8460
8478
  const sdCap = outcome => {
8461
8479
  /* Hack to avoid lack of context-stroke and context-fill in Safari */
@@ -9051,20 +9069,27 @@
9051
9069
  // EXIT
9052
9070
  t0zUpdate.exit().remove();
9053
9071
 
9072
+ // Measures
9073
+ const markerCorrection = 2;
9074
+
9054
9075
  // a Measure
9055
9076
  // DATA-JOIN
9056
9077
  const aUpdate = evidenceOverlayerMerge.selectAll('.measure.a').data(this.measures ? [this.a] : []);
9057
9078
  // ENTER
9058
9079
  const aEnter = aUpdate.enter().append('g').classed('measure a', true);
9059
- aEnter.append('line').classed('line', true)
9080
+ aEnter.append('line').classed('line', true);
9081
+ aEnter.append('line').classed('markers', true)
9060
9082
  /* Hack to avoid lack of context-stroke and context-fill in Safari */.attr('marker-start', 'url(#measure-arrow-a)').attr('marker-end', 'url(#measure-arrow-a)');
9061
9083
  const aLabel = aEnter.append('text').classed('label', true);
9062
9084
  aLabel.append('tspan').classed('a math-var', true).text('a');
9063
9085
  aLabel.append('tspan').classed('equals', true).text(' = ');
9064
9086
  aLabel.append('tspan').classed('value', true);
9065
9087
  // MERGE
9088
+ const aLength = Math.abs(evidenceScale(this.bounds.upper) - evidenceScale(this.bounds.lower));
9089
+ const aShort = aLength <= markerCorrection * 2;
9066
9090
  const aMerge = aEnter.merge(aUpdate);
9067
- aMerge.select('.line').transition().duration(this.drag ? 0 : transitionDuration).ease(cubicOut).attr('x1', timeScale(this.scale.time.max) - this.rem * 0.75).attr('y1', evidenceScale(this.bounds.upper) + 2).attr('x2', timeScale(this.scale.time.max) - this.rem * 0.75).attr('y2', evidenceScale(this.bounds.lower) - 2);
9091
+ aMerge.select('.line').classed('short', aShort).transition().duration(this.drag ? 0 : transitionDuration).ease(cubicOut).attr('x1', timeScale(this.scale.time.max) - this.rem * 0.75).attr('y1', evidenceScale(this.bounds.upper) + markerCorrection).attr('x2', timeScale(this.scale.time.max) - this.rem * 0.75).attr('y2', evidenceScale(this.bounds.lower) - markerCorrection);
9092
+ aMerge.select('.markers').transition().duration(this.drag ? 0 : transitionDuration).ease(cubicOut).attr('x1', timeScale(this.scale.time.max) - this.rem * 0.75).attr('y1', evidenceScale(this.bounds.upper)).attr('x2', timeScale(this.scale.time.max) - this.rem * 0.75).attr('y2', evidenceScale(this.bounds.lower));
9068
9093
  const aLabelMerge = aMerge.select('.label').transition().duration(this.drag ? 0 : transitionDuration).ease(cubicOut).attr('x', timeScale(this.scale.time.max)).attr('y', evidenceScale(this.bounds.upper) - this.rem * 0.25);
9069
9094
  aLabelMerge.select('.value').text(format('.2f')(this.a));
9070
9095
  // EXIT
@@ -9075,15 +9100,19 @@
9075
9100
  const zUpdate = evidenceOverlayerMerge.selectAll('.measure.z').data(this.measures ? [this.z] : []);
9076
9101
  // ENTER
9077
9102
  const zEnter = zUpdate.enter().append('g').classed('measure z', true);
9078
- zEnter.append('line').classed('line', true)
9103
+ zEnter.append('line').classed('line', true);
9104
+ zEnter.append('line').classed('markers', true)
9079
9105
  /* Hack to avoid lack of context-stroke and context-fill in Safari */.attr('marker-start', 'url(#measure-arrow-z)').attr('marker-end', 'url(#measure-arrow-z)');
9080
9106
  const zLabel = zEnter.append('text').classed('label', true);
9081
9107
  zLabel.append('tspan').classed('z math-var', true).text('z');
9082
9108
  zLabel.append('tspan').classed('equals', true).text(' = ');
9083
9109
  zLabel.append('tspan').classed('value', true);
9084
9110
  // MERGE
9111
+ const zLength = Math.abs(evidenceScale(this.startingPoint) - evidenceScale(this.bounds.lower));
9112
+ const zShort = zLength <= markerCorrection * 2;
9085
9113
  const zMerge = zEnter.merge(zUpdate);
9086
- zMerge.select('.line').transition().duration(this.drag ? 0 : transitionDuration).ease(cubicOut).attr('x1', timeScale(this.scale.time.min) + this.rem * 0.75).attr('y1', evidenceScale(this.startingPoint) + 2).attr('x2', timeScale(this.scale.time.min) + this.rem * 0.75).attr('y2', evidenceScale(this.bounds.lower) - 2);
9114
+ zMerge.select('.line').classed('short', zShort).transition().duration(this.drag ? 0 : transitionDuration).ease(cubicOut).attr('x1', timeScale(this.scale.time.min) + this.rem * 0.75).attr('y1', evidenceScale(this.startingPoint) + markerCorrection).attr('x2', timeScale(this.scale.time.min) + this.rem * 0.75).attr('y2', evidenceScale(this.bounds.lower) - markerCorrection);
9115
+ zMerge.select('.markers').transition().duration(this.drag ? 0 : transitionDuration).ease(cubicOut).attr('x1', timeScale(this.scale.time.min) + this.rem * 0.75).attr('y1', evidenceScale(this.startingPoint)).attr('x2', timeScale(this.scale.time.min) + this.rem * 0.75).attr('y2', evidenceScale(this.bounds.lower));
9087
9116
  const zLabelMerge = zMerge.select('.label').transition().duration(this.drag ? 0 : transitionDuration).ease(cubicOut).attr('x', timeScale(this.scale.time.min)).attr('y', evidenceScale(this.bounds.lower) + this.rem * 0.125);
9088
9117
  zLabelMerge.select('.value').text(format('.0%')(this.z));
9089
9118
  // EXIT
@@ -9094,22 +9123,37 @@
9094
9123
  const vUpdate = evidenceOverlayerMerge.selectAll('.measure.v').data(this.measures ? [this.v] : []);
9095
9124
  // ENTER
9096
9125
  const vEnter = vUpdate.enter().append('g').classed('measure v', true);
9097
- vEnter.append('path').classed('line', true)
9098
- /* Hack to avoid lack of context-stroke and context-fill in Safari */.attr('marker-start', 'url(#measure-arrow-cap-v)').attr('marker-end', 'url(#measure-arrow-cap-v)');
9126
+ vEnter.append('path').classed('line', true);
9127
+ vEnter.append('path').classed('markers', true)
9128
+ /* Hack to avoid lack of context-stroke and context-fill in Safari */.attr('marker-start', 'url(#measure-capped-arrow-v)').attr('marker-end', 'url(#measure-capped-arrow-v)');
9099
9129
  const vLabel = vEnter.append('text').classed('label', true);
9100
9130
  vLabel.append('tspan').classed('v math-var', true).text('v');
9101
9131
  vLabel.append('tspan').classed('equals', true).text(' = ');
9102
9132
  vLabel.append('tspan').classed('value', true);
9103
9133
  // MERGE
9134
+ // Full path
9104
9135
  const driftHypotenuse = timeScale(200) - timeScale(0) + this.rem * 0.75;
9105
- const driftCorrection = 2 / driftHypotenuse;
9106
- const driftAngle = Math.atan(this.v / 1000 * scaleRatio) - driftCorrection;
9136
+ const driftAngle = Math.atan(this.v / 1000 * scaleRatio);
9107
9137
  const driftX = Math.cos(driftAngle) * driftHypotenuse;
9108
9138
  const driftY = Math.sin(driftAngle) * driftHypotenuse;
9139
+ // Corrected path
9140
+ const driftCorrection = markerCorrection / driftHypotenuse;
9141
+ const driftAngleCorrected = Math.atan(this.v / 1000 * scaleRatio) - driftCorrection;
9142
+ const driftStartX = Math.cos(driftCorrection) * driftHypotenuse;
9143
+ const driftStartY = Math.sin(driftCorrection) * driftHypotenuse;
9144
+ const driftEndX = Math.cos(driftAngleCorrected) * driftHypotenuse;
9145
+ const driftEndY = Math.sin(driftAngleCorrected) * driftHypotenuse;
9146
+ // Short path?
9147
+ const vLength = driftAngleCorrected * driftHypotenuse;
9148
+ const vShort = vLength <= markerCorrection * 2;
9109
9149
  const vMerge = vEnter.merge(vUpdate);
9110
- vMerge.select('.line').transition().duration(this.drag ? 0 : transitionDuration).ease(cubicOut).attr('d', `
9111
- M ${timeScale(this.t0 + 200) + this.rem * 0.75}, ${evidenceScale(this.startingPoint) - 2}
9112
- A ${timeScale(200) - timeScale(0)} ${timeScale(200) - timeScale(0)} 0 0 0 ${timeScale(this.t0) + driftX} ${evidenceScale(this.startingPoint) - driftY}
9150
+ vMerge.select('.line').classed('short', vShort).transition().duration(this.drag ? 0 : transitionDuration).ease(cubicOut).attr('d', `
9151
+ M ${timeScale(this.t0) + driftStartX}, ${evidenceScale(this.startingPoint) - driftStartY}
9152
+ A ${timeScale(200) - timeScale(0) + this.rem * 0.75} ${timeScale(200) - timeScale(0) + this.rem * 0.75} 0 0 0 ${timeScale(this.t0) + driftEndX} ${evidenceScale(this.startingPoint) - driftEndY}
9153
+ `);
9154
+ vMerge.select('.markers').transition().duration(this.drag ? 0 : transitionDuration).ease(cubicOut).attr('d', `
9155
+ M ${timeScale(this.t0 + 200) + this.rem * 0.75}, ${evidenceScale(this.startingPoint)}
9156
+ A ${timeScale(200) - timeScale(0) + this.rem * 0.75} ${timeScale(200) - timeScale(0) + this.rem * 0.75} 0 0 0 ${timeScale(this.t0) + driftX} ${evidenceScale(this.startingPoint) - driftY}
9113
9157
  `);
9114
9158
  const vLabelMerge = vMerge.select('.label').transition().duration(this.drag ? 0 : transitionDuration).ease(cubicOut).attr('x', timeScale(this.t0 + 200) + this.rem * 0.5).attr('y', evidenceScale(this.bounds.upper) - this.rem * 0.25);
9115
9159
  vLabelMerge.select('.value').text(format('.2f')(this.v));
@@ -9121,15 +9165,19 @@
9121
9165
  const t0Update = evidenceOverlayerMerge.selectAll('.measure.t0').data(this.measures ? [this.t0] : []);
9122
9166
  // ENTER
9123
9167
  const t0Enter = t0Update.enter().append('g').classed('measure t0', true);
9124
- t0Enter.append('line').classed('line', true)
9125
- /* Hack to avoid lack of context-stroke and context-fill in Safari */.attr('marker-start', 'url(#measure-arrow-t0)').attr('marker-end', 'url(#measure-arrow-cap-t0)');
9168
+ t0Enter.append('line').classed('line', true);
9169
+ t0Enter.append('line').classed('markers', true)
9170
+ /* Hack to avoid lack of context-stroke and context-fill in Safari */.attr('marker-start', 'url(#measure-arrow-t0)').attr('marker-end', 'url(#measure-capped-arrow-t0)');
9126
9171
  const t0Label = t0Enter.append('text').classed('label', true);
9127
9172
  t0Label.append('tspan').classed('t0 math-var', true).text('t₀');
9128
9173
  t0Label.append('tspan').classed('equals', true).text(' = ');
9129
9174
  t0Label.append('tspan').classed('value', true);
9130
9175
  // MERGE
9176
+ const t0Length = Math.abs(timeScale(0) - timeScale(this.t0));
9177
+ const t0Short = t0Length <= markerCorrection * 2;
9131
9178
  const t0Merge = t0Enter.merge(t0Update);
9132
- t0Merge.select('.line').transition().duration(this.drag ? 0 : transitionDuration).ease(cubicOut).attr('x1', timeScale(0) + 2).attr('y1', evidenceScale(this.startingPoint) - this.rem * 0.75).attr('x2', timeScale(this.t0) - 2).attr('y2', evidenceScale(this.startingPoint) - this.rem * 0.75);
9179
+ t0Merge.select('.line').classed('short', t0Short).transition().duration(this.drag ? 0 : transitionDuration).ease(cubicOut).attr('x1', timeScale(0) + markerCorrection).attr('y1', evidenceScale(this.startingPoint) - this.rem * 0.75).attr('x2', timeScale(this.t0) - markerCorrection).attr('y2', evidenceScale(this.startingPoint) - this.rem * 0.75);
9180
+ t0Merge.select('.markers').transition().duration(this.drag ? 0 : transitionDuration).ease(cubicOut).attr('x1', timeScale(0)).attr('y1', evidenceScale(this.startingPoint) - this.rem * 0.75).attr('x2', timeScale(this.t0)).attr('y2', evidenceScale(this.startingPoint) - this.rem * 0.75);
9133
9181
  const t0LabelMerge = t0Merge.select('.label').transition().duration(this.drag ? 0 : transitionDuration).ease(cubicOut).attr('x', timeScale(this.t0) + this.rem * 0.25).attr('y', evidenceScale(this.bounds.upper) - this.rem * 0.25);
9134
9182
  t0LabelMerge.select('.value').text(format('d')(this.t0));
9135
9183
  // EXIT