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.

218 lines
5.6 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. (function($) {
  2. 'use strict';
  3. var c3LineChart = c3.generate({
  4. bindto: '#c3-line-chart',
  5. data: {
  6. columns: [
  7. ['data1', 30, 200, 100, 400, 150, 250],
  8. ['data2', 50, 20, 10, 40, 15, 25]
  9. ]
  10. },
  11. color: {
  12. pattern: ['rgba(88,216,163,1)', 'rgba(237,28,36,0.6)', 'rgba(4,189,254,0.6)']
  13. },
  14. padding: {
  15. top: 0,
  16. right: 0,
  17. bottom: 30,
  18. left: 0,
  19. }
  20. });
  21. setTimeout(function() {
  22. c3LineChart.load({
  23. columns: [
  24. ['data1', 230, 190, 300, 500, 300, 400]
  25. ]
  26. });
  27. }, 1000);
  28. setTimeout(function() {
  29. c3LineChart.load({
  30. columns: [
  31. ['data3', 130, 150, 200, 300, 200, 100]
  32. ]
  33. });
  34. }, 1500);
  35. setTimeout(function() {
  36. c3LineChart.unload({
  37. ids: 'data1'
  38. });
  39. }, 2000);
  40. var c3SplineChart = c3.generate({
  41. bindto: '#c3-spline-chart',
  42. data: {
  43. columns: [
  44. ['data1', 30, 200, 100, 400, 150, 250],
  45. ['data2', 130, 100, 140, 200, 150, 50]
  46. ],
  47. type: 'spline'
  48. },
  49. color: {
  50. pattern: ['rgba(88,216,163,1)', 'rgba(237,28,36,0.6)', 'rgba(4,189,254,0.6)']
  51. },
  52. padding: {
  53. top: 0,
  54. right: 0,
  55. bottom: 30,
  56. left: 0,
  57. }
  58. });
  59. var c3BarChart = c3.generate({
  60. bindto: '#c3-bar-chart',
  61. data: {
  62. columns: [
  63. ['data1', 30, 200, 100, 400, 150, 250],
  64. ['data2', 130, 100, 140, 200, 150, 50]
  65. ],
  66. type: 'bar'
  67. },
  68. color: {
  69. pattern: ['rgba(88,216,163,1)', 'rgba(4,189,254,0.6)', 'rgba(237,28,36,0.6)']
  70. },
  71. padding: {
  72. top: 0,
  73. right: 0,
  74. bottom: 30,
  75. left: 0,
  76. },
  77. bar: {
  78. width: {
  79. ratio: 0.7 // this makes bar width 50% of length between ticks
  80. }
  81. }
  82. });
  83. setTimeout(function() {
  84. c3BarChart.load({
  85. columns: [
  86. ['data3', 130, -150, 200, 300, -200, 100]
  87. ]
  88. });
  89. }, 1000);
  90. var c3StepChart = c3.generate({
  91. bindto: '#c3-step-chart',
  92. data: {
  93. columns: [
  94. ['data1', 300, 350, 300, 0, 0, 100],
  95. ['data2', 130, 100, 140, 200, 150, 50]
  96. ],
  97. types: {
  98. data1: 'step',
  99. data2: 'area-step'
  100. }
  101. },
  102. color: {
  103. pattern: ['rgba(88,216,163,1)', 'rgba(4,189,254,0.6)', 'rgba(237,28,36,0.6)']
  104. },
  105. padding: {
  106. top: 0,
  107. right: 0,
  108. bottom: 30,
  109. left: 0,
  110. }
  111. });
  112. var c3PieChart = c3.generate({
  113. bindto: '#c3-pie-chart',
  114. data: {
  115. // iris data from R
  116. columns: [
  117. ['data1', 30],
  118. ['data2', 120],
  119. ],
  120. type: 'pie',
  121. onclick: function(d, i) {
  122. console.log("onclick", d, i);
  123. },
  124. onmouseover: function(d, i) {
  125. console.log("onmouseover", d, i);
  126. },
  127. onmouseout: function(d, i) {
  128. console.log("onmouseout", d, i);
  129. }
  130. },
  131. color: {
  132. pattern: ['#6153F9', '#8E97FC', '#A7B3FD']
  133. },
  134. padding: {
  135. top: 0,
  136. right: 0,
  137. bottom: 30,
  138. left: 0,
  139. }
  140. });
  141. setTimeout(function() {
  142. c3PieChart.load({
  143. columns: [
  144. ["Income", 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2, 0.4, 0.4, 0.3, 0.3, 0.3, 0.2, 0.4, 0.2, 0.5, 0.2, 0.2, 0.4, 0.2, 0.2, 0.2, 0.2, 0.4, 0.1, 0.2, 0.2, 0.2, 0.2, 0.1, 0.2, 0.2, 0.3, 0.3, 0.2, 0.6, 0.4, 0.3, 0.2, 0.2, 0.2, 0.2],
  145. ["Outcome", 1.4, 1.5, 1.5, 1.3, 1.5, 1.3, 1.6, 1.0, 1.3, 1.4, 1.0, 1.5, 1.0, 1.4, 1.3, 1.4, 1.5, 1.0, 1.5, 1.1, 1.8, 1.3, 1.5, 1.2, 1.3, 1.4, 1.4, 1.7, 1.5, 1.0, 1.1, 1.0, 1.2, 1.6, 1.5, 1.6, 1.5, 1.3, 1.3, 1.3, 1.2, 1.4, 1.2, 1.0, 1.3, 1.2, 1.3, 1.3, 1.1, 1.3],
  146. ["Revenue", 2.5, 1.9, 2.1, 1.8, 2.2, 2.1, 1.7, 1.8, 1.8, 2.5, 2.0, 1.9, 2.1, 2.0, 2.4, 2.3, 1.8, 2.2, 2.3, 1.5, 2.3, 2.0, 2.0, 1.8, 2.1, 1.8, 1.8, 1.8, 2.1, 1.6, 1.9, 2.0, 2.2, 1.5, 1.4, 2.3, 2.4, 1.8, 1.8, 2.1, 2.4, 2.3, 1.9, 2.3, 2.5, 2.3, 1.9, 2.0, 2.3, 1.8],
  147. ]
  148. });
  149. }, 1500);
  150. setTimeout(function() {
  151. c3PieChart.unload({
  152. ids: 'data1'
  153. });
  154. c3PieChart.unload({
  155. ids: 'data2'
  156. });
  157. }, 2500);
  158. var c3DonutChart = c3.generate({
  159. bindto: '#c3-donut-chart',
  160. data: {
  161. columns: [
  162. ['data1', 30],
  163. ['data2', 120],
  164. ],
  165. type: 'donut',
  166. onclick: function(d, i) {
  167. console.log("onclick", d, i);
  168. },
  169. onmouseover: function(d, i) {
  170. console.log("onmouseover", d, i);
  171. },
  172. onmouseout: function(d, i) {
  173. console.log("onmouseout", d, i);
  174. }
  175. },
  176. color: {
  177. pattern: ['rgba(88,216,163,1)', 'rgba(4,189,254,0.6)', 'rgba(237,28,36,0.6)']
  178. },
  179. padding: {
  180. top: 0,
  181. right: 0,
  182. bottom: 30,
  183. left: 0,
  184. },
  185. donut: {
  186. title: "Iris Petal Width"
  187. }
  188. });
  189. setTimeout(function() {
  190. c3DonutChart.load({
  191. columns: [
  192. ["setosa", 0.2, 0.2, 0.2, 0.2, 0.2, 0.4, 0.3, 0.2, 0.2, 0.1, 0.2, 0.2, 0.1, 0.1, 0.2, 0.4, 0.4, 0.3, 0.3, 0.3, 0.2, 0.4, 0.2, 0.5, 0.2, 0.2, 0.4, 0.2, 0.2, 0.2, 0.2, 0.4, 0.1, 0.2, 0.2, 0.2, 0.2, 0.1, 0.2, 0.2, 0.3, 0.3, 0.2, 0.6, 0.4, 0.3, 0.2, 0.2, 0.2, 0.2],
  193. ["versicolor", 1.4, 1.5, 1.5, 1.3, 1.5, 1.3, 1.6, 1.0, 1.3, 1.4, 1.0, 1.5, 1.0, 1.4, 1.3, 1.4, 1.5, 1.0, 1.5, 1.1, 1.8, 1.3, 1.5, 1.2, 1.3, 1.4, 1.4, 1.7, 1.5, 1.0, 1.1, 1.0, 1.2, 1.6, 1.5, 1.6, 1.5, 1.3, 1.3, 1.3, 1.2, 1.4, 1.2, 1.0, 1.3, 1.2, 1.3, 1.3, 1.1, 1.3],
  194. ["virginica", 2.5, 1.9, 2.1, 1.8, 2.2, 2.1, 1.7, 1.8, 1.8, 2.5, 2.0, 1.9, 2.1, 2.0, 2.4, 2.3, 1.8, 2.2, 2.3, 1.5, 2.3, 2.0, 2.0, 1.8, 2.1, 1.8, 1.8, 1.8, 2.1, 1.6, 1.9, 2.0, 2.2, 1.5, 1.4, 2.3, 2.4, 1.8, 1.8, 2.1, 2.4, 2.3, 1.9, 2.3, 2.5, 2.3, 1.9, 2.0, 2.3, 1.8],
  195. ]
  196. });
  197. }, 1500);
  198. setTimeout(function() {
  199. c3DonutChart.unload({
  200. ids: 'data1'
  201. });
  202. c3DonutChart.unload({
  203. ids: 'data2'
  204. });
  205. }, 2500);
  206. })(jQuery);