@mark1russell7/site-pages 0.5.2 → 0.5.4
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/README.md +1 -0
- package/build/chrome.d.ts +7 -1
- package/build/chrome.d.ts.map +1 -1
- package/build/chrome.js +21 -2
- package/build/chrome.js.map +1 -1
- package/build/config/site-config.d.ts +114 -0
- package/build/config/site-config.d.ts.map +1 -0
- package/build/config/site-config.js +211 -0
- package/build/config/site-config.js.map +1 -0
- package/build/explorer/index.d.ts.map +1 -1
- package/build/explorer/index.js +45 -51
- package/build/explorer/index.js.map +1 -1
- package/package.json +6 -1
package/build/explorer/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { h } from "../chrome.js";
|
|
1
|
+
import { h, svg } from "../chrome.js";
|
|
2
2
|
import { heldOutError, parseResponseRecord, quantile, responseCells, sliceResponse, surfaceResponse, whenHolds } from "@mark1russell7/rigor-statistics";
|
|
3
3
|
// src/explorer/model.ts
|
|
4
4
|
/**
|
|
@@ -705,7 +705,6 @@ function numberTable(view, panel) {
|
|
|
705
705
|
* The DOM view of the response explorer. This module draws SVG with no framework. The core in `model.ts` gives each
|
|
706
706
|
* rule and each number, and this module connects the core to the page.
|
|
707
707
|
*/
|
|
708
|
-
const SVG = "http://www.w3.org/2000/svg";
|
|
709
708
|
/** The most faults that the view lists. */
|
|
710
709
|
const MAX_FAULTS = 20;
|
|
711
710
|
/** The width of a chart with no layout, for example in a test. */
|
|
@@ -719,13 +718,6 @@ const MARGIN = {
|
|
|
719
718
|
/** The height of a line of text of an axis, in pixels. */
|
|
720
719
|
const CHAR_WIDTH = 6.4;
|
|
721
720
|
let mounts = 0;
|
|
722
|
-
/** This function makes an SVG element with attributes and children. */
|
|
723
|
-
function s(tag, attrs, ...children) {
|
|
724
|
-
const el = document.createElementNS(SVG, tag);
|
|
725
|
-
for (const [name, value] of Object.entries(attrs)) el.setAttribute(name, String(value));
|
|
726
|
-
el.append(...children);
|
|
727
|
-
return el;
|
|
728
|
-
}
|
|
729
721
|
/** This function gives the plot of a chart. Long level names need room for their turned text. */
|
|
730
722
|
function plotOf(width, height, view) {
|
|
731
723
|
const turned = turnedLevels(view.x, width - MARGIN.left - MARGIN.right);
|
|
@@ -755,19 +747,19 @@ function xAxis(plot, axis) {
|
|
|
755
747
|
const turned = turnedLevels(axis, length);
|
|
756
748
|
const ticks = fittedTicks(axis, length).map((tick) => {
|
|
757
749
|
const x = plot.left + tick.place * length;
|
|
758
|
-
const label = turned ?
|
|
750
|
+
const label = turned ? svg("text", {
|
|
759
751
|
class: "rx-tick",
|
|
760
752
|
x,
|
|
761
753
|
y: plot.bottom + 14,
|
|
762
754
|
"text-anchor": "end",
|
|
763
755
|
transform: `rotate(-35 ${x} ${plot.bottom + 14})`
|
|
764
|
-
}, tick.text) :
|
|
756
|
+
}, tick.text) : svg("text", {
|
|
765
757
|
class: "rx-tick",
|
|
766
758
|
x,
|
|
767
759
|
y: plot.bottom + 15,
|
|
768
760
|
"text-anchor": x + tick.text.length * CHAR_WIDTH / 2 > plot.width ? "end" : "middle"
|
|
769
761
|
}, tick.text);
|
|
770
|
-
return
|
|
762
|
+
return svg("g", {}, svg("line", {
|
|
771
763
|
class: "rx-axis",
|
|
772
764
|
x1: x,
|
|
773
765
|
x2: x,
|
|
@@ -775,13 +767,13 @@ function xAxis(plot, axis) {
|
|
|
775
767
|
y2: plot.bottom + 4
|
|
776
768
|
}), label);
|
|
777
769
|
});
|
|
778
|
-
const name =
|
|
770
|
+
const name = svg("text", {
|
|
779
771
|
class: "rx-axis-name",
|
|
780
772
|
x: (plot.left + plot.right) / 2,
|
|
781
773
|
y: plot.height - 6,
|
|
782
774
|
"text-anchor": "middle"
|
|
783
775
|
}, axis.log ? `${axis.label}, log scale` : axis.label);
|
|
784
|
-
return
|
|
776
|
+
return svg("g", {}, svg("line", {
|
|
785
777
|
class: "rx-axis",
|
|
786
778
|
x1: plot.left,
|
|
787
779
|
x2: plot.right,
|
|
@@ -792,34 +784,36 @@ function xAxis(plot, axis) {
|
|
|
792
784
|
/** This function draws the value axis with its grid lines. */
|
|
793
785
|
function valueAxis(plot, ticks) {
|
|
794
786
|
const length = plot.bottom - plot.top;
|
|
795
|
-
|
|
787
|
+
const lines = ticks.map((tick) => {
|
|
796
788
|
const y = plot.bottom - tick.place * length;
|
|
797
|
-
return
|
|
789
|
+
return svg("g", {}, svg("line", {
|
|
798
790
|
class: "rx-grid",
|
|
799
791
|
x1: plot.left,
|
|
800
792
|
x2: plot.right,
|
|
801
793
|
y1: y,
|
|
802
794
|
y2: y
|
|
803
|
-
}),
|
|
795
|
+
}), svg("text", {
|
|
804
796
|
class: "rx-tick",
|
|
805
797
|
x: plot.left - 6,
|
|
806
798
|
y: y + 4,
|
|
807
799
|
"text-anchor": "end"
|
|
808
800
|
}, tick.text));
|
|
809
|
-
})
|
|
801
|
+
});
|
|
802
|
+
return svg("g", {}, ...lines);
|
|
810
803
|
}
|
|
811
804
|
/** This function draws the vertical axis of a surface. */
|
|
812
805
|
function surfaceAxis(plot, axis) {
|
|
813
806
|
const length = plot.bottom - plot.top;
|
|
814
|
-
|
|
807
|
+
const ticks = axisTicks(axis, Math.max(2, Math.floor(length / 45))).map((tick) => {
|
|
815
808
|
const y = plot.bottom - tick.place * length;
|
|
816
|
-
return
|
|
809
|
+
return svg("text", {
|
|
817
810
|
class: "rx-tick",
|
|
818
811
|
x: plot.left - 6,
|
|
819
812
|
y: y + 4,
|
|
820
813
|
"text-anchor": "end"
|
|
821
814
|
}, tick.text);
|
|
822
|
-
})
|
|
815
|
+
});
|
|
816
|
+
return svg("g", {}, ...ticks);
|
|
823
817
|
}
|
|
824
818
|
/** This function gives the place of a value on the value axis, from 0 to 1. */
|
|
825
819
|
function valuePlace(scale, value) {
|
|
@@ -861,7 +855,7 @@ function connect(svg, cursor, tell) {
|
|
|
861
855
|
}
|
|
862
856
|
/** This function makes the frame of a chart with its text for a screen reader. */
|
|
863
857
|
function chartFrame(plot, label) {
|
|
864
|
-
return
|
|
858
|
+
return svg("svg", {
|
|
865
859
|
class: "rx-svg",
|
|
866
860
|
width: plot.width,
|
|
867
861
|
height: plot.height,
|
|
@@ -878,12 +872,12 @@ function fadedBand(plot, panel, scale, axis, id) {
|
|
|
878
872
|
const curve = panel.slice.curve;
|
|
879
873
|
const px = (at) => plot.left + placeOn(axis, at) * length;
|
|
880
874
|
const py = (value) => plot.bottom - valuePlace(scale, value) * height;
|
|
881
|
-
const stops = curve.map((place) =>
|
|
875
|
+
const stops = curve.map((place) => svg("stop", {
|
|
882
876
|
class: "rx-band-stop",
|
|
883
877
|
offset: placeOn(axis, place.at),
|
|
884
878
|
"stop-opacity": fadeOf(place.nearest).toFixed(3)
|
|
885
879
|
}));
|
|
886
|
-
const gradient =
|
|
880
|
+
const gradient = svg("linearGradient", {
|
|
887
881
|
id,
|
|
888
882
|
gradientUnits: "userSpaceOnUse",
|
|
889
883
|
x1: plot.left,
|
|
@@ -893,7 +887,7 @@ function fadedBand(plot, panel, scale, axis, id) {
|
|
|
893
887
|
}, ...stops);
|
|
894
888
|
const upper = curve.map((place) => [px(place.at), py(place.high)]);
|
|
895
889
|
const lower = curve.map((place) => [px(place.at), py(place.low)]);
|
|
896
|
-
return [
|
|
890
|
+
return [svg("defs", {}, gradient), svg("path", {
|
|
897
891
|
class: "rx-band",
|
|
898
892
|
d: bandPath(upper, lower),
|
|
899
893
|
fill: `url(#${id})`
|
|
@@ -909,7 +903,7 @@ function levelMarks(plot, panel, scale, axis) {
|
|
|
909
903
|
const top = plot.bottom - valuePlace(scale, place.high) * height;
|
|
910
904
|
const bottom = plot.bottom - valuePlace(scale, place.low) * height;
|
|
911
905
|
const y = plot.bottom - valuePlace(scale, place.value) * height;
|
|
912
|
-
return [
|
|
906
|
+
return [svg("rect", {
|
|
913
907
|
class: "rx-whisker",
|
|
914
908
|
x: x - room / 2,
|
|
915
909
|
y: top,
|
|
@@ -917,7 +911,7 @@ function levelMarks(plot, panel, scale, axis) {
|
|
|
917
911
|
height: Math.max(1, bottom - top),
|
|
918
912
|
rx: 4,
|
|
919
913
|
"fill-opacity": (.3 * fadeOf(place.nearest)).toFixed(3)
|
|
920
|
-
}),
|
|
914
|
+
}), svg("line", {
|
|
921
915
|
class: "rx-line",
|
|
922
916
|
x1: x - room / 2,
|
|
923
917
|
x2: x + room / 2,
|
|
@@ -939,19 +933,19 @@ function curveChart(view, panel, width, id, tell) {
|
|
|
939
933
|
const px = (at) => plot.left + placeOn(view.x, at) * length;
|
|
940
934
|
const py = (value) => plot.bottom - valuePlace(scale, value) * height;
|
|
941
935
|
const smooth = view.x.kind === "number";
|
|
942
|
-
const marks = smooth ? [...fadedBand(plot, panel, scale, view.x, id),
|
|
936
|
+
const marks = smooth ? [...fadedBand(plot, panel, scale, view.x, id), svg("path", {
|
|
943
937
|
class: "rx-line",
|
|
944
938
|
d: linePath(curve.map((place) => [px(place.at), py(place.value)]))
|
|
945
939
|
})] : levelMarks(plot, panel, scale, view.x);
|
|
946
940
|
const room = smooth ? 0 : Math.min(30, length / Math.max(1, view.x.levels.length) * .35);
|
|
947
|
-
const dots = panel.slice.points.map((point) =>
|
|
941
|
+
const dots = panel.slice.points.map((point) => svg("circle", {
|
|
948
942
|
class: "rx-dot",
|
|
949
943
|
cx: px(point.at) + jitter(point.id, room),
|
|
950
944
|
cy: py(point.value),
|
|
951
945
|
r: 3.5
|
|
952
946
|
}));
|
|
953
947
|
const ticks = numberTicks(scale.range[0], scale.range[1], scale.log, Math.max(2, Math.floor(height / 50)));
|
|
954
|
-
const rule =
|
|
948
|
+
const rule = svg("line", {
|
|
955
949
|
class: "rx-cursor",
|
|
956
950
|
x1: 0,
|
|
957
951
|
x2: 0,
|
|
@@ -959,16 +953,16 @@ function curveChart(view, panel, width, id, tell) {
|
|
|
959
953
|
y2: plot.bottom,
|
|
960
954
|
visibility: "hidden"
|
|
961
955
|
});
|
|
962
|
-
const ring =
|
|
956
|
+
const ring = svg("circle", {
|
|
963
957
|
class: "rx-ring",
|
|
964
958
|
cx: 0,
|
|
965
959
|
cy: 0,
|
|
966
960
|
r: 5,
|
|
967
961
|
visibility: "hidden"
|
|
968
962
|
});
|
|
969
|
-
const svg = chartFrame(plot, `${panel.title} ${view.measure.label} over ${view.x.label}.`.trim());
|
|
970
|
-
svg.append(valueAxis(plot, ticks), ...marks, ...dots, xAxis(plot, view.x), rule, ring);
|
|
971
|
-
connect(svg, {
|
|
963
|
+
const svg$1 = chartFrame(plot, `${panel.title} ${view.measure.label} over ${view.x.label}.`.trim());
|
|
964
|
+
svg$1.append(valueAxis(plot, ticks), ...marks, ...dots, xAxis(plot, view.x), rule, ring);
|
|
965
|
+
connect(svg$1, {
|
|
972
966
|
columns: curve.length,
|
|
973
967
|
rows: 1,
|
|
974
968
|
at: (x) => {
|
|
@@ -986,7 +980,7 @@ function curveChart(view, panel, width, id, tell) {
|
|
|
986
980
|
return curveText(view.x, place);
|
|
987
981
|
}
|
|
988
982
|
}, tell);
|
|
989
|
-
return svg;
|
|
983
|
+
return svg$1;
|
|
990
984
|
}
|
|
991
985
|
/** This function draws a chart of a surface, or the separate cells of a table. */
|
|
992
986
|
function surfaceChart(view, panel, width, tell) {
|
|
@@ -1011,17 +1005,17 @@ function surfaceChart(view, panel, width, tell) {
|
|
|
1011
1005
|
height: Math.max(.5, lower - upper - gap + (gap === 0 ? .6 : 0))
|
|
1012
1006
|
};
|
|
1013
1007
|
const step = heatStep(band.value, range, view.log);
|
|
1014
|
-
const parts = [
|
|
1008
|
+
const parts = [svg("rect", {
|
|
1015
1009
|
...box,
|
|
1016
1010
|
class: `rx-h${step}`
|
|
1017
1011
|
})];
|
|
1018
1012
|
const veil = veilOf(band.nearest);
|
|
1019
|
-
if (veil > .02) parts.push(
|
|
1013
|
+
if (veil > .02) parts.push(svg("rect", {
|
|
1020
1014
|
...box,
|
|
1021
1015
|
class: "rx-veil",
|
|
1022
1016
|
"fill-opacity": veil.toFixed(3)
|
|
1023
1017
|
}));
|
|
1024
|
-
if (panel.cells && box.width > 34 && box.height > 18) parts.push(
|
|
1018
|
+
if (panel.cells && box.width > 34 && box.height > 18) parts.push(svg("text", {
|
|
1025
1019
|
class: `rx-cell-text ${step > 9 / 2 ? "rx-on-dark" : "rx-on-light"}`,
|
|
1026
1020
|
x: box.x + box.width / 2,
|
|
1027
1021
|
y: box.y + box.height / 2 + 4,
|
|
@@ -1029,13 +1023,13 @@ function surfaceChart(view, panel, width, tell) {
|
|
|
1029
1023
|
}, formatValue(band.value)));
|
|
1030
1024
|
return parts;
|
|
1031
1025
|
}));
|
|
1032
|
-
const dots = panel.surface.points.map((point) =>
|
|
1026
|
+
const dots = panel.surface.points.map((point) => svg("circle", {
|
|
1033
1027
|
class: "rx-dot rx-dot-heat",
|
|
1034
1028
|
cx: plot.left + placeOn(view.x, point.at[0]) * length + jitter(point.id, 6),
|
|
1035
1029
|
cy: plot.bottom - placeOn(axisY, point.at[1]) * height + jitter(`${point.id}y`, 6),
|
|
1036
1030
|
r: 2.5
|
|
1037
1031
|
}));
|
|
1038
|
-
const outline =
|
|
1032
|
+
const outline = svg("rect", {
|
|
1039
1033
|
class: "rx-cell-cursor",
|
|
1040
1034
|
x: 0,
|
|
1041
1035
|
y: 0,
|
|
@@ -1043,13 +1037,13 @@ function surfaceChart(view, panel, width, tell) {
|
|
|
1043
1037
|
height: 0,
|
|
1044
1038
|
visibility: "hidden"
|
|
1045
1039
|
});
|
|
1046
|
-
const svg = chartFrame(plot, `${panel.title} ${view.measure.label} over ${view.x.label} and ${axisY.label}.`.trim());
|
|
1047
|
-
svg.append(...cellMarks, ...dots, surfaceAxis(plot, axisY), xAxis(plot, view.x), outline);
|
|
1040
|
+
const svg$2 = chartFrame(plot, `${panel.title} ${view.measure.label} over ${view.x.label} and ${axisY.label}.`.trim());
|
|
1041
|
+
svg$2.append(...cellMarks, ...dots, surfaceAxis(plot, axisY), xAxis(plot, view.x), outline);
|
|
1048
1042
|
const find = (edges, share) => {
|
|
1049
1043
|
const index = edges.findIndex((edge) => edge > share);
|
|
1050
1044
|
return Math.max(0, (index < 0 ? edges.length : index) - 1);
|
|
1051
1045
|
};
|
|
1052
|
-
connect(svg, {
|
|
1046
|
+
connect(svg$2, {
|
|
1053
1047
|
columns: x.length,
|
|
1054
1048
|
rows: y.length,
|
|
1055
1049
|
at: (px, py) => [find(xEdges, (px - plot.left) / length), y.length - 1 - find(yEdges, (plot.bottom - py) / height)],
|
|
@@ -1063,40 +1057,40 @@ function surfaceChart(view, panel, width, tell) {
|
|
|
1063
1057
|
return cellText(view.x, axisY, x[column], y[j], cells[j]?.[column]);
|
|
1064
1058
|
}
|
|
1065
1059
|
}, tell);
|
|
1066
|
-
return svg;
|
|
1060
|
+
return svg$2;
|
|
1067
1061
|
}
|
|
1068
1062
|
/** This function draws the measured points of a measure with no model. */
|
|
1069
1063
|
function pointsChart(view, panel, width) {
|
|
1070
1064
|
const plot = plotOf(width, 270, view);
|
|
1071
1065
|
const length = plot.right - plot.left;
|
|
1072
1066
|
const height = plot.bottom - plot.top;
|
|
1073
|
-
const svg = chartFrame(plot, `${panel.title} ${view.measure.label}: ${panel.points.length} measured points.`.trim());
|
|
1067
|
+
const svg$3 = chartFrame(plot, `${panel.title} ${view.measure.label}: ${panel.points.length} measured points.`.trim());
|
|
1074
1068
|
if (view.y === null) {
|
|
1075
1069
|
const scale = {
|
|
1076
1070
|
range: valueRange(view),
|
|
1077
1071
|
log: view.log
|
|
1078
1072
|
};
|
|
1079
1073
|
const room = view.x.kind === "levels" ? Math.min(30, length / Math.max(1, view.x.levels.length) * .35) : 0;
|
|
1080
|
-
const dots = panel.points.map((point) =>
|
|
1074
|
+
const dots = panel.points.map((point) => svg("circle", {
|
|
1081
1075
|
class: "rx-dot",
|
|
1082
1076
|
cx: plot.left + placeOn(view.x, point.at[0]) * length + jitter(point.id, room),
|
|
1083
1077
|
cy: plot.bottom - valuePlace(scale, point.value) * height,
|
|
1084
1078
|
r: 3.5
|
|
1085
1079
|
}));
|
|
1086
1080
|
const ticks = numberTicks(scale.range[0], scale.range[1], scale.log, Math.max(2, Math.floor(height / 50)));
|
|
1087
|
-
svg.append(valueAxis(plot, ticks), ...dots, xAxis(plot, view.x));
|
|
1088
|
-
return svg;
|
|
1081
|
+
svg$3.append(valueAxis(plot, ticks), ...dots, xAxis(plot, view.x));
|
|
1082
|
+
return svg$3;
|
|
1089
1083
|
}
|
|
1090
1084
|
const axisY = view.y;
|
|
1091
1085
|
const range = heatRange(view);
|
|
1092
|
-
const dots = panel.points.map((point) =>
|
|
1086
|
+
const dots = panel.points.map((point) => svg("circle", {
|
|
1093
1087
|
class: `rx-h${heatStep(point.value, range, view.log)} rx-ring-dot`,
|
|
1094
1088
|
cx: plot.left + placeOn(view.x, point.at[0]) * length + jitter(point.id, 8),
|
|
1095
1089
|
cy: plot.bottom - placeOn(axisY, point.at[1]) * height + jitter(`${point.id}y`, 8),
|
|
1096
1090
|
r: 5
|
|
1097
1091
|
}));
|
|
1098
|
-
svg.append(...dots, surfaceAxis(plot, axisY), xAxis(plot, view.x));
|
|
1099
|
-
return svg;
|
|
1092
|
+
svg$3.append(...dots, surfaceAxis(plot, axisY), xAxis(plot, view.x));
|
|
1093
|
+
return svg$3;
|
|
1100
1094
|
}
|
|
1101
1095
|
/** This function gives the number of measured points of a panel. */
|
|
1102
1096
|
function pointCount(panel) {
|