index.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. let Index = {
  2. init() {
  3. this.charts = {};
  4. this.loadData();
  5. Public.chartsResize(this.charts);
  6. Public.chartsReDraw(this.charts, null, [
  7. 'ec01_line_tiobe', 'ec06_pie_findSong'
  8. ], [
  9. 'ec03_barV_timeDistribute', 'ec05_lineBar_timeDistribute', 'ec06_pie_findSong'
  10. ])
  11. },
  12. loadData() {
  13. this.ec01_line_tiobe();//
  14. this.ec02_area_accessSource();//
  15. this.ec03_barV_timeDistribute();//
  16. this.ec04_pie_computerBroken();//
  17. this.ec05_lineBar_timeDistribute();//
  18. this.ec06_pie_findSong();//
  19. },
  20. ec01_line_tiobe() {
  21. let chart = echarts.init($("#ec01_line_tiobe")[0]); //初始化图表,注意命名的规范合理
  22. this.charts.ec01_line_tiobe = chart; //放入charts对象方便后面的刷新缩放以及其他操作
  23. chart.setOption(opt_line); // 设置这个类型(折线图)图表的共性
  24. chart.setOption({
  25. xAxis: { // 本图表option的个性
  26. nameLocation: 'start',
  27. inverse: true,
  28. data: ['2019', '2014', '2009', '2004', '1999', '1994', '1989']
  29. },
  30. yAxis: { // 本图表option的个性
  31. name: '排名',
  32. nameLocation: 'start',
  33. min: 1,
  34. inverse: true
  35. },
  36. dataZoom: { // 本图表option的个性
  37. type: 'inside',
  38. orient: 'vertical'
  39. },
  40. series: [
  41. {"name": "Java", data: [1, 2, 1, 1, 12, '-', 0]},
  42. {"name": "C", data: [2, 1, 2, 2, 1, 1, 1]},
  43. {"name": "C++", data: [3, 4, 3, 3, 2, 2, 3]},
  44. {"name": "Python", data: [4, 7, 5, 9, 27, 21, 0]},
  45. {"name": "java web", data: [5, 10, '-', '-', '-', '-', 0]},
  46. {"name": "C#", data: [6, 5, 6, 7, 23, '-', 0]},
  47. {"name": "JavaScript", data: [7, 8, 8, 8, 17, '-', 0]},
  48. {"name": "PHP", data: [8, 6, 4, 5, '-', '-', 0]},
  49. {"name": "SQL", data: [9, '-', '-', 6, '-', '-', 0]},
  50. {"name": "android", data: [10, 3, 36, 44, '-', '-', 0]},
  51. // {"name": "COBOL", data: [25, 20, 16, 11, 3, 9, 12]},
  52. // {"name": "Lisp", data: [29, 13, 19, 14, 14, 5, 2]},
  53. // {"name": "Pascal", data: [207, 14, 14, 96, 6, 3, 17]}
  54. ].map(item => {
  55. return $.extend(true, {}, seri_line,// 折线图图表series的共性
  56. { // 本图表series的个性
  57. symbol:'circle',
  58. smooth: false,
  59. showSymbol: false,
  60. }, item)
  61. })
  62. })
  63. },
  64. ec02_area_accessSource() {
  65. let chart = echarts.init($("#ec02_area_accessSource")[0]);
  66. this.charts.ec02_area_accessSource = chart;
  67. chart.setOption(opt_line);
  68. chart.setOption({
  69. xAxis: {
  70. data: ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
  71. },
  72. yAxis: {
  73. name: '学院',
  74. },
  75. series: [{
  76. name: '软件学院',
  77. data: [120, 132, 101, 134, 90, 230, 210]
  78. }, {
  79. name: '数媒学院',
  80. data: [220, 182, 191, 234, 290, 330, 310]
  81. }, {
  82. name: '外语学院',
  83. data: [550, 432, 501, 454, 390, 530, 410]
  84. }, {
  85. name: '计算机学院',
  86. data: [420, 432, 401, 434, 490, 530, 320]
  87. }, {
  88. name: '管理学院',
  89. data: [820, 932, 901, 934, 1290, 1330, 1320]
  90. }].map(item => {
  91. return $.extend(true, {}, seri_area, {
  92. symbol: 'circle',
  93. }, item)
  94. })
  95. });
  96. },
  97. ec03_barV_timeDistribute() {
  98. let chart = echarts.init($("#ec03_barV_timeDistribute")[0]);
  99. this.charts.ec03_barV_timeDistribute = chart;
  100. chart.setOption(opt_bar_v);
  101. chart.setOption({
  102. xAxis: {
  103. data: ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
  104. },
  105. yAxis: {
  106. name: '时间/小时',
  107. },
  108. series: [
  109. {"name": "吃饭", data: [3, 2, 2, 2, 2, 2, 3]},
  110. {"name": "睡觉", data: [8, 7, 7, 7, 7, 7, 7.5]},
  111. {"name": "工作", data: [0, 8, 8, 8, 8, 7.5, 8]},
  112. {"name": "学习", data: [3, 1, 1, 1.5, 1, 1, 2]},
  113. {"name": "其他", data: [10, 6, 6, 5.5, 6, 6.5, 3.5]},
  114. ].map(item => {
  115. return $.extend(true, {}, seri_bar_v, item, {stack: '总时间'})
  116. })
  117. })
  118. },
  119. ec04_pie_computerBroken() {
  120. let chart = echarts.init($("#ec04_pie_computerBroken")[0]);
  121. this.charts.ec04_pie_computerBroken = chart;
  122. chart.setOption(opt_pie);
  123. chart.setOption({
  124. roseType: 'radius',
  125. series: [
  126. {
  127. name: "电脑坏了",
  128. data: [{
  129. value: 72,
  130. name: '重启'
  131. },{
  132. value: 3,
  133. name: '找人帮忙'
  134. }, {
  135. value: 10,
  136. name: '放弃使用'
  137. }, {
  138. value: 15,
  139. name: '想法修复'
  140. } ]
  141. },
  142. ].map(item => {
  143. return $.extend(true, {}, seri_circle, item)
  144. })
  145. })
  146. },
  147. ec05_lineBar_timeDistribute() {
  148. let chart = echarts.init($("#ec05_lineBar_timeDistribute")[0]);
  149. this.charts.ec05_lineBar_timeDistribute = chart;
  150. chart.setOption(opt_line);
  151. chart.setOption({
  152. legend: {
  153. data: ["跑步", "打篮球", "游泳", "健身", '睡觉',]
  154. },
  155. tooltip: {
  156. formatter: function (param) {
  157. return param.map(item => {
  158. if (item.seriesName === '补位') {
  159. return ''
  160. } else {
  161. return `${item.seriesName}: ${item.value}<br>`
  162. }
  163. }).join("").replace(',', '')
  164. }
  165. },
  166. xAxis: {
  167. boundaryGap: true,
  168. data: ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
  169. },
  170. yAxis: {
  171. name: '时间/小时',
  172. },
  173. series: [
  174. {
  175. name: '睡觉',
  176. data: [8, 7, 7, 7, 6, 6.5, 7.5]
  177. }, {
  178. name: '补位',
  179. silent: true,
  180. itemStyle: {
  181. color: c_bg_bar,
  182. },
  183. barGap: '-100%',
  184. data: new Array(7).fill(12)
  185. }
  186. ].map(item => {
  187. return $.extend(true, {}, seri_bar_v, item)
  188. }).concat([
  189. {"name": "跑步", data: [3, 2, 2, 2, 2, 2, 3]},
  190. {"name": "打篮球", data: [3, 1, 1, 1.5, 1, 1, 2]},
  191. {"name": "游泳", data: [0, 8, 8, 8, 8, 7.5, 8]},
  192. {"name": "健身", data: [10, 6, 6, 5.5, 7, 7, 3.5]},
  193. ].map(item => {
  194. return $.extend(true, {}, seri_line, {
  195. symbol: 'emptyCircle'
  196. }, item)
  197. }))
  198. })
  199. },
  200. ec06_pie_findSong() {
  201. let chart = echarts.init($("#ec06_pie_findSong")[0]);
  202. this.charts.ec06_pie_findSong = chart;
  203. chart.setOption(opt_pie);
  204. chart.setOption({
  205. roseType: 'radius',
  206. visualMap: {
  207. show: false,
  208. min: 0,
  209. max: 100,
  210. inRange: {
  211. colorLightness: [0.3, 1.2]
  212. }
  213. },
  214. series: [
  215. {
  216. name: "资料显示",
  217. itemStyle: {
  218. normal: {
  219. color: colors[0],
  220. shadowBlur: 100 * scale,
  221. shadowColor: 'rgba(0, 0, 0, 0.5)'
  222. }
  223. },
  224. data: [{
  225. value: 40,
  226. name: 'java学习资料'
  227. }, {
  228. value: 30,
  229. name: 'jquery前端开发'
  230. }, {
  231. value: 18,
  232. name: 'Android应用教程'
  233. }, {
  234. value: 10,
  235. name: 'web后端维护'
  236. }, {
  237. value: 2,
  238. name: '数据库创建'
  239. }].sort(function (a, b) {
  240. return a.value - b.value;
  241. }),
  242. },
  243. ].map(item => {
  244. return $.extend(true, {}, seri_pie, item)
  245. })
  246. })
  247. }
  248. };
  249. Index.init();