Something like ggbApplet.setAxisTickExpression?

s_o shared this question 6 years ago

I'm currently working on something like this for trigonometric functions:

For that I would like to change the x-Axis dynamically from "normal scale" to "π scale". I can set tick distance to π/4 by doing:


But this will not show π / 4 at axis label on the first tick, but 0.79. For that I would need to set a tick expression. I tried:


<viewNumber viewNo="1"/>

<axis id="0" show="true" label="x" unitLabel="" tickStyle="1" showNumbers="true" tickDistance="0.7853981633974483" tickExpression="π / 4"/>


But that does not work, also axis-tag alone won't work. Any idea how to set the tick expression using JavaScript or is that function missing in the current API?

Best regards


Comments (6)


See also the script in piDivisor in the attachment.

For your spezific java-script question I have no answer, respectively: create the axis Labels yourself as in the attachment.

For testing the applet zoomIN and Out.


That is a really great idea! Especially using LaTeX I can display much nicer fractions, if I use steps with higher distance I can also include the pi in every fraction. There are only two problems I noticed: Background of the text is transparent, not solid white, that can probably be fixed using Javascript, second: There are ticks in between the numbers which is stupid, it does not seem to be possible to show ticks but not numbers. So second step is probably to also draw the ticks myself...


Ticks you can change in preferences/graphic/xAxis/Ticks. Alternatively you can hide the ticks form GGB (in Preferences....) and make visible list1.

For my using transparent background-labels are better. But you can change this in properties\list2\color\background-color.

The distance-range you can change in piDivisor. The fraction-formula in list2


Changing background color didn't worked the first time, restarted geogebra, now it's ok. I tried to change the ticks, but without numbers either no ticks at all are shown ( | | | ) or only those ticks between the numbers ( | ' | ' | ).


The grid overwrite the ticks (so you can't see there). If you want see the ticks include the grid then unhide list1.

Background-color and other properties of text has a very old small bug, when you modify the object some properties change (to default ?)


To have the same behavior as you get from setting axis step in GUI you can do just


© 2022 International GeoGebra Institute