1

Say one draws an axis inside a given bounding box, and the ticks are automatically placed. How about placing more/fewer/different ticks along the axes? Is it possible to change the distance of x and y ticks?

EDIT:

I managed to control minorTicks, but ticksDistance and ticksDelta do not have an effect, see MWE in JSFiddle.

FlorianL
  • 267
  • 2
  • 10
  • 2
    Yes. There are plety of options for ticks (which makes it difficult...). See https://jsxgraph.org/wiki/index.php/Ticks and http://jsxgraph.org/docs/symbols/Ticks.html for more information. If you have a specific example, please post it as jsfiddle. – Alfred Wassermann May 07 '21 at 20:30
  • Thanks for your hints thus far! I added an EDIT section above with a JSFiddle link. Is there a way to get ``ticksDistance`` or ``ticksDelta`` to work such that major ticks only occur for multiples of 5? – FlorianL May 07 '21 at 21:42

1 Answers1

2

You are already very close to the solution. The only missing attribute is insertTicks: false, which disables the automatic insertion of major ticks. ticksDelta is not necessary. Here is the code:

const brd0 = JXG.JSXGraph.initBoard('BOARDID0', { 
  boundingbox: [-1, 11, 12, -11], axis:true, 
  defaultAxes: {
    x: {
       withLabel: true, 
       name: 't in s',
           label: {
             position: 'rt', 
             offset: [-0, 15], 
             anchorX: 'right'
           },
           ticks: {
             insertTicks: false,
             ticksDistance: 5, 
             minorTicks: 4
           } 
        },
    y: {withLabel:true, name: 'x in m',      
        label: {position: 'rt', offset: [+15, -0]} } },
  showCopyright: false, showNavigation: false 
});

Additionally, I set minorTicks:4. See it live at https://jsfiddle.net/sxpm1z35/2/

Alfred Wassermann
  • 2,248
  • 1
  • 11
  • 10