@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/index.js CHANGED
@@ -25414,7 +25414,7 @@ class GradedGroupAnswerBar extends React__namespace.Component {
25414
25414
  }, nextQuestion));
25415
25415
  }
25416
25416
  }
25417
- const fontSize$1 = 17;
25417
+ const fontSize = 17;
25418
25418
  const styles$j = {
25419
25419
  answerBar: {
25420
25420
  display: "flex",
@@ -25439,7 +25439,7 @@ const styles$j = {
25439
25439
  flexDirection: "row",
25440
25440
  alignItems: "center",
25441
25441
  fontWeight: "bold",
25442
- fontSize: fontSize$1
25442
+ fontSize: fontSize
25443
25443
  }
25444
25444
  };
25445
25445
 
@@ -28126,7 +28126,6 @@ const defaultGraphConfig = {
28126
28126
  width: 0,
28127
28127
  height: 0,
28128
28128
  labels: [],
28129
- labelLocation: "onAxis",
28130
28129
  disableKeyboardInteraction: false,
28131
28130
  interactiveColor: "var(--mafs-blue)"
28132
28131
  };
@@ -28350,8 +28349,6 @@ function escapeIfUnescaped(character) {
28350
28349
  }
28351
28350
  }
28352
28351
 
28353
- // Exported for testing purposes
28354
- const fontSize = 14;
28355
28352
  function AxisLabels(_ref) {
28356
28353
  let {
28357
28354
  i18n
@@ -28360,26 +28357,24 @@ function AxisLabels(_ref) {
28360
28357
  range,
28361
28358
  labels,
28362
28359
  width,
28363
- height,
28364
- labelLocation
28360
+ height
28365
28361
  } = useGraphConfig();
28366
28362
  const {
28367
28363
  strings
28368
28364
  } = i18n;
28365
+ const yAxisLabelLocation = [0, range[Y][MAX]];
28366
+ const xAxisLabelLocation = [range[X][MAX], 0];
28367
+ const [xAxisLabelText, yAxisLabelText] = labels;
28369
28368
  const graphInfo = {
28370
28369
  range,
28371
28370
  width,
28372
28371
  height
28373
28372
  };
28374
-
28375
- // Get the position of the main axis labels
28376
- const [xAxisLabelLocation, yAxisLabelLocation] = getLabelPosition(graphInfo, labelLocation);
28377
- const [xAxisLabelText, yAxisLabelText] = labels;
28378
-
28379
- // If the labels are rotated, we need to center the
28380
- // x-axis label along the bottom of the graph.
28381
- const xLabelTransform = labelLocation === "onAxis" ? "translate(7px, -50%)" : "translate(-50%, -50%)";
28382
- const yLabelTransform = labelLocation === "onAxis" ? "translate(-50%, 0px)" : "translate(-50%, 0px) rotate(-90deg)";
28373
+ const [x1, y1] = pointToPixel(xAxisLabelLocation, graphInfo);
28374
+ // The default location for the y-axis-label is at the maximum y point
28375
+ // This is just underneath the tick line for that point. The -24 moves the
28376
+ // label up one grid square, so it sits on top of the graph
28377
+ const [x2, y2] = mafs.vec.add(pointToPixel(yAxisLabelLocation, graphInfo), [0, -24]);
28383
28378
  const {
28384
28379
  TeX
28385
28380
  } = getDependencies();
@@ -28387,53 +28382,22 @@ function AxisLabels(_ref) {
28387
28382
  "aria-label": strings.xAxis,
28388
28383
  style: {
28389
28384
  position: "absolute",
28390
- left: xAxisLabelLocation[X],
28391
- top: xAxisLabelLocation[Y],
28392
- fontSize: fontSize + "px",
28393
- transform: xLabelTransform
28385
+ left: x1,
28386
+ top: y1,
28387
+ fontSize: "14px",
28388
+ transform: "translate(7px, -50%)"
28394
28389
  }
28395
28390
  }, /*#__PURE__*/React__default["default"].createElement(TeX, null, replaceOutsideTeX(xAxisLabelText))), /*#__PURE__*/React__default["default"].createElement("span", {
28396
28391
  "aria-label": strings.yAxis,
28397
28392
  style: {
28398
28393
  position: "absolute",
28399
- left: yAxisLabelLocation[X],
28400
- top: yAxisLabelLocation[Y],
28401
- fontSize: fontSize + "px",
28402
- transform: yLabelTransform
28394
+ left: x2,
28395
+ top: y2,
28396
+ fontSize: "14px",
28397
+ transform: "translate(-50%, 0px)"
28403
28398
  }
28404
28399
  }, /*#__PURE__*/React__default["default"].createElement(TeX, null, replaceOutsideTeX(yAxisLabelText))));
28405
28400
  }
28406
- const getLabelPosition = (graphInfo, labelLocation) => {
28407
- // If the labels are placed along the edge of the graph, we need to place them at the
28408
- // center of the graph, which is the average of the min and max values of the axes.
28409
- if (labelLocation === "alongEdge") {
28410
- // Offset the labels by a certain amount based on the range of the graph, to ensure that
28411
- // the labels do not overlap with the axis tick if they are out of the graph bounds.
28412
- 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
28413
- : [0, fontSize]; // Move the label down by 1 font size if the y-axis min is negative
28414
- 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
28415
- : [-fontSize, -fontSize]; // Move the label left by 1 font size if the x-axis min is negative
28416
-
28417
- // Calculate the location of the labels to be halfway between the min and max values of the axes
28418
- const xAxisLabelLocation = [(graphInfo.range[X][MIN] + graphInfo.range[X][MAX]) / 2, graphInfo.range[Y][MIN]];
28419
- const yAxisLabelLocation = [graphInfo.range[X][MIN], (graphInfo.range[Y][MIN] + graphInfo.range[Y][MAX]) / 2];
28420
-
28421
- // Convert the Vector2 coordinates to pixel coordinates and add the offsets
28422
- const xLabel = mafs.vec.add(pointToPixel(xAxisLabelLocation, graphInfo), xAxisLabelOffset);
28423
- const yLabel = mafs.vec.add(pointToPixel(yAxisLabelLocation, graphInfo), yAxisLabelOffset);
28424
- return [xLabel, yLabel];
28425
- }
28426
-
28427
- // Otherwise, the labels are placed on the axes (default), and we need to
28428
- // place them at the end of the axis, which is the maximum value of the axis.
28429
- const xLabelInitial = [graphInfo.range[X][MAX], 0];
28430
- const yLabelInitial = [0, graphInfo.range[Y][MAX]];
28431
- const yLabelOffset = [0, -fontSize * 2]; // Move the y-axis label up by 2 font sizes
28432
-
28433
- const xLabel = pointToPixel(xLabelInitial, graphInfo);
28434
- const yLabel = mafs.vec.add(pointToPixel(yLabelInitial, graphInfo), yLabelOffset);
28435
- return [xLabel, yLabel];
28436
- };
28437
28401
 
28438
28402
  // The size of the ticks and labels in pixels
28439
28403
  const tickSize = 10;
@@ -34783,7 +34747,6 @@ const MafsGraph = props => {
34783
34747
  state,
34784
34748
  dispatch,
34785
34749
  labels,
34786
- labelLocation,
34787
34750
  readOnly,
34788
34751
  fullGraphAriaLabel,
34789
34752
  fullGraphAriaDescription
@@ -34864,7 +34827,6 @@ const MafsGraph = props => {
34864
34827
  width,
34865
34828
  height,
34866
34829
  labels,
34867
- labelLocation,
34868
34830
  disableKeyboardInteraction: disableInteraction,
34869
34831
  // If the graph is read-only or static, we want to make it
34870
34832
  // visually clear that the graph is no longer interactive.
@@ -41992,7 +41954,7 @@ const addLibraryVersionToPerseusDebug = (libraryName, libraryVersion) => {
41992
41954
 
41993
41955
  // This file is processed by a Rollup plugin (replace) to inject the production
41994
41956
  const libName = "@khanacademy/perseus";
41995
- const libVersion = "57.0.1";
41957
+ const libVersion = "57.1.0";
41996
41958
  addLibraryVersionToPerseusDebug(libName, libVersion);
41997
41959
 
41998
41960
  const apiVersion = {