Custom axis label in JSXGraph

5 views
Skip to first unread message

David Wishart

unread,
Mar 6, 2024, 11:24:23 AMMar 6
to Numbas Users
I have an issue with trying to generate custom axis labels in JSXGraph which, whilst my code appears to work fine when I refresh the page with F5, fails every time I click 'Try another question like this' in Numbas.

The gist of what I'm trying to do is on the codepen below. I basically want a variable axis label that can be a fraction of pi, eg pi, pi/2, pi/3 etc. This version appears to work as I want, every time I refresh the page the label updates.

With the same question in Numbas however, refreshing the page with F5 works fine but 'Try another question like this one' gives errors. It gives a [Math Processing Error] at the first retry followed by what looks like raw Latex on the second and any subsequent retries.

I'm guessing it's to do with the way the lambda function returns generateLabelText but the solution is beyond me.

Christian Lawson-Perfect

unread,
Mar 7, 2024, 4:37:09 AMMar 7
to numbas...@googlegroups.com
The problem seems to be that JSXGraph is trying to typeset the maths before the graph is attached to the question statement, so the \var command can't get the question's variables.
I'll see if I can get it to wait before typesetting.

--
You received this message because you are subscribed to the Google Groups "Numbas Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numbas-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/numbas-users/fb763d4d-d7ba-413e-b334-16ba678155b1n%40googlegroups.com.

Christian Lawson-Perfect

unread,
Mar 7, 2024, 5:07:16 AMMar 7
to numbas...@googlegroups.com
If you set useMathJax: false, then JSXGraph won't try to run MathJax on labels itself; instead, Numbas will run MathJax once the board is attached to the question statement. I think that fixes it.
I couldn't think of a better way of resolving this without changing JSXGraph. I might file an issue with them about this.

David Wishart

unread,
Mar 7, 2024, 6:38:34 AMMar 7
to Numbas Users
Thanks Christian,
Unfortunately useMathJax: false does not appear to change the behaviour.

Christian Lawson-Perfect

unread,
Mar 7, 2024, 10:10:25 AMMar 7
to numbas...@googlegroups.com
You had useMathJax twice: once as a global setting, and again when making the replacement ticks. I've made a copy of your question where they're both set to false, and it seems to work OK for me: https://numbas.mathcentre.ac.uk/question/share/view/b6c61105-ac2e-46ec-8b23-fa2adb0f3efc

David Wishart

unread,
Mar 7, 2024, 10:18:07 AMMar 7
to Numbas Users
Whoops, missed that! Thank-you, all sorted, I'll just keep the global setting as I have no need for JSXGraph to be using MathJax elsewhere, not even in the full question.
Reply all
Reply to author
Forward
0 new messages