-
-
Notifications
You must be signed in to change notification settings - Fork 80
Fix some issues with plots.pl and the graph tool. #1322
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
drgrice1
wants to merge
1
commit into
openwebwork:develop
Choose a base branch
from
drgrice1:plots-fixes
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+23
−11
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
c893b40 to
5139a67
Compare
f9e4917 to
5e1fb0c
Compare
somiaj
approved these changes
Oct 29, 2025
Contributor
somiaj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes look good. We should probably get this in for when testing your other upcoming changes.
Member
Author
|
I have built the future work on top of this pull request. So I won't go forward with that pull request until this is in. |
ae35b5a to
f3a870d
Compare
somiaj
approved these changes
Nov 12, 2025
First, fix the alt attribute for TikZ and GD image types for plots.pl.
The `image` method of `PGbasicmacros.pl` currently sets the
`aria_description` with the value of the `alt` option if it is passed to
the method, and it does so regardless of the plots image type. However,
that is only used for `html` output with JSXGraph. Thus for TikZ or GD
image types the alt attribute is lost. This makes it so that the
`aria_description` is only set for `html` output, and for all other
outputs the given alt tag is left in the `@alt_list` so that the later
code that inserts the `<image>` tag can get it and add it as an
attribute to the `<image>` tag.
You can test this with the following MWE:
```perl
DOCUMENT();
loadMacros('PGstandard.pl', 'PGML.pl', 'plots.pl', 'PGcourse.pl');
$plot = Plot();
$plot->add_function('x^2', 'x', -10, 10, color => 'blue');
$plot->image_type('tikz');
BEGIN_PGML
[!graph of x^2!]{$plot}{300}
END_PGML
ENDDOCUMENT();
```
With that example and the current code, the image will not have an alt
attribute, but will with this pull request. If you remove the line that
sets the image type to 'tikz', then the JSXGraph image will get the aria
description (with the second fix below).
Second, fix the aria description for both JSXGraph output of plots.pl
and the graph tool.
This is caused by the removal of the `description` option for the
`JXG.Board` object in the JSXGraph library. I must have missed this when
this happened three years ago. Although, it seems to have been done
rather quietly, as this is not listed in the change log for JSXGraph.
To fix this, I just do the same thing that the `description` option used
to do, and add a visually hidden span that the graph is `aria-describedby`.
Note that there is a new `aria-description` attribute that could be used
in the future for this, but it is in a future aria specification, and I
don't know how well supported it is at this point.
Finally, fix some issues with GD output of the plots.pl macro. This is
caused when an Plots::Plot object does not have the height explicitly
set. For TikZ and JSXGraph output, the `size` method is called which
determines the height if it is not set explicitly. So GD output should
do the same.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First, fix the alt attribute for TikZ and GD image types for plots.pl.
The
imagemethod ofPGbasicmacros.plcurrently sets thearia_descriptionwith the value of thealtoption if it is passed to the method, and it does so regardless of the plots image type. However, that is only used forhtmloutput with JSXGraph. Thus for TikZ or GD image types the alt attribute is lost. This makes it so that thearia_descriptionis only set forhtmloutput, and for all other outputs the given alt tag is left in the@alt_listso that the later code that inserts the<image>tag can get it and add it as an attribute to the<image>tag.You can test this with the following MWE:
With that example and the current code, the image will not have an alt attribute, but will with this pull request. If you remove the line that sets the image type to 'tikz', then the JSXGraph image will get the aria description (with the second fix below).
Second, fix the aria description for both JSXGraph output of plots.pl and the graph tool.
This is caused by the removal of the
descriptionoption for theJXG.Boardobject in the JSXGraph library. I must have missed this when this happened three years ago. Although, it seems to have been done rather quietly, as this is not listed in the change log for JSXGraph.To fix this, I just do the same thing that the
descriptionoption used to do, and add a visually hidden span that the graph isaria-describedby. Note that there is a newaria-descriptionattribute that could be used in the future for this, but it is in a future aria specification, and I don't know how well supported it is at this point.Finally, fix some issues with GD output of the plots.pl macro. This is caused when an Plots::Plot object does not have the height explicitly set. For TikZ and JSXGraph output, the
sizemethod is called which determines the height if it is not set explicitly. So GD output should do the same.