JSXGraph logo
JSXGraph
JSXGraph share

Share

Circles
QR code
<iframe 
    src="https://www.jsxgraph.org/share/iframe/circles" 
    style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" 
    name="JSXGraph example: Circles" 
    allowfullscreen
></iframe>
This code has to
<div id="board-0-wrapper" class="jxgbox-wrapper " style="width: 100%; ">
   <div id="board-0" class="jxgbox" style="aspect-ratio: 5/2; width: 100%;" data-ar="5/2"></div>
</div>
<div id="board-1-wrapper" class="jxgbox-wrapper " style="width: 100%; ">
   <div id="board-1" class="jxgbox" style="aspect-ratio: 5/2; width: 100%;" data-ar="5/2"></div>
</div>
<div id="board-2-wrapper" class="jxgbox-wrapper " style="width: 100%; ">
   <div id="board-2" class="jxgbox" style="aspect-ratio: 5/2; width: 100%;" data-ar="5/2"></div>
</div>

<script type = "text/javascript"> 
    /*
    This example is licensed under a 
    Creative Commons Attribution 4.0 International License.
    https://creativecommons.org/licenses/by/4.0/
    
    Please note you have to mention 
    The Center of Mobile Learning with Digital Technology
    in the credits.
    */
    
    const BOARDID0 = 'board-0';
    const BOARDID1 = 'board-1';
    const BOARDID2 = 'board-2';
    const BOARDID = BOARDID0;

    (function() {
        const board = JXG.JSXGraph.initBoard(BOARDID0, {
            boundingbox: [-5, 2, 5, -2]
        });
        var a = board.create('point', [0, 0], {
            name: 'A',
            size: 4
        });
        var b = board.create('point', [2, 0], {
            name: 'B',
            size: 4
        });
        var ci = board.create('circle', ["A", "B"], {
            strokeColor: '#00ff00',
            strokeWidth: 2
        });
    })();
    
    (function() {
        const board = JXG.JSXGraph.initBoard(BOARDID1, {
            boundingbox: [-5, 2, 5, -2]
        });
        var a = board.create('point', [0, 0], {
            name: 'A',
            size: 4
        });
        var b = board.create('point', [2, 0], {
            name: 'B',
            size: 4
        });
        var ci = board.create('circle', [a, b], {
            strokeWidth: 3,
            dash: 2,
            fillColor: '#ffff00',
            fillOpacity: 0.3
        });
    })();
    
    (function() {
        const board = JXG.JSXGraph.initBoard(BOARDID2, {
            boundingbox: [-5, 2, 5, -2]
        });
        var a = board.create('point', [0, 0], {
            name: 'A',
            size: 4
        });
        var b = board.create('point', [2, 0], {
            name: 'B',
            size: 4
        });
        var ci = board.create('circle', [a, b], {
            strokeWidth: 1,
            fillColor: '#555500',
            fillOpacity: function() {
                return b.X() * 0.25;
            }
        });
    })();
 </script> 
/*
This example is licensed under a 
Creative Commons Attribution 4.0 International License.
https://creativecommons.org/licenses/by/4.0/

Please note you have to mention 
The Center of Mobile Learning with Digital Technology
in the credits.
*/

const BOARDID0 = 'your_div_id_0'; // Insert your 1st board id here!
const BOARDID1 = 'your_div_id_1'; // Insert your 2nd board id here!
const BOARDID2 = 'your_div_id_2'; // Insert your 3rd board id here!

(function() {
    const board = JXG.JSXGraph.initBoard(BOARDID0, {
        boundingbox: [-5, 2, 5, -2]
    });
    var a = board.create('point', [0, 0], {
        name: 'A',
        size: 4
    });
    var b = board.create('point', [2, 0], {
        name: 'B',
        size: 4
    });
    var ci = board.create('circle', ["A", "B"], {
        strokeColor: '#00ff00',
        strokeWidth: 2
    });
})();

(function() {
    const board = JXG.JSXGraph.initBoard(BOARDID1, {
        boundingbox: [-5, 2, 5, -2]
    });
    var a = board.create('point', [0, 0], {
        name: 'A',
        size: 4
    });
    var b = board.create('point', [2, 0], {
        name: 'B',
        size: 4
    });
    var ci = board.create('circle', [a, b], {
        strokeWidth: 3,
        dash: 2,
        fillColor: '#ffff00',
        fillOpacity: 0.3
    });
})();

(function() {
    const board = JXG.JSXGraph.initBoard(BOARDID2, {
        boundingbox: [-5, 2, 5, -2]
    });
    var a = board.create('point', [0, 0], {
        name: 'A',
        size: 4
    });
    var b = board.create('point', [2, 0], {
        name: 'B',
        size: 4
    });
    var ci = board.create('circle', [a, b], {
        strokeWidth: 1,
        fillColor: '#555500',
        fillOpacity: function() {
            return b.X() * 0.25;
        }
    });
})();
<jsxgraph width="100%, 100%, 100%" aspect-ratio="5/2, 5/2, 5/2" numberOfBoards="3" title="Circles" description="This construction was copied from JSXGraph examples database: BTW HERE SHOULD BE A GENERATED LINKuseGlobalJS="false">
   /*
   This example is licensed under a 
   Creative Commons Attribution 4.0 International License.
   https://creativecommons.org/licenses/by/4.0/
   
   Please note you have to mention 
   The Center of Mobile Learning with Digital Technology
   in the credits.
   */
   
   (function() {
       const board = JXG.JSXGraph.initBoard(BOARDID0, {
           boundingbox: [-5, 2, 5, -2]
       });
       var a = board.create('point', [0, 0], {
           name: 'A',
           size: 4
       });
       var b = board.create('point', [2, 0], {
           name: 'B',
           size: 4
       });
       var ci = board.create('circle', ["A", "B"], {
           strokeColor: '#00ff00',
           strokeWidth: 2
       });
   })();
   
   (function() {
       const board = JXG.JSXGraph.initBoard(BOARDID1, {
           boundingbox: [-5, 2, 5, -2]
       });
       var a = board.create('point', [0, 0], {
           name: 'A',
           size: 4
       });
       var b = board.create('point', [2, 0], {
           name: 'B',
           size: 4
       });
       var ci = board.create('circle', [a, b], {
           strokeWidth: 3,
           dash: 2,
           fillColor: '#ffff00',
           fillOpacity: 0.3
       });
   })();
   
   (function() {
       const board = JXG.JSXGraph.initBoard(BOARDID2, {
           boundingbox: [-5, 2, 5, -2]
       });
       var a = board.create('point', [0, 0], {
           name: 'A',
           size: 4
       });
       var b = board.create('point', [2, 0], {
           name: 'B',
           size: 4
       });
       var ci = board.create('circle', [a, b], {
           strokeWidth: 1,
           fillColor: '#555500',
           fillOpacity: function() {
               return b.X() * 0.25;
           }
       });
   })();
</jsxgraph>

Circles

One possibility to construct a circle is to give its center and a point defining its radius. For this we use the two points $A$ and $B$. Watch the different ways to access the points $A$ and $B$. In the third example the fill color changes dynamically depending on the $x$-coordinate of $B$.
// Define the ids of your boards in BOARDID0, BOARDID1,...

(function() {
    const board = JXG.JSXGraph.initBoard(BOARDID0, {
        boundingbox: [-5, 2, 5, -2]
    });
    var a = board.create('point', [0, 0], {
        name: 'A',
        size: 4
    });
    var b = board.create('point', [2, 0], {
        name: 'B',
        size: 4
    });
    var ci = board.create('circle', ["A", "B"], {
        strokeColor: '#00ff00',
        strokeWidth: 2
    });
})();

(function() {
    const board = JXG.JSXGraph.initBoard(BOARDID1, {
        boundingbox: [-5, 2, 5, -2]
    });
    var a = board.create('point', [0, 0], {
        name: 'A',
        size: 4
    });
    var b = board.create('point', [2, 0], {
        name: 'B',
        size: 4
    });
    var ci = board.create('circle', [a, b], {
        strokeWidth: 3,
        dash: 2,
        fillColor: '#ffff00',
        fillOpacity: 0.3
    });
})();

(function() {
    const board = JXG.JSXGraph.initBoard(BOARDID2, {
        boundingbox: [-5, 2, 5, -2]
    });
    var a = board.create('point', [0, 0], {
        name: 'A',
        size: 4
    });
    var b = board.create('point', [2, 0], {
        name: 'B',
        size: 4
    });
    var ci = board.create('circle', [a, b], {
        strokeWidth: 1,
        fillColor: '#555500',
        fillOpacity: function() {
            return b.X() * 0.25;
        }
    });
})();

license

This example is licensed under a Creative Commons Attribution 4.0 International License.
Please note you have to mention The Center of Mobile Learning with Digital Technology in the credits.