Created
June 21, 2016 04:46
-
-
Save anonymous/8bce3821424418e704eeec4406c6d831 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> | |
<script type="text/javascript"> | |
google.charts.load('current', {'packages':['corechart']}); | |
google.charts.setOnLoadCallback(drawChart); | |
var a1=0; | |
function radom() | |
{ | |
var maxNum = 3; | |
var minNum = 0; | |
a1 = Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum; | |
if(a1==0) | |
{ | |
drawChart0(); | |
} | |
if(a1==1) | |
{ | |
drawChart1(); | |
} | |
if(a1==2) | |
{ | |
drawChart2(); | |
} | |
if(a1==3) | |
{ | |
drawChart3(); | |
} | |
} | |
function drawChart0() { | |
var data = google.visualization.arrayToDataTable([ | |
['Task', 'Hours per Day'], | |
['Work', 1], | |
['Eat', 1], | |
['Commute', 1], | |
['b', 1], | |
]); | |
var options = { | |
title: 'My Daily Activities' ,width: 900,height: 400, | |
pieSliceText: '', | |
pieStartAngle: 0, | |
tooltip: { trigger: '' }, | |
slices: { | |
0: { color: 'yellow' }, | |
1: { color: 'red' }, | |
2: { color: 'black' }, | |
3: { color: 'blue' }, | |
} | |
}; | |
var chart = new google.visualization.PieChart(document.getElementById('piechart')); | |
chart.draw(data, options); | |
} | |
function drawChart1() { | |
var data = google.visualization.arrayToDataTable([ | |
['Task', 'Hours per Day'], | |
['Work', 1], | |
['Eat', 1], | |
['Commute', 1], | |
['b', 1], | |
]); | |
var options = { | |
title: 'My Daily Activities' ,width: 900,height: 400, | |
pieSliceText: '', | |
pieStartAngle: 0, | |
tooltip: { trigger: '' }, | |
slices: { | |
0: { color: 'green' }, | |
1: { color: 'red' }, | |
2: { color: 'black' }, | |
3: { color: 'blue' }, | |
} | |
}; | |
var chart = new google.visualization.PieChart(document.getElementById('piechart')); | |
chart.draw(data, options); | |
} | |
function drawChart2() { | |
var data = google.visualization.arrayToDataTable([ | |
['Task', 'Hours per Day'], | |
['Work', 1], | |
['Eat', 1], | |
['Commute', 1], | |
['b', 1], | |
]); | |
var options = { | |
title: 'My Daily Activities' ,width: 900,height: 400, | |
pieSliceText: '', | |
pieStartAngle: 0, | |
tooltip: { trigger: '' }, | |
slices: { | |
0: { color: 'purple' }, | |
1: { color: 'red' }, | |
2: { color: 'black' }, | |
3: { color: 'blue' }, | |
} | |
}; | |
var chart = new google.visualization.PieChart(document.getElementById('piechart')); | |
chart.draw(data, options); | |
} | |
function drawChart3() { | |
var data = google.visualization.arrayToDataTable([ | |
['Task', 'Hours per Day'], | |
['Work', 1], | |
['Eat', 1], | |
['Commute', 1], | |
['b', 1], | |
]); | |
var options = { | |
title: 'My Daily Activities' ,width: 900,height: 400, | |
pieSliceText: '', | |
pieStartAngle: 0, | |
tooltip: { trigger: '' }, | |
slices: { | |
0: { color: 'white' }, | |
1: { color: 'red' }, | |
2: { color: 'black' }, | |
3: { color: 'blue' }, | |
} | |
}; | |
var chart = new google.visualization.PieChart(document.getElementById('piechart')); | |
chart.draw(data, options); | |
} | |
</script> | |
<body> | |
<input type="button" value="radom" onclick="radom()"/> | |
<div id="piechart" style="width: 900px; height: 500px;"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment