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