api_xgrid_lines.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <html>
  2. <head>
  3. <link rel="stylesheet" type="text/css" href="../css/c3.css">
  4. </head>
  5. <body>
  6. <div id="chart"></div>
  7. <script src="https://d3js.org/d3.v5.min.js" charset="utf-8"></script>
  8. <script src="../js/c3.js"></script>
  9. <script>
  10. var axis_rotated = false, axis_x_type = "";
  11. var generate = function () { return c3.generate({
  12. bindto: '#chart',
  13. data: {
  14. columns: [
  15. ['sample', 30, 200, 100, 400, 150, 250]
  16. ]
  17. },
  18. axis: {
  19. rotated: axis_rotated,
  20. x: {
  21. type: axis_x_type
  22. }
  23. },
  24. grid: {
  25. x: {
  26. // lines: [{value: 3, text:'Label 3'}, {value: 4.5, text: 'Label 4.5'}]
  27. }
  28. }
  29. }); }, chart = generate();
  30. var queue = [
  31. function () {
  32. chart.xgrids([{value: 1, text:'Label 1'}, {value: 4, text: 'Label 4'}]);
  33. },
  34. function () {
  35. chart.xgrids([{value: 2, text:'Label 2'}]);
  36. },
  37. function () {
  38. chart.xgrids.add([{value: 3, text:'Label 3', class:'hoge'}]);
  39. },
  40. function () {
  41. chart.xgrids.remove({value:2});
  42. },
  43. function () {
  44. chart.xgrids.remove({class:'hoge'});
  45. },
  46. function () {
  47. chart.xgrids.remove([{value: 1}, {value: 4}]);
  48. },
  49. function () {
  50. chart.xgrids([{value: 1, text:'Label 1'}, {value: 4, text: 'Label 4'}]);
  51. },
  52. function () {
  53. chart.xgrids.remove();
  54. },
  55. function () {
  56. axis_rotated = true;
  57. chart = generate();
  58. },
  59. function () {
  60. chart.xgrids([{value: 1, text:'Label 1'}, {value: 4, text: 'Label 4'}]);
  61. },
  62. function () {
  63. chart.xgrids([{value: 2, text:'Label 2'}]);
  64. },
  65. function () {
  66. chart.xgrids.add([{value: 3, text:'Label 3', class:'hoge'}]);
  67. },
  68. function () {
  69. chart.xgrids.remove({value:2});
  70. },
  71. function () {
  72. chart.xgrids.remove({class:'hoge'});
  73. },
  74. function () {
  75. chart.xgrids.remove([{value: 1}, {value: 4}]);
  76. },
  77. function () {
  78. chart.xgrids([{value: 1, text:'Label 1'}, {value: 4, text: 'Label 4'}]);
  79. },
  80. function () {
  81. chart.xgrids.remove();
  82. },
  83. function () {
  84. axis_rotated = false;
  85. axis_x_type = 'category';
  86. chart = generate();
  87. },
  88. function () {
  89. chart.xgrids([{value: 1, text:'Label 1'}, {value: 4, text: 'Label 4'}]);
  90. },
  91. function () {
  92. chart.xgrids([{value: 2, text:'Label 2'}]);
  93. },
  94. function () {
  95. chart.xgrids.add([{value: 3, text:'Label 3', class:'hoge'}]);
  96. },
  97. function () {
  98. chart.xgrids.remove({value:2});
  99. },
  100. function () {
  101. chart.xgrids.remove({class:'hoge'});
  102. },
  103. function () {
  104. chart.xgrids.remove([{value: 1}, {value: 4}]);
  105. },
  106. function () {
  107. chart.xgrids([{value: 1, text:'Label 1'}, {value: 4, text: 'Label 4'}]);
  108. },
  109. function () {
  110. chart.xgrids.remove();
  111. },
  112. ];
  113. var i = 0;
  114. queue.forEach(function (f) {
  115. setTimeout(f, 1000 * i++);
  116. });
  117. </script>
  118. </body>
  119. </html>