JSXGraph logo
JSXGraph
JSXGraph share

Share

Pie chart II
QR code
<iframe 
    src="http://jsxgraph.uni-bayreuth.de/share/iframe/pie-chart-ii" 
    style="border: 1px solid black; overflow: hidden; width: 550px; aspect-ratio: 55 / 65;" 
    name="JSXGraph example: Pie chart II" 
    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: 1 / 1; width: 100%;" data-ar="1 / 1"></div>
</div>

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

    var board = JXG.JSXGraph.initBoard(BOARDID, {originX: 50, originY: 450, unitX: 50, unitY: 50, axis:true, keepaspectratio: true});
    board.suspendUpdate();
    
    var s = board.create('slider', [[8,7],[11,7],[1,1,1.5]],{name:'S',strokeColor:'black',fillColor:'white'});
    var f = [function(){return (s.Value()*1).toFixed(2);},
    	 function(){return (s.Value()*2).toFixed(2);},
    	 function(){return (s.Value()*3).toFixed(2);},
    	 function(){return (s.Value()*4).toFixed(2);},
    	 function(){return 4;},
    	 function(){return 2;},
    	 function(){return 1;},
    	 function(){return 1.2;},
    	 function(){return 3;},
    	 function(){return 1;},
    	 function(){return 1.7;}
    	];
    
    var a = board.create('chart', [f],
    			{chartStyle:'pie',
    			 colorArray:
    ['#0F408D','#6F1B75','#CA147A','#DA2228','#E8801B','#FCF302','#8DC922','#15993C','#87CCEE','#0092CE','#CA147A'],
    center:[5,2], strokeColor:'black', highlightStrokeColor:'black',
    strokeWidth:4,
    			 highlightColorArray:
    ['#E46F6A','#F9DF82','#F7FA7B','#B0D990','#69BF8E','#BDDDE4','#92C2DF','#637CB0','#AB91BC','#EB8EBF','#B0D990'],
    			 highlightOnSector:true}
    		);
    
    board.unsuspendUpdate();
 </script> 
/*
This example is licensed under a 
Creative Commons Attribution ShareAlike 4.0 International License.
https://creativecommons.org/licenses/by-sa/4.0/

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

const BOARDID = 'your_div_id'; // Insert your id here!

var board = JXG.JSXGraph.initBoard(BOARDID, {originX: 50, originY: 450, unitX: 50, unitY: 50, axis:true, keepaspectratio: true});
board.suspendUpdate();

var s = board.create('slider', [[8,7],[11,7],[1,1,1.5]],{name:'S',strokeColor:'black',fillColor:'white'});
var f = [function(){return (s.Value()*1).toFixed(2);},
	 function(){return (s.Value()*2).toFixed(2);},
	 function(){return (s.Value()*3).toFixed(2);},
	 function(){return (s.Value()*4).toFixed(2);},
	 function(){return 4;},
	 function(){return 2;},
	 function(){return 1;},
	 function(){return 1.2;},
	 function(){return 3;},
	 function(){return 1;},
	 function(){return 1.7;}
	];

var a = board.create('chart', [f],
			{chartStyle:'pie',
			 colorArray:
['#0F408D','#6F1B75','#CA147A','#DA2228','#E8801B','#FCF302','#8DC922','#15993C','#87CCEE','#0092CE','#CA147A'],
center:[5,2], strokeColor:'black', highlightStrokeColor:'black',
strokeWidth:4,
			 highlightColorArray:
['#E46F6A','#F9DF82','#F7FA7B','#B0D990','#69BF8E','#BDDDE4','#92C2DF','#637CB0','#AB91BC','#EB8EBF','#B0D990'],
			 highlightOnSector:true}
		);

board.unsuspendUpdate();
<jsxgraph width="100%" aspect-ratio="1 / 1" title="Pie chart II" 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 ShareAlike 4.0 International License.
   https://creativecommons.org/licenses/by-sa/4.0/
   
   Please note you have to mention 
   The Center of Mobile Learning with Digital Technology
   in the credits.
   */
   
   var board = JXG.JSXGraph.initBoard(BOARDID, {originX: 50, originY: 450, unitX: 50, unitY: 50, axis:true, keepaspectratio: true});
   board.suspendUpdate();
   
   var s = board.create('slider', [[8,7],[11,7],[1,1,1.5]],{name:'S',strokeColor:'black',fillColor:'white'});
   var f = [function(){return (s.Value()*1).toFixed(2);},
   	 function(){return (s.Value()*2).toFixed(2);},
   	 function(){return (s.Value()*3).toFixed(2);},
   	 function(){return (s.Value()*4).toFixed(2);},
   	 function(){return 4;},
   	 function(){return 2;},
   	 function(){return 1;},
   	 function(){return 1.2;},
   	 function(){return 3;},
   	 function(){return 1;},
   	 function(){return 1.7;}
   	];
   
   var a = board.create('chart', [f],
   			{chartStyle:'pie',
   			 colorArray:
   ['#0F408D','#6F1B75','#CA147A','#DA2228','#E8801B','#FCF302','#8DC922','#15993C','#87CCEE','#0092CE','#CA147A'],
   center:[5,2], strokeColor:'black', highlightStrokeColor:'black',
   strokeWidth:4,
   			 highlightColorArray:
   ['#E46F6A','#F9DF82','#F7FA7B','#B0D990','#69BF8E','#BDDDE4','#92C2DF','#637CB0','#AB91BC','#EB8EBF','#B0D990'],
   			 highlightOnSector:true}
   		);
   
   board.unsuspendUpdate();
</jsxgraph>

Pie chart II

Use the slider in this dynamic pie chart to scale sector values and instantly update the chart. **AI generated desctiption**
// Define the id of your board in BOARDID

var board = JXG.JSXGraph.initBoard(BOARDID, {originX: 50, originY: 450, unitX: 50, unitY: 50, axis:true, keepaspectratio: true});
board.suspendUpdate();

var s = board.create('slider', [[8,7],[11,7],[1,1,1.5]],{name:'S',strokeColor:'black',fillColor:'white'});
var f = [function(){return (s.Value()*1).toFixed(2);},
	 function(){return (s.Value()*2).toFixed(2);},
	 function(){return (s.Value()*3).toFixed(2);},
	 function(){return (s.Value()*4).toFixed(2);},
	 function(){return 4;},
	 function(){return 2;},
	 function(){return 1;},
	 function(){return 1.2;},
	 function(){return 3;},
	 function(){return 1;},
	 function(){return 1.7;}
	];

var a = board.create('chart', [f],
			{chartStyle:'pie',
			 colorArray:
['#0F408D','#6F1B75','#CA147A','#DA2228','#E8801B','#FCF302','#8DC922','#15993C','#87CCEE','#0092CE','#CA147A'],
center:[5,2], strokeColor:'black', highlightStrokeColor:'black',
strokeWidth:4,
			 highlightColorArray:
['#E46F6A','#F9DF82','#F7FA7B','#B0D990','#69BF8E','#BDDDE4','#92C2DF','#637CB0','#AB91BC','#EB8EBF','#B0D990'],
			 highlightOnSector:true}
		);

board.unsuspendUpdate();

license

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