@khanacademy/perseus 57.0.1 → 57.1.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/dist/es/index.js +20 -58
- package/dist/es/index.js.map +1 -1
- package/dist/index.js +20 -58
- package/dist/index.js.map +1 -1
- package/dist/widgets/interactive-graphs/backgrounds/axis-labels.d.ts +0 -5
- package/dist/widgets/interactive-graphs/interactive-graph-question-builder.d.ts +1 -3
- package/dist/widgets/interactive-graphs/mafs-graph.d.ts +0 -1
- package/dist/widgets/interactive-graphs/reducer/use-graph-config.d.ts +1 -2
- package/dist/widgets/interactive-graphs/stateful-mafs-graph.d.ts +0 -1
- package/package.json +7 -7
package/dist/es/index.js
CHANGED
|
@@ -24998,7 +24998,7 @@ class GradedGroupAnswerBar extends React.Component {
|
|
|
24998
24998
|
}
|
|
24999
24999
|
}
|
|
25000
25000
|
GradedGroupAnswerBar.contextType = PerseusI18nContext;
|
|
25001
|
-
const fontSize
|
|
25001
|
+
const fontSize = 17;
|
|
25002
25002
|
const styles$j = {
|
|
25003
25003
|
answerBar: {
|
|
25004
25004
|
display: "flex",
|
|
@@ -25023,7 +25023,7 @@ const styles$j = {
|
|
|
25023
25023
|
flexDirection: "row",
|
|
25024
25024
|
alignItems: "center",
|
|
25025
25025
|
fontWeight: "bold",
|
|
25026
|
-
fontSize: fontSize
|
|
25026
|
+
fontSize: fontSize
|
|
25027
25027
|
}
|
|
25028
25028
|
};
|
|
25029
25029
|
|
|
@@ -27679,7 +27679,6 @@ const defaultGraphConfig = {
|
|
|
27679
27679
|
width: 0,
|
|
27680
27680
|
height: 0,
|
|
27681
27681
|
labels: [],
|
|
27682
|
-
labelLocation: "onAxis",
|
|
27683
27682
|
disableKeyboardInteraction: false,
|
|
27684
27683
|
interactiveColor: "var(--mafs-blue)"
|
|
27685
27684
|
};
|
|
@@ -27895,8 +27894,6 @@ function escapeIfUnescaped(character) {
|
|
|
27895
27894
|
}
|
|
27896
27895
|
}
|
|
27897
27896
|
|
|
27898
|
-
// Exported for testing purposes
|
|
27899
|
-
const fontSize = 14;
|
|
27900
27897
|
function AxisLabels({
|
|
27901
27898
|
i18n
|
|
27902
27899
|
}) {
|
|
@@ -27904,26 +27901,24 @@ function AxisLabels({
|
|
|
27904
27901
|
range,
|
|
27905
27902
|
labels,
|
|
27906
27903
|
width,
|
|
27907
|
-
height
|
|
27908
|
-
labelLocation
|
|
27904
|
+
height
|
|
27909
27905
|
} = useGraphConfig();
|
|
27910
27906
|
const {
|
|
27911
27907
|
strings
|
|
27912
27908
|
} = i18n;
|
|
27909
|
+
const yAxisLabelLocation = [0, range[Y][MAX]];
|
|
27910
|
+
const xAxisLabelLocation = [range[X][MAX], 0];
|
|
27911
|
+
const [xAxisLabelText, yAxisLabelText] = labels;
|
|
27913
27912
|
const graphInfo = {
|
|
27914
27913
|
range,
|
|
27915
27914
|
width,
|
|
27916
27915
|
height
|
|
27917
27916
|
};
|
|
27918
|
-
|
|
27919
|
-
//
|
|
27920
|
-
|
|
27921
|
-
|
|
27922
|
-
|
|
27923
|
-
// If the labels are rotated, we need to center the
|
|
27924
|
-
// x-axis label along the bottom of the graph.
|
|
27925
|
-
const xLabelTransform = labelLocation === "onAxis" ? "translate(7px, -50%)" : "translate(-50%, -50%)";
|
|
27926
|
-
const yLabelTransform = labelLocation === "onAxis" ? "translate(-50%, 0px)" : "translate(-50%, 0px) rotate(-90deg)";
|
|
27917
|
+
const [x1, y1] = pointToPixel(xAxisLabelLocation, graphInfo);
|
|
27918
|
+
// The default location for the y-axis-label is at the maximum y point
|
|
27919
|
+
// This is just underneath the tick line for that point. The -24 moves the
|
|
27920
|
+
// label up one grid square, so it sits on top of the graph
|
|
27921
|
+
const [x2, y2] = vec.add(pointToPixel(yAxisLabelLocation, graphInfo), [0, -24]);
|
|
27927
27922
|
const {
|
|
27928
27923
|
TeX
|
|
27929
27924
|
} = getDependencies();
|
|
@@ -27931,53 +27926,22 @@ function AxisLabels({
|
|
|
27931
27926
|
"aria-label": strings.xAxis,
|
|
27932
27927
|
style: {
|
|
27933
27928
|
position: "absolute",
|
|
27934
|
-
left:
|
|
27935
|
-
top:
|
|
27936
|
-
fontSize:
|
|
27937
|
-
transform:
|
|
27929
|
+
left: x1,
|
|
27930
|
+
top: y1,
|
|
27931
|
+
fontSize: "14px",
|
|
27932
|
+
transform: "translate(7px, -50%)"
|
|
27938
27933
|
}
|
|
27939
27934
|
}, /*#__PURE__*/React__default.createElement(TeX, null, replaceOutsideTeX(xAxisLabelText))), /*#__PURE__*/React__default.createElement("span", {
|
|
27940
27935
|
"aria-label": strings.yAxis,
|
|
27941
27936
|
style: {
|
|
27942
27937
|
position: "absolute",
|
|
27943
|
-
left:
|
|
27944
|
-
top:
|
|
27945
|
-
fontSize:
|
|
27946
|
-
transform:
|
|
27938
|
+
left: x2,
|
|
27939
|
+
top: y2,
|
|
27940
|
+
fontSize: "14px",
|
|
27941
|
+
transform: "translate(-50%, 0px)"
|
|
27947
27942
|
}
|
|
27948
27943
|
}, /*#__PURE__*/React__default.createElement(TeX, null, replaceOutsideTeX(yAxisLabelText))));
|
|
27949
27944
|
}
|
|
27950
|
-
const getLabelPosition = (graphInfo, labelLocation) => {
|
|
27951
|
-
// If the labels are placed along the edge of the graph, we need to place them at the
|
|
27952
|
-
// center of the graph, which is the average of the min and max values of the axes.
|
|
27953
|
-
if (labelLocation === "alongEdge") {
|
|
27954
|
-
// Offset the labels by a certain amount based on the range of the graph, to ensure that
|
|
27955
|
-
// the labels do not overlap with the axis tick if they are out of the graph bounds.
|
|
27956
|
-
const xAxisLabelOffset = graphInfo.range[Y][MIN] >= 0 ? [0, fontSize * 3] // Move the label down by 3 font sizes if the y-axis min is positive
|
|
27957
|
-
: [0, fontSize]; // Move the label down by 1 font size if the y-axis min is negative
|
|
27958
|
-
const yAxisLabelOffset = graphInfo.range[X][MIN] >= 0 ? [-fontSize * 3, -fontSize] // Move the label left by 3 font sizes if the x-axis min is positive
|
|
27959
|
-
: [-fontSize, -fontSize]; // Move the label left by 1 font size if the x-axis min is negative
|
|
27960
|
-
|
|
27961
|
-
// Calculate the location of the labels to be halfway between the min and max values of the axes
|
|
27962
|
-
const xAxisLabelLocation = [(graphInfo.range[X][MIN] + graphInfo.range[X][MAX]) / 2, graphInfo.range[Y][MIN]];
|
|
27963
|
-
const yAxisLabelLocation = [graphInfo.range[X][MIN], (graphInfo.range[Y][MIN] + graphInfo.range[Y][MAX]) / 2];
|
|
27964
|
-
|
|
27965
|
-
// Convert the Vector2 coordinates to pixel coordinates and add the offsets
|
|
27966
|
-
const _xLabel = vec.add(pointToPixel(xAxisLabelLocation, graphInfo), xAxisLabelOffset);
|
|
27967
|
-
const _yLabel = vec.add(pointToPixel(yAxisLabelLocation, graphInfo), yAxisLabelOffset);
|
|
27968
|
-
return [_xLabel, _yLabel];
|
|
27969
|
-
}
|
|
27970
|
-
|
|
27971
|
-
// Otherwise, the labels are placed on the axes (default), and we need to
|
|
27972
|
-
// place them at the end of the axis, which is the maximum value of the axis.
|
|
27973
|
-
const xLabelInitial = [graphInfo.range[X][MAX], 0];
|
|
27974
|
-
const yLabelInitial = [0, graphInfo.range[Y][MAX]];
|
|
27975
|
-
const yLabelOffset = [0, -fontSize * 2]; // Move the y-axis label up by 2 font sizes
|
|
27976
|
-
|
|
27977
|
-
const xLabel = pointToPixel(xLabelInitial, graphInfo);
|
|
27978
|
-
const yLabel = vec.add(pointToPixel(yLabelInitial, graphInfo), yLabelOffset);
|
|
27979
|
-
return [xLabel, yLabel];
|
|
27980
|
-
};
|
|
27981
27945
|
|
|
27982
27946
|
// The size of the ticks and labels in pixels
|
|
27983
27947
|
const tickSize = 10;
|
|
@@ -34236,7 +34200,6 @@ const MafsGraph = props => {
|
|
|
34236
34200
|
state,
|
|
34237
34201
|
dispatch,
|
|
34238
34202
|
labels,
|
|
34239
|
-
labelLocation,
|
|
34240
34203
|
readOnly,
|
|
34241
34204
|
fullGraphAriaLabel,
|
|
34242
34205
|
fullGraphAriaDescription
|
|
@@ -34317,7 +34280,6 @@ const MafsGraph = props => {
|
|
|
34317
34280
|
width,
|
|
34318
34281
|
height,
|
|
34319
34282
|
labels,
|
|
34320
|
-
labelLocation,
|
|
34321
34283
|
disableKeyboardInteraction: disableInteraction,
|
|
34322
34284
|
// If the graph is read-only or static, we want to make it
|
|
34323
34285
|
// visually clear that the graph is no longer interactive.
|
|
@@ -41429,7 +41391,7 @@ const addLibraryVersionToPerseusDebug = (libraryName, libraryVersion) => {
|
|
|
41429
41391
|
|
|
41430
41392
|
// This file is processed by a Rollup plugin (replace) to inject the production
|
|
41431
41393
|
const libName = "@khanacademy/perseus";
|
|
41432
|
-
const libVersion = "57.0
|
|
41394
|
+
const libVersion = "57.1.0";
|
|
41433
41395
|
addLibraryVersionToPerseusDebug(libName, libVersion);
|
|
41434
41396
|
|
|
41435
41397
|
const apiVersion = {
|