morris-demo.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. $(function() {
  2. Morris.Line({
  3. element: 'morris-one-line-chart',
  4. data: [
  5. { year: '2008', value: 5 },
  6. { year: '2009', value: 10 },
  7. { year: '2010', value: 8 },
  8. { year: '2011', value: 22 },
  9. { year: '2012', value: 8 },
  10. { year: '2014', value: 10 },
  11. { year: '2015', value: 5 }
  12. ],
  13. xkey: 'year',
  14. ykeys: ['value'],
  15. resize: true,
  16. lineWidth:4,
  17. labels: ['Value'],
  18. lineColors: ['#1ab394'],
  19. pointSize:5,
  20. });
  21. Morris.Area({
  22. element: 'morris-area-chart',
  23. data: [{
  24. period: '2010 Q1',
  25. iphone: 2666,
  26. ipad: null,
  27. itouch: 2647
  28. }, {
  29. period: '2010 Q2',
  30. iphone: 2778,
  31. ipad: 2294,
  32. itouch: 2441
  33. }, {
  34. period: '2010 Q3',
  35. iphone: 4912,
  36. ipad: 1969,
  37. itouch: 2501
  38. }, {
  39. period: '2010 Q4',
  40. iphone: 3767,
  41. ipad: 3597,
  42. itouch: 5689
  43. }, {
  44. period: '2011 Q1',
  45. iphone: 6810,
  46. ipad: 1914,
  47. itouch: 2293
  48. }, {
  49. period: '2011 Q2',
  50. iphone: 5670,
  51. ipad: 4293,
  52. itouch: 1881
  53. }, {
  54. period: '2011 Q3',
  55. iphone: 4820,
  56. ipad: 3795,
  57. itouch: 1588
  58. }, {
  59. period: '2011 Q4',
  60. iphone: 15073,
  61. ipad: 5967,
  62. itouch: 5175
  63. }, {
  64. period: '2012 Q1',
  65. iphone: 10687,
  66. ipad: 4460,
  67. itouch: 2028
  68. }, {
  69. period: '2012 Q2',
  70. iphone: 8432,
  71. ipad: 5713,
  72. itouch: 1791
  73. }],
  74. xkey: 'period',
  75. ykeys: ['iphone', 'ipad', 'itouch'],
  76. labels: ['iPhone', 'iPad', 'iPod Touch'],
  77. pointSize: 2,
  78. hideHover: 'auto',
  79. resize: true,
  80. lineColors: ['#87d6c6', '#54cdb4','#1ab394'],
  81. lineWidth:2,
  82. pointSize:1,
  83. });
  84. Morris.Donut({
  85. element: 'morris-donut-chart',
  86. data: [{
  87. label: "A系列",
  88. value: 12
  89. }, {
  90. label: "B系列",
  91. value: 30
  92. }, {
  93. label: "C系列",
  94. value: 20
  95. }],
  96. resize: true,
  97. colors: ['#87d6c6', '#54cdb4','#1ab394'],
  98. });
  99. Morris.Bar({
  100. element: 'morris-bar-chart',
  101. data: [{
  102. y: '2006',
  103. a: 60,
  104. b: 50
  105. }, {
  106. y: '2007',
  107. a: 75,
  108. b: 65
  109. }, {
  110. y: '2008',
  111. a: 50,
  112. b: 40
  113. }, {
  114. y: '2009',
  115. a: 75,
  116. b: 65
  117. }, {
  118. y: '2010',
  119. a: 50,
  120. b: 40
  121. }, {
  122. y: '2011',
  123. a: 75,
  124. b: 65
  125. }, {
  126. y: '2012',
  127. a: 100,
  128. b: 90
  129. }],
  130. xkey: 'y',
  131. ykeys: ['a', 'b'],
  132. labels: ['A系列', 'B系列'],
  133. hideHover: 'auto',
  134. resize: true,
  135. barColors: ['#1ab394', '#cacaca'],
  136. });
  137. Morris.Line({
  138. element: 'morris-line-chart',
  139. data: [{
  140. y: '2006',
  141. a: 100,
  142. b: 90
  143. }, {
  144. y: '2007',
  145. a: 75,
  146. b: 65
  147. }, {
  148. y: '2008',
  149. a: 50,
  150. b: 40
  151. }, {
  152. y: '2009',
  153. a: 75,
  154. b: 65
  155. }, {
  156. y: '2010',
  157. a: 50,
  158. b: 40
  159. }, {
  160. y: '2011',
  161. a: 75,
  162. b: 65
  163. }, {
  164. y: '2012',
  165. a: 100,
  166. b: 90
  167. }],
  168. xkey: 'y',
  169. ykeys: ['a', 'b'],
  170. labels: ['A系列', 'B系列'],
  171. hideHover: 'auto',
  172. resize: true,
  173. lineColors: ['#54cdb4','#1ab394'],
  174. });
  175. });