Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion htdocs/js/GraphTool/graphtool.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ window.graphTool = (containerId, options) => {
if ('htmlInputId' in options) gt.html_input = document.getElementById(options.htmlInputId);
const cfgOptions = {
title: 'WeBWorK Graph Tool',
description: options.ariaDescription ?? 'Interactively graph objects',
showCopyright: false,
pan: { enabled: false },
zoom: { enabled: false },
Expand Down Expand Up @@ -116,6 +115,14 @@ window.graphTool = (containerId, options) => {

const setupBoard = () => {
gt.board = JXG.JSXGraph.initBoard(`${containerId}_graph`, cfgOptions);

const descriptionSpan = document.createElement('span');
descriptionSpan.id = `${containerId}_description`;
descriptionSpan.classList.add('visually-hidden');
descriptionSpan.textContent = options.ariaDescription ?? 'Interactively graph objects';
gt.board.containerObj.after(descriptionSpan);
gt.board.containerObj.setAttribute('aria-describedby', descriptionSpan.id);

gt.board.suspendUpdate();

// Move the axes defining points to the end so that the arrows go to the board edges.
Expand Down
14 changes: 7 additions & 7 deletions lib/Plots/GD.pm
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ sub im_y {
return unless defined($y);
my $plots = $self->plots;
my ($ymin, $ymax) = ($plots->axes->yaxis('min'), $plots->axes->yaxis('max'));
return int(($ymax - $y) * $plots->{height} / ($ymax - $ymin));
(undef, my $height) = $plots->size;
return int(($ymax - $y) * $height / ($ymax - $ymin));
}

sub moveTo {
Expand Down Expand Up @@ -217,12 +218,11 @@ sub draw_circle_stamp {
}

sub draw {
my $self = shift;
my $plots = $self->plots;
my $axes = $plots->axes;
my $grid = $axes->grid;
my $width = $plots->{width};
my $height = $plots->{height};
my $self = shift;
my $plots = $self->plots;
my $axes = $plots->axes;
my $grid = $axes->grid;
my ($width, $height) = $plots->size;

# Initialize image
$self->im->interlaced('true');
Expand Down
7 changes: 6 additions & 1 deletion lib/Plots/JSXGraph.pm
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ sub init_graph {

my $JSXOptions = Mojo::JSON::encode_json({
title => $axes->style('aria_label'),
description => $axes->style('aria_description'),
boundingBox => [ $xmin, $ymax, $xmax, $ymin ],
axis => 0,
showNavigation => $allow_navigation,
Expand Down Expand Up @@ -497,6 +496,12 @@ sub init_graph {
$self->{JSend} = '';
$self->{JS} = <<~ "END_JS";
const board = JXG.JSXGraph.initBoard(id, $JSXOptions);
const descriptionSpan = document.createElement('span');
descriptionSpan.id = `\${id}_description`;
descriptionSpan.classList.add('visually-hidden');
descriptionSpan.textContent = '${\($axes->style('aria_description'))}';
board.containerObj.after(descriptionSpan);
board.containerObj.setAttribute('aria-describedby', descriptionSpan.id);
board.suspendUpdate();
board.create('axis', [[$xmin, $xaxis_pos], [$xmax, $xaxis_pos]], $XAxisOptions);
board.create('axis', [[$yaxis_pos, $ymin], [$yaxis_pos, $ymax]], $YAxisOptions);
Expand Down
2 changes: 1 addition & 1 deletion macros/core/PGbasicmacros.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2928,9 +2928,9 @@ sub image {
$image_item->{width} = $width if $out_options{width};
$image_item->{height} = $height if $out_options{height};
$image_item->{tex_size} = $tex_size if $out_options{tex_size};
$image_item->axes->style(aria_description => shift @alt_list) if $out_options{alt};

if ($image_item->ext eq 'html') {
$image_item->axes->style(aria_description => shift @alt_list) if $out_options{alt};
$image_item->{description_details} = $description_details;
push(@output_list, $image_item->draw);
next;
Expand Down