point label color and position

16 views
Skip to first unread message

Christian Bauer

unread,
Nov 8, 2021, 9:28:28 AM11/8/21
to JSXGraph
Hi all,
I want to change the position and color of some (not all) labels of points in my graph. How do I do this?
var P1 = b1.create('point',[1,0],{face:'o',name:'K_1',label:{offset:[-10,-25]}});
works for the position, but labelColor:'red' doesn't and position:'bot' instead of offset neither.
Best, Christian

Alfred Wassermann

unread,
Nov 8, 2021, 12:37:30 PM11/8/21
to JSXGraph
Hi Christian,
instead of "offset", you want to use anchorX and anchorY of the label to define which corner (or point) of the label is positioned relatively to the point coordinates.
For example, if the upper right corner of the label text should be at position [1, 0], you can set

 P1 = board.create('point',[1,0],

     {face:'o',
   name:'K_1',
   label:{
     anchorX: 'right', // right, left, 'middle'
     anchorY: 'top', // 'top', 'bottom', 'middle'
     offset:[0, 0],
     strokeColor: 'blue',
     fontSize: 24
   }
  });

By setting the offset with pixel values e.g. [-5,-5] you can adjust the label position a little bit further.
The text color can be set with the property "strokeColor" of the label.

Best wishes,
Alfred


Reply all
Reply to author
Forward
0 new messages