Something like ggbApplet.setAxisTickExpression?

s_o shared this question 4 years ago
Answered

I'm currently working on something like this for trigonometric functions: https://www.geogebra.org/m/gdMAhp3m


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:


ggbApplet.setAxisSteps(1,0.7853981633974483,1,1);


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:


ggbApplet.evalXML('<euclidianView>

<viewNumber viewNo="1"/>

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

</euclidianView>');


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

Stefan

Comments (6)

photo
1

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.

photo
1

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...

photo
1

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

photo
1

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 ( | ' | ' | ).

photo
1

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 ?)

photo
1

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

ggbApplet.setAxisSteps(1,"pi/4",1,1);

© 2020 International GeoGebra Institute