No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

piechart.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //円グラフのデータ
  2. var PopMan = 8862;
  3. var PopWoman = 9596;
  4. var data = [
  5. {
  6. value : PopMan,
  7. color : "#01a9de"
  8. },
  9. {
  10. value : PopWoman,
  11. color : "#eb5f60"
  12. }
  13. ];
  14. var options = {
  15. //Boolean - Whether we should animate the chart
  16. animation : true,
  17. //Number - Amount of animation steps
  18. animationSteps : 100,
  19. //String - Animation easing effect
  20. //animationEasing : "easeOutBounce",
  21. //Boolean - Whether we animate the rotation of the Pie
  22. //animateRotate : true,
  23. //Boolean - Whether we animate scaling the Pie from the centre
  24. animateScale : false,
  25. //Function - Will fire on animation completion.
  26. onAnimationComplete : function(){
  27. var Man = new Image();
  28. var Woman = new Image();
  29. Man.src = "css/img/Man.png?" + new Date().getTime();
  30. Woman.src = "css/img/Woman.png?" + new Date().getTime();
  31. Man.onload = function() {
  32. ctx.drawImage(Man, 151, 70, 20, 50);
  33. }
  34. Woman.onload = function() {
  35. ctx.drawImage(Woman, 9, 70, 20, 50);
  36. }
  37. var Pop = parseInt(PopMan) + parseInt(PopWoman);
  38. var PerPopMan = Math.round(parseInt(PopMan) / parseInt(Pop) * 100);
  39. var PerPopWoman = Math.round(parseInt(PopWoman) / parseInt(Pop) * 100);
  40. var PopMan_text = document.getElementById("PopMan_text");
  41. var PopWoman_text = document.getElementById("PopWoman_text");
  42. var PerPopMan_text = document.getElementById("PerPopMan_text");
  43. var PerPopWoman_text = document.getElementById("PerPopWoman_text");
  44. PerPopMan_text.innerHTML = PerPopMan + "%";
  45. PerPopWoman_text.innerHTML = PerPopWoman + "%";
  46. PopMan_text.style.display = "block";
  47. PopWoman_text.style.display = "block";
  48. PerPopMan_text.style.display = "block";
  49. PerPopWoman_text.style.display = "block";
  50. }
  51. };
  52. var ctx = null;
  53. var NewChart = null;
  54. function piechart1(){
  55. ctx = $("#Maletofemaleratio").get(0).getContext("2d"),//Canvasのコンテキスト取得
  56. NewChart = new Chart(ctx);//チャートを生成
  57. NewChart.Pie(data,options);
  58. }
  59. /* オンロード時に動作 */
  60. if(window.addEventListener) {
  61. window.addEventListener('load', piechart1, false);
  62. } else {
  63. window.attachEvent("onload", piechart1);
  64. }