axisjsxgraphxticks

JSXGraph: Is it possible to manually set the x and y tick distance


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.


Solution

  • 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/