dashboard.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. define(['jquery', 'bootstrap', 'backend', 'addtabs', 'table', 'echarts', 'echarts-theme','form', 'template'], function ($, undefined, Backend, Datatable, Table, Echarts, undefined,Form, Template) {
  2. var Controller = {
  3. index: function () {
  4. // 基于准备好的dom,初始化echarts实例
  5. var myChart = Echarts.init(document.getElementById('echart'), 'walden');
  6. // 指定图表的配置项和数据
  7. var option = {
  8. title: {
  9. text: '',
  10. subtext: ''
  11. },
  12. color: [
  13. "#18d1b1",
  14. "#3fb1e3",
  15. "#626c91",
  16. "#a0a7e6",
  17. "#c4ebad",
  18. "#96dee8"
  19. ],
  20. tooltip: {
  21. trigger: 'axis'
  22. },
  23. legend: {
  24. data: [__('Register user')]
  25. },
  26. toolbox: {
  27. show: false,
  28. feature: {
  29. magicType: {show: true, type: ['stack', 'tiled']},
  30. saveAsImage: {show: true}
  31. }
  32. },
  33. xAxis: {
  34. type: 'category',
  35. boundaryGap: false,
  36. data: Config.column
  37. },
  38. yAxis: {},
  39. grid: [{
  40. left: 'left',
  41. top: 'top',
  42. right: '10',
  43. bottom: 30
  44. }],
  45. series: [{
  46. name: __('Register user'),
  47. type: 'line',
  48. smooth: true,
  49. areaStyle: {
  50. normal: {}
  51. },
  52. lineStyle: {
  53. normal: {
  54. width: 1.5
  55. }
  56. },
  57. data: Config.userdata
  58. }]
  59. };
  60. // 使用刚指定的配置项和数据显示图表。
  61. myChart.setOption(option);
  62. $(window).resize(function () {
  63. myChart.resize();
  64. });
  65. $(document).on("click", ".btn-refresh", function () {
  66. setTimeout(function () {
  67. myChart.resize();
  68. }, 0);
  69. });
  70. },
  71. order: function () {
  72. // 基于准备好的dom,初始化echarts实例
  73. var myChart = Echarts.init(document.getElementById('echart'), 'walden');
  74. // 指定图表的配置项和数据
  75. var option = {
  76. title: {
  77. text: '订单统计'
  78. },
  79. tooltip: {
  80. trigger: 'axis'
  81. },
  82. legend: {
  83. data: ['笔数']
  84. },
  85. grid: {
  86. left: '3%',
  87. right: '4%',
  88. bottom: '3%',
  89. containLabel: true
  90. },
  91. toolbox: {
  92. feature: {
  93. saveAsImage: {}
  94. }
  95. },
  96. xAxis: {
  97. type: 'category',
  98. boundaryGap: false,
  99. data: Config.ec_date
  100. },
  101. yAxis: {
  102. type: 'value'
  103. },
  104. series: [
  105. {
  106. name: '笔数',
  107. type: 'line',
  108. // stack: 'Total',
  109. data: Config.ec_ordernum
  110. },
  111. ]
  112. };
  113. // 使用刚指定的配置项和数据显示图表。
  114. myChart.setOption(option);
  115. $(window).resize(function () {
  116. myChart.resize();
  117. });
  118. $(document).on("click", ".btn-refresh", function () {
  119. setTimeout(function () {
  120. myChart.resize();
  121. }, 0);
  122. });
  123. },
  124. orderservicetype: function () {
  125. // 基于准备好的dom,初始化echarts实例
  126. var myChart = Echarts.init(document.getElementById('echart'), 'walden');
  127. // 指定图表的配置项和数据
  128. var option = {
  129. title: {
  130. text: '订单统计',
  131. subtext: '',
  132. left: 'center'
  133. },
  134. tooltip: {
  135. trigger: 'item'
  136. },
  137. legend: {
  138. orient: 'vertical',
  139. left: 'left'
  140. },
  141. series: [
  142. {
  143. name: 'Access From',
  144. type: 'pie',
  145. radius: '50%',
  146. data: Config.servicetype,
  147. emphasis: {
  148. itemStyle: {
  149. shadowBlur: 10,
  150. shadowOffsetX: 0,
  151. shadowColor: 'rgba(0, 0, 0, 0.5)'
  152. }
  153. }
  154. }
  155. ]
  156. };
  157. // 使用刚指定的配置项和数据显示图表。
  158. myChart.setOption(option);
  159. $(window).resize(function () {
  160. myChart.resize();
  161. });
  162. $(document).on("click", ".btn-refresh", function () {
  163. setTimeout(function () {
  164. myChart.resize();
  165. }, 0);
  166. });
  167. },
  168. datacentertwo: function () {
  169. // 基于准备好的dom,初始化echarts实例
  170. var myChart = Echarts.init(document.getElementById('echart'), 'walden');
  171. // 指定图表的配置项和数据
  172. var option = {
  173. title: {
  174. text: '客户统计',
  175. subtext: '',
  176. left: 'center'
  177. },
  178. tooltip: {
  179. trigger: 'item'
  180. },
  181. legend: {
  182. orient: 'vertical',
  183. left: 'left'
  184. },
  185. series: [
  186. {
  187. name: 'Access From',
  188. type: 'pie',
  189. radius: '50%',
  190. data: Config.comefrom_array,
  191. emphasis: {
  192. itemStyle: {
  193. shadowBlur: 10,
  194. shadowOffsetX: 0,
  195. shadowColor: 'rgba(0, 0, 0, 0.5)'
  196. }
  197. }
  198. }
  199. ]
  200. };
  201. // 使用刚指定的配置项和数据显示图表。
  202. myChart.setOption(option);
  203. $(window).resize(function () {
  204. myChart.resize();
  205. });
  206. $(document).on("click", ".btn-refresh", function () {
  207. setTimeout(function () {
  208. myChart.resize();
  209. }, 0);
  210. });
  211. },
  212. datacenterthree: function () {
  213. // 基于准备好的dom,初始化echarts实例
  214. var myChart = Echarts.init(document.getElementById('echart'), 'walden');
  215. var app = {};
  216. const posList = [
  217. 'left',
  218. 'right',
  219. 'top',
  220. 'bottom',
  221. 'inside',
  222. 'insideTop',
  223. 'insideLeft',
  224. 'insideRight',
  225. 'insideBottom',
  226. 'insideTopLeft',
  227. 'insideTopRight',
  228. 'insideBottomLeft',
  229. 'insideBottomRight'
  230. ];
  231. app.configParameters = {
  232. rotate: {
  233. min: -90,
  234. max: 90
  235. },
  236. align: {
  237. options: {
  238. left: 'left',
  239. center: 'center',
  240. right: 'right'
  241. }
  242. },
  243. verticalAlign: {
  244. options: {
  245. top: 'top',
  246. middle: 'middle',
  247. bottom: 'bottom'
  248. }
  249. },
  250. position: {
  251. options: posList.reduce(function (map, pos) {
  252. map[pos] = pos;
  253. return map;
  254. }, {})
  255. },
  256. distance: {
  257. min: 0,
  258. max: 100
  259. }
  260. };
  261. app.config = {
  262. rotate: 90,
  263. align: 'left',
  264. verticalAlign: 'middle',
  265. position: 'inside',
  266. distance: 18,
  267. onChange: function () {
  268. const labelOption = {
  269. rotate: app.config.rotate,
  270. align: app.config.align,
  271. verticalAlign: app.config.verticalAlign,
  272. position: app.config.position,
  273. distance: app.config.distance
  274. };
  275. myChart.setOption({
  276. series: [
  277. {
  278. label: labelOption
  279. },
  280. {
  281. label: labelOption
  282. },
  283. {
  284. label: labelOption
  285. },
  286. {
  287. label: labelOption
  288. }
  289. ]
  290. });
  291. }
  292. };
  293. const labelOption = {
  294. show: true,
  295. position: app.config.position,
  296. distance: app.config.distance,
  297. align: app.config.align,
  298. verticalAlign: app.config.verticalAlign,
  299. rotate: app.config.rotate,
  300. formatter: '{c} {name|{a}}',
  301. fontSize: 16,
  302. rich: {
  303. name: {}
  304. }
  305. };
  306. // 指定图表的配置项和数据
  307. var option = {
  308. tooltip: {
  309. trigger: 'axis',
  310. axisPointer: {
  311. type: 'shadow'
  312. }
  313. },
  314. legend: {
  315. data: ['Forest', 'Steppe', 'Desert', 'Wetland']
  316. },
  317. toolbox: {
  318. show: true,
  319. orient: 'vertical',
  320. left: 'right',
  321. top: 'center',
  322. feature: {
  323. mark: { show: true },
  324. dataView: { show: true, readOnly: false },
  325. magicType: { show: true, type: ['line', 'bar', 'stack'] },
  326. restore: { show: true },
  327. saveAsImage: { show: true }
  328. }
  329. },
  330. xAxis: [
  331. {
  332. type: 'category',
  333. axisTick: { show: false },
  334. data: ['2012', '2013', '2014', '2015', '2016']
  335. }
  336. ],
  337. yAxis: [
  338. {
  339. type: 'value'
  340. }
  341. ],
  342. series: [
  343. {
  344. name: 'Forest',
  345. type: 'bar',
  346. barGap: 0,
  347. label: labelOption,
  348. emphasis: {
  349. focus: 'series'
  350. },
  351. data: [320, 332, 301, 334, 390]
  352. },
  353. {
  354. name: 'Steppe',
  355. type: 'bar',
  356. label: labelOption,
  357. emphasis: {
  358. focus: 'series'
  359. },
  360. data: [220, 182, 191, 234, 290]
  361. },
  362. {
  363. name: 'Desert',
  364. type: 'bar',
  365. label: labelOption,
  366. emphasis: {
  367. focus: 'series'
  368. },
  369. data: [150, 232, 201, 154, 190]
  370. },
  371. {
  372. name: 'Wetland',
  373. type: 'bar',
  374. label: labelOption,
  375. emphasis: {
  376. focus: 'series'
  377. },
  378. data: [98, 77, 101, 99, 40]
  379. }
  380. ]
  381. };
  382. // 使用刚指定的配置项和数据显示图表。
  383. myChart.setOption(option);
  384. $(window).resize(function () {
  385. myChart.resize();
  386. });
  387. $(document).on("click", ".btn-refresh", function () {
  388. setTimeout(function () {
  389. myChart.resize();
  390. }, 0);
  391. });
  392. },
  393. datacenterfour: function () {
  394. // 基于准备好的dom,初始化echarts实例
  395. var myChart = Echarts.init(document.getElementById('echart'), 'walden');
  396. // 指定图表的配置项和数据
  397. var option = {
  398. title: {
  399. text: '业绩统计'
  400. },
  401. tooltip: {
  402. trigger: 'axis'
  403. },
  404. legend: {
  405. data: ['笔数']
  406. },
  407. grid: {
  408. left: '3%',
  409. right: '4%',
  410. bottom: '3%',
  411. containLabel: true
  412. },
  413. toolbox: {
  414. feature: {
  415. saveAsImage: {}
  416. }
  417. },
  418. xAxis: {
  419. type: 'category',
  420. boundaryGap: false,
  421. data: Config.ec_date
  422. },
  423. yAxis: {
  424. type: 'value'
  425. },
  426. series: [
  427. {
  428. name: '笔数',
  429. type: 'line',
  430. // stack: 'Total',
  431. data: Config.ec_ordernum
  432. },
  433. ]
  434. };
  435. // 使用刚指定的配置项和数据显示图表。
  436. myChart.setOption(option);
  437. $(window).resize(function () {
  438. myChart.resize();
  439. });
  440. $(document).on("click", ".btn-refresh", function () {
  441. setTimeout(function () {
  442. myChart.resize();
  443. }, 0);
  444. });
  445. },
  446. datacenterfive: function () {
  447. // 基于准备好的dom,初始化echarts实例
  448. var myChart = Echarts.init(document.getElementById('echart'), 'walden');
  449. // 指定图表的配置项和数据
  450. var option = {
  451. title: {
  452. text: '业绩统计'
  453. },
  454. tooltip: {
  455. trigger: 'axis'
  456. },
  457. legend: {
  458. data: ['金额']
  459. },
  460. grid: {
  461. left: '3%',
  462. right: '4%',
  463. bottom: '3%',
  464. containLabel: true
  465. },
  466. toolbox: {
  467. feature: {
  468. saveAsImage: {}
  469. }
  470. },
  471. xAxis: {
  472. type: 'category',
  473. boundaryGap: false,
  474. data: Config.ec_date
  475. },
  476. yAxis: {
  477. type: 'value'
  478. },
  479. series: [
  480. {
  481. name: '笔数',
  482. type: 'line',
  483. // stack: 'Total',
  484. data: Config.ec_ordernum
  485. },
  486. ]
  487. };
  488. // 使用刚指定的配置项和数据显示图表。
  489. myChart.setOption(option);
  490. $(window).resize(function () {
  491. myChart.resize();
  492. });
  493. $(document).on("click", ".btn-refresh", function () {
  494. setTimeout(function () {
  495. myChart.resize();
  496. }, 0);
  497. });
  498. },
  499. api: {
  500. bindevent: function () {
  501. Form.api.bindevent($("form[role=form]"));
  502. }
  503. }
  504. };
  505. return Controller;
  506. });