You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[editor-pi] [Interactive Graph] Support tick labels that are multiples of pi (#2167)
## Summary:
Currently, if a graph has tick labels that are multiples of pi,
such as in a sinusoid graph, content authors have to set the
graph markings to "none" and load in a graphie background image
that has the graph with the desired tick markings.
This is not only inconvenient for content authors, it also means
that the screen reader will not read the correct coordinates for
these interactive graphs. It might say "2" when it should be
saying "2 pi."
Implementing a fix for this to improve the lives of our content
authors and our screen reader users.
- Editor
- Check if the value loaded into NumberInput is a multiple
of pi, and not already written in the "pi" format.
- If so, and if the `allowPiTrunacation` prop is true,
divide this number by pi and append "π" to the value.
- This will make it so that the value shown in the text
input will show as pi format even if loaded in without it.
(6.28... --> "2π")
- Mafs graph
- In the AxisTicks component, check if the tick step is a
multiple of pi.
- If so, divide all the ticks by pi and append pi to the value
(special cases for 0, 1π, and -1π).
- This will result in the ticks showing as integers * pi.
Issue: https://khanacademy.atlassian.net/browse/LEMS-2059
## Test plan:
`yarn jest packages/perseus/src/components/__tests__/number-input.test.tsx`
`yarn jest packages/perseus/src/util/math-utils.test.ts`
`yarn jest packages/perseus/src/widgets/interactive-graphs/backgrounds/axis-ticks.test.ts`
`yarn jest packages/perseus/src/widgets/interactive-graphs/interactive-graph.test.tsx`
Storybook
- http://localhost:6006/?path=/story/perseuseditor-widgets-interactive-graph--interactive-graph-sinusoid
<img width="847" alt="image" src="https://github.com/user-attachments/assets/cb2044df-d8c2-496e-b78c-2ee7c6643b7d" />
Author: nishasy
Reviewers: SonicScrewdriver, nishasy, catandthemachines
Required Reviewers:
Approved By: SonicScrewdriver
Checks: ✅ Lint, Typecheck, Format, and Test (ubuntu-latest, 20.x), ✅ Publish npm snapshot (ubuntu-latest, 20.x), ✅ Check builds for changes in size (ubuntu-latest, 20.x), ✅ Cypress (ubuntu-latest, 20.x), ✅ Publish Storybook to Chromatic (ubuntu-latest, 20.x), ✅ Check for .changeset entries for all changed files (ubuntu-latest, 20.x)
Pull Request URL: #2167
0 commit comments