1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
|
<html>
<head>
<title>JSXGraph example</title>
<link rel="stylesheet" type="text/css" href="../distrib/jsxgraph.css" />
<script type="text/javascript" src="../distrib/jsxgraphcore.js"></script>
<script type="text/javascript" src="/javascript/jquery/jquery.js"></script>
</head>
<body>
<h2>Playground to test things temporarily. May change very often.</h2>
<input type="button" value="Line chart" onClick="lineChart()">
<input type="button" value="Spline chart" onClick="splineChart()">
<input type="button" value="Bar chart" onClick="barChart()">
<input type="button" value="Multiple styles" onClick="multiStyleChart()">
<input type="button" value="Two bar charts" onClick="twoBarCharts()">
<input type="button" value="Horizontal bars" onClick="horizontalBarChart()">
<input type="button" value="Dynamic bars" onClick="dynamicBarChart()">
<input type="button" value="Regression line" onClick="fitChart(1)">
<input type="button" value="Regression parabola" onClick="fitChart(2)">
<div style="width:800px">
<div id="jxgbox" class="jxgbox" style="width:800px; height:800px; float:left;"></div>
</div>
<div id="debug" style="display:block;">DEBUG</div>
<script type="text/javascript">
/* <![CDATA[ */
var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-1, 10, 11, -2], axis: true});
var dataArr = [4,1,3,2,5,7,1.5,2];
// Line chart
function lineChart() {
JXG.JSXGraph.freeBoard(board);
board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-1, 10, 11, -2], axis: true});
board.suspendUpdate();
var a = board.create('chart', dataArr, {chartStyle:'line',strokeWidth:4,strokeColor:'#0000ff'});
board.unsuspendUpdate();
};
// Line chart with cubic splines
function splineChart() {
JXG.JSXGraph.freeBoard(board);
board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-1, 10, 11, -2], axis: true});
board.suspendUpdate();
var a = board.create('chart', dataArr, {chartStyle:'spline',strokeWidth:4,strokeColor:'#0000ff'});
board.unsuspendUpdate();
};
// Bar chart
function barChart() {
JXG.JSXGraph.freeBoard(board);
board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-1, 10, 11, -2], axis: true});
board.suspendUpdate();
var a = board.create('chart', dataArr, {chartStyle:'bar',width:0.6,labels:dataArr});
board.unsuspendUpdate();
};
// Single chart with multiple styles
function multiStyleChart() {
JXG.JSXGraph.freeBoard(board);
board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-1, 10, 11, -2], axis: true});
board.suspendUpdate();
var a = board.create('chart', dataArr, {chartStyle:'bar,line,point',width:0.8,size:4,labels:dataArr});
board.unsuspendUpdate();
};
// Two bar charts
function twoBarCharts() {
JXG.JSXGraph.freeBoard(board);
board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-1, 10, 11, -2], axis: true});
board.suspendUpdate();
var a = board.create('chart', [[1,3,5,7],[4,-1,3,2]], {chartStyle:'bar',width:0.8});
var b = board.create('chart', [[2,4,6,8],[3,1,2,5]], {chartStyle:'bar',fillColor:'#C3D9FF',width:0.8});
board.unsuspendUpdate();
};
// Bar chart with horizontal bars
function horizontalBarChart() {
JXG.JSXGraph.freeBoard(board);
board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-1, 10, 11, -2], axis: true});
board.suspendUpdate();
var a = board.create('chart', dataArr, {chartStyle:'bar',labels:dataArr,width:0.8,dir:'horizontal'});
board.unsuspendUpdate();
};
// Single chart with dynamic entries
function dynamicBarChart() {
JXG.JSXGraph.freeBoard(board);
board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-1, 10, 11, -2], axis: true});
board.suspendUpdate();
var s = board.create('slider', [[5,-1],[8,-1], [1,1,2]], {name:'S'});
var f = [function(){return Math.round(s.Value()*4,2);},
function(){return Math.round(s.Value()*(-1),2);},
function(){return Math.round(s.Value()*3,2);},
function(){return Math.round(s.Value()*2,2);}];
var chart = board.create('chart', [f], {chartStyle:'bar',width:0.8,labels:f});
board.unsuspendUpdate();
};
// Regression curve
function fitChart(deg) {
JXG.JSXGraph.freeBoard(board);
board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-1, 10, 11, -2], axis: true});
board.suspendUpdate();
var a = board.create('chart', dataArr,
{chartStyle:'bar,fit', degree:deg, colorArray:['#B02B2C','#3F4C6B','#C79810','#D15600'], dash:2}
);
board.unsuspendUpdate();
}
lineChart();
/* ]]> */
</script>
</body>
</html>
|