Created
February 23, 2015 09:54
-
-
Save Vaduz/a69c1bd3cf77d895221c to your computer and use it in GitHub Desktop.
kataso dice chart
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
var script = document.createElement("script"); | |
script.src = "https://www.google.com/jsapi"; | |
document.body.appendChild(script); | |
var chart_div = document.createElement("div"); | |
chart_div.id = "dice_chart"; | |
google.load("visualization", '1', {packages:['corechart']}); | |
var chart = new google.visualization.ColumnChart(chart_div); | |
var rolls = { | |
2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0, 12: 0 | |
}; | |
var trials = 0; | |
var chats = document.getElementsByClassName('chat'); | |
for (var i = 0, len = chats.length; i < len; ++i) { | |
var chatText = chats[i].firstElementChild.innerHTML; | |
// console.log(chatText); | |
// var turn; | |
// if (turn = /^--「(\w+)\(([青赤黄緑])\)」ターン--$/.exec(chatText)) { | |
// console.log("ターン変更. プレイヤー: " + turn[1] + ", 色: " + turn[2]); | |
// } | |
var num; | |
if (num = /^ダイス「(\d+)」$/.exec(chatText)) { | |
// console.log("num: " + num[1]); | |
rolls[num[1]]++; | |
trials++; | |
} | |
} | |
console.log(rolls); | |
console.log(trials); | |
var percent_of_rolls = []; | |
for (key in rolls) { | |
percent_of_rolls.push(Math.round((rolls[key] / trials) * 10000) / 100); | |
} | |
// console.log(percent_of_rolls.join(',')); | |
console.log('http://chart.apis.google.com/chart?chs=480x480&chd=t:' + percent_of_rolls.join(',') + '|2.78,5.56,8.33,11.11,13.89,16.67,13.89,11.11,8.33,5.56,2.78&chxt=x,y&chxl=0:|2|3|4|5|6|7|8|9|10|11|12&chyp=1,5,10,15,20&cht=bvg&chco=ff0000,666666&chbh=10,2,5&chdl=actual|theoretical&chtt=' + trials); | |
&chxp=1,5,10,15,20&chxr=1,0,25 | |
http://chart.apis.google.com/chart?chs=480x480&chd=t:2.3,5.75,6.9,9.2,20.69,13.79,14.94,11.49,8.05,3.45,3.45|2.78,5.56,8.33,11.11,13.89,16.67,13.89,11.11,8.33,5.56,2.78&chxp=1,1,5,10,15,20&chxt=x,y&chxl=0:|2|3|4|5|6|7|8|9|10|11|12&cht=bvg&chco=ff0000,666666&chbh=10,2,5&chdl=actual|theoretical&chtt=87&chxr=1,0,25 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment