SOURCE

console 命令行工具 X clear

                    
>
console
var board = JXG.JSXGraph.initBoard('jxgbox',
    {
        boundingbox: [-5, 2, 5, -2],
        axis: true,
        grid: true,
        zoom: true
    }
);

var line1 = board.create("line", [[-3, 1], [3, -1]]);
//直接使用未声明坐标点生成的直线

var p = board.create('point', [-2, -1]);
var q = board.create('point', [3, 1]);
var line2 = board.create("line", [p, q]);
//使用已经声明坐标点生成的直线,默认名称A、B

 var p2 = board.create('point',[-3,-1],{name:"first", size:5, color:"FF0000"});
 var q2 = board.create('point',[2,1],{name:"last",fixed:true, face:"diamond"});
//自定义point,名称、颜色、是否固定
/*
face:
cross
circle
square
plus
diamond
triangleUp
triangleDown
triangleLeft
triangleRight

b3a.create('point',[1,0], {face:'o'});  // or circle
b3a.create('point',[2,0], {face:'[]'}); // or square
b3a.create('point',[3,0], {face:'x'});  // or cross
b3a.create('point',[4,0], {face:'+'});  // or plus
b3a.create('point',[5,0], {face:'^'});  // or triangleUp
b3a.create('point',[6,0], {face:'v'});  // or triangleDown
b3a.create('point',[7,0], {face:'>'});  // or triangleLeft
b3a.create('point',[8,0], {face:'<'});  // or triangleRight
b3a.create('point',[9,0], {face:'<>'}); // or diamond


*/

 var line2 = board.create("line",[p2,q2],{straightLast:false, dash:"4" });
 //有固定点的地方,直线不能移动,可以沿着固定点旋转。straightLast:false:不再延长, dash:"4":虚线 
<!DOCTYPE HTML>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<title>JSXGraph template</title>
	<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
	<link href="https://cdn.jsdelivr.net/npm/jsxgraph/distrib/jsxgraph.css" rel="stylesheet" type="text/css" />
	<script src="https://cdn.jsdelivr.net/npm/jsxgraph/distrib/jsxgraphcore.js" type="text/javascript" charset="UTF-8">

	</script>
	<!-- The next line is optional: MathJax -->
	<script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js" id="MathJax-script" async>

	</script>
</head>

<body>

	<div id="jxgbox" class="jxgbox" style="width:500px; height:200px;"></div>

</body>

</html>