chart-render.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119
  1. (function(window, undefined) {
  2. var chartOption = {
  3. barPointTopic: getBarPointTopicOptions,
  4. barPointGrade: getBarPointGradeOptions,
  5. barTeachers: getBarTeachersOptions,
  6. barTeacherGrade: getBarTeacherGradeOptions,
  7. line: getLineOptions,
  8. lineReverse: getLineReverseOptions,
  9. lineSmooth: getLineSmoothOptions
  10. };
  11. var colors = [
  12. "rgba(67, 80, 136, 0.8)",
  13. "rgba(151, 94, 229, 0.8)",
  14. "rgba(61, 160, 255, 0.8)",
  15. "rgba(48, 203, 203, 0.8)",
  16. "rgba(75, 203, 116, 0.8)",
  17. "rgba(250, 212, 68, 0.8)",
  18. "rgba(217, 217, 217, 0.8)"
  19. ];
  20. var textStyle = {
  21. color: "#555",
  22. fontFamily:
  23. '"PingFang SC", "Microsoft YaHei", Tahoma,Helvetica, Arial, sans-serif'
  24. };
  25. var animationIsOpen = false;
  26. var symbolCircle =
  27. "path://M16,9.2c-3.8,0-6.8,3.1-6.8,6.8s3.1,6.8,6.8,6.8s6.8-3.1,6.8-6.8S19.8,9.2,16,9.2z M29.7,16 c0,7.6-6.1,13.7-13.7,13.7S2.3,23.6,2.3,16S8.4,2.3,16,2.3S29.7,8.4,29.7,16z";
  28. function Charts(dome, dataList, chartType, renderType) {
  29. this.dome = dome;
  30. this.dataList = dataList;
  31. this.chartType = chartType;
  32. this.renderType = renderType || "canvas";
  33. }
  34. Charts.prototype.initChart = function() {
  35. return window.echarts.init(this.dome, "", {
  36. renderer: this.renderType
  37. });
  38. };
  39. Charts.prototype.renderChart = function() {
  40. var options = chartOption[this.chartType](this.dataList);
  41. if (options) this.initChart().setOption(options, true);
  42. };
  43. // function getStrLen(str) {
  44. // var len = 0;
  45. // for (var i = 0; i < str.length; i++) {
  46. // if (str.charCodeAt(i) > 127 || str.charCodeAt(i) == 94) {
  47. // len += 2;
  48. // } else {
  49. // len++;
  50. // }
  51. // }
  52. // return len;
  53. // }
  54. function getBarPointTopicOptions(datas) {
  55. var yAxisLabels = datas.map(function(item) {
  56. return [item.name, item.number].join("#");
  57. });
  58. var avgDatas = datas.map(function(item) {
  59. return item.avgScore;
  60. });
  61. var stdDatas = datas.map(function(item) {
  62. return item.stdevScore;
  63. });
  64. var scoreRateDatas = datas.map(function(item) {
  65. return item.scoreRate;
  66. });
  67. var fullRateDatas = datas.map(function(item) {
  68. return item.fullRate;
  69. });
  70. var legendData = ["单题平均分", "单题标准差", "得分率", "满分率"];
  71. var series = [
  72. {
  73. type: "bar",
  74. data: avgDatas,
  75. barWidth: 6,
  76. barGap: "50%",
  77. name: "单题平均分",
  78. xAxisIndex: 0,
  79. yAxisIndex: 0,
  80. itemStyle: {
  81. color: "rgba(61, 160, 255, 0.8)"
  82. }
  83. },
  84. {
  85. type: "bar",
  86. data: stdDatas,
  87. barWidth: 6,
  88. barGap: "50%",
  89. name: "单题标准差",
  90. xAxisIndex: 0,
  91. yAxisIndex: 0,
  92. itemStyle: {
  93. color: "#4bcb74"
  94. }
  95. },
  96. {
  97. type: "scatter",
  98. data: scoreRateDatas,
  99. symbol: symbolCircle,
  100. symbolSize: 10,
  101. name: "得分率",
  102. xAxisIndex: 1,
  103. yAxisIndex: 1,
  104. itemStyle: {
  105. color: "rgba(67, 80, 136, 0.8)"
  106. }
  107. },
  108. {
  109. type: "scatter",
  110. data: fullRateDatas,
  111. symbol: symbolCircle,
  112. symbolSize: 10,
  113. name: "满分率",
  114. xAxisIndex: 1,
  115. yAxisIndex: 1,
  116. itemStyle: {
  117. color: "rgba(250, 212, 68, 0.8)"
  118. }
  119. }
  120. ];
  121. return {
  122. animation: animationIsOpen,
  123. textStyle: textStyle,
  124. legend: {
  125. data: legendData,
  126. itemGap: 30,
  127. itemWidth: 14,
  128. bottom: 40,
  129. textStyle: {
  130. fontSize: 19
  131. }
  132. },
  133. grid: [
  134. {
  135. left: "20%",
  136. top: 120,
  137. width: "36%",
  138. bottom: 100,
  139. show: true,
  140. borderColor: "rgba(230,230,230,1)"
  141. },
  142. {
  143. left: "56%",
  144. top: 120,
  145. width: "30%",
  146. bottom: 100,
  147. show: true,
  148. borderColor: "rgba(230,230,230,1)"
  149. }
  150. ],
  151. xAxis: [
  152. {
  153. type: "value",
  154. gridIndex: 0,
  155. position: "top",
  156. inverse: true,
  157. axisTick: {
  158. show: false
  159. },
  160. splitLine: {
  161. show: true,
  162. lineStyle: {
  163. color: "rgba(233,233,233,1)"
  164. }
  165. },
  166. axisLine: {
  167. lineStyle: {
  168. color: "rgba(233,233,233,1)"
  169. }
  170. },
  171. axisLabel: {
  172. fontSize: 18,
  173. formatter: function(value, index) {
  174. if (!index) return "0";
  175. return value.toFixed(2);
  176. }
  177. }
  178. },
  179. {
  180. type: "value",
  181. gridIndex: 1,
  182. min: 0,
  183. max: 1,
  184. interval: 0.2,
  185. position: "top",
  186. axisTick: {
  187. show: false
  188. },
  189. axisLine: {
  190. lineStyle: {
  191. color: "rgba(233,233,233,1)"
  192. }
  193. },
  194. splitLine: {
  195. show: true,
  196. lineStyle: {
  197. color: "rgba(233,233,233,1)"
  198. }
  199. },
  200. axisLabel: {
  201. fontSize: 18,
  202. formatter: function(value, index) {
  203. if (!index) return "";
  204. return parseInt(value * 100) + "%";
  205. }
  206. }
  207. }
  208. ],
  209. yAxis: [
  210. {
  211. type: "category",
  212. gridIndex: 0,
  213. data: yAxisLabels,
  214. inverse: true,
  215. axisTick: {
  216. show: false
  217. },
  218. splitArea: {
  219. show: true,
  220. areaStyle: {
  221. color: ["rgba(250,250,250,1)", "rgba(255,255,255,1)"]
  222. }
  223. },
  224. splitLine: {
  225. show: true,
  226. lineStyle: {
  227. color: "rgba(233,233,233,1)"
  228. }
  229. },
  230. axisLabel: {
  231. fontSize: 17,
  232. margin: 20,
  233. formatter: function(value) {
  234. var str = value.split("#");
  235. if (str[0].length > 10) str[0] = str[0].substr(0, 10) + "...";
  236. return [str[0], str[1]].join(" ");
  237. }
  238. }
  239. },
  240. {
  241. show: true,
  242. type: "category",
  243. inverse: true,
  244. gridIndex: 1,
  245. data: yAxisLabels,
  246. axisLabel: {
  247. show: false,
  248. fontSize: 19
  249. },
  250. axisTick: {
  251. show: false
  252. },
  253. axisLine: {
  254. lineStyle: {
  255. color: "rgba(170,170,170,1)"
  256. }
  257. },
  258. splitArea: {
  259. show: true,
  260. areaStyle: {
  261. color: ["rgba(250,250,250,1)", "rgba(255,255,255,1)"]
  262. }
  263. },
  264. splitLine: {
  265. show: true,
  266. lineStyle: {
  267. color: "rgba(233,233,233,1)"
  268. }
  269. }
  270. }
  271. ],
  272. series: series
  273. };
  274. }
  275. function getBarPointGradeOptions(datas) {
  276. var yAxisLabels = datas.map(function(item) {
  277. return item.name;
  278. });
  279. var avgDatas = datas.map(function(item) {
  280. return item.avgScore;
  281. });
  282. var maxDatas = datas.map(function(item) {
  283. return item.maxScore;
  284. });
  285. var minDatas = datas.map(function(item) {
  286. return item.minScore;
  287. });
  288. var passRateDatas = datas.map(function(item) {
  289. return Math.round(item.passRate * 100);
  290. });
  291. var excellentRateDatas = datas.map(function(item) {
  292. return Math.round(item.excellentRate * 100);
  293. });
  294. return {
  295. animation: animationIsOpen,
  296. textStyle: textStyle,
  297. legend: {
  298. data: ["平均分", "最高分", "最低分", "及格率", "优秀率"],
  299. itemGap: 30,
  300. itemWidth: 14,
  301. bottom: 40,
  302. textStyle: {
  303. fontSize: 19
  304. }
  305. },
  306. grid: [
  307. {
  308. left: "20%",
  309. top: 120,
  310. width: "36%",
  311. bottom: 100,
  312. show: true,
  313. borderColor: "rgba(230,230,230,1)"
  314. },
  315. {
  316. left: "56%",
  317. top: 120,
  318. width: "30%",
  319. bottom: 100,
  320. show: true,
  321. borderColor: "rgba(230,230,230,1)"
  322. }
  323. ],
  324. xAxis: [
  325. {
  326. type: "value",
  327. gridIndex: 0,
  328. position: "top",
  329. inverse: true,
  330. axisTick: {
  331. show: false
  332. },
  333. splitLine: {
  334. show: true,
  335. lineStyle: {
  336. color: "rgba(233,233,233,1)"
  337. }
  338. },
  339. axisLine: {
  340. lineStyle: {
  341. color: "rgba(233,233,233,1)"
  342. }
  343. },
  344. axisLabel: {
  345. fontSize: 18,
  346. color: "#555",
  347. formatter: function(value, index) {
  348. if (!index) return "0";
  349. return value;
  350. }
  351. }
  352. },
  353. {
  354. type: "value",
  355. gridIndex: 1,
  356. min: 0,
  357. max: 100,
  358. interval: 20,
  359. position: "top",
  360. axisTick: {
  361. show: false
  362. },
  363. axisLine: {
  364. lineStyle: {
  365. color: "rgba(233,233,233,1)"
  366. }
  367. },
  368. splitLine: {
  369. show: true,
  370. lineStyle: {
  371. color: "rgba(233,233,233,1)"
  372. }
  373. },
  374. axisLabel: {
  375. fontSize: 18,
  376. color: "#555",
  377. formatter: function(value, index) {
  378. if (!index) return "";
  379. return (value / 100).toFixed(1);
  380. }
  381. }
  382. }
  383. ],
  384. yAxis: [
  385. {
  386. type: "category",
  387. gridIndex: 0,
  388. data: yAxisLabels,
  389. inverse: true,
  390. axisTick: {
  391. show: false
  392. },
  393. splitArea: {
  394. show: true,
  395. areaStyle: {
  396. color: ["rgba(250,250,250,1)", "rgba(255,255,255,1)"]
  397. }
  398. },
  399. splitLine: {
  400. show: true,
  401. lineStyle: {
  402. color: "rgba(233,233,233,1)"
  403. }
  404. },
  405. axisLabel: {
  406. fontSize: 19,
  407. margin: 30,
  408. formatter: function(value) {
  409. if (value.length > 8) {
  410. return [value.substring(0, 8), value.substring(8)].join("\n");
  411. }
  412. return value;
  413. }
  414. }
  415. },
  416. {
  417. show: true,
  418. type: "category",
  419. inverse: true,
  420. gridIndex: 1,
  421. data: yAxisLabels,
  422. axisLabel: {
  423. show: false,
  424. fontSize: 19,
  425. formatter: function(value) {
  426. if (value.length > 8) {
  427. return [value.substring(0, 8), value.substring(8)].join("\n");
  428. }
  429. return value;
  430. }
  431. },
  432. axisTick: {
  433. show: false
  434. },
  435. axisLine: {
  436. lineStyle: {
  437. color: "rgba(170,170,170,1)"
  438. }
  439. },
  440. splitArea: {
  441. show: true,
  442. areaStyle: {
  443. color: ["rgba(250,250,250,1)", "rgba(255,255,255,1)"]
  444. }
  445. },
  446. splitLine: {
  447. show: true,
  448. lineStyle: {
  449. color: "rgba(233,233,233,1)"
  450. }
  451. }
  452. }
  453. ],
  454. series: [
  455. {
  456. type: "bar",
  457. data: avgDatas,
  458. barWidth: 6,
  459. barGap: "50%",
  460. name: "平均分",
  461. xAxisIndex: 0,
  462. yAxisIndex: 0,
  463. itemStyle: {
  464. color: "rgba(61, 160, 255, 0.8)"
  465. }
  466. },
  467. {
  468. type: "bar",
  469. data: maxDatas,
  470. barWidth: 6,
  471. barGap: "50%",
  472. name: "最高分",
  473. xAxisIndex: 0,
  474. yAxisIndex: 0,
  475. itemStyle: {
  476. color: "rgba(151, 94, 229, 0.8)"
  477. }
  478. },
  479. {
  480. type: "bar",
  481. data: minDatas,
  482. barWidth: 6,
  483. barGap: "50%",
  484. name: "最低分",
  485. xAxisIndex: 0,
  486. yAxisIndex: 0,
  487. itemStyle: {
  488. color: "rgba(217, 217, 217, 0.8)"
  489. }
  490. },
  491. {
  492. type: "scatter",
  493. data: passRateDatas,
  494. symbol: symbolCircle,
  495. symbolSize: 10,
  496. name: "及格率",
  497. xAxisIndex: 1,
  498. yAxisIndex: 1,
  499. itemStyle: {
  500. color: "rgba(67, 80, 136, 0.8)"
  501. }
  502. },
  503. {
  504. type: "scatter",
  505. data: excellentRateDatas,
  506. symbol: symbolCircle,
  507. symbolSize: 10,
  508. name: "优秀率",
  509. xAxisIndex: 1,
  510. yAxisIndex: 1,
  511. itemStyle: {
  512. color: "rgba(250, 212, 68, 0.8)"
  513. }
  514. }
  515. ]
  516. };
  517. }
  518. function getBarTeachersOptions(datas) {
  519. var xAxisData = [
  520. "实考人数",
  521. "最高分",
  522. "最低分",
  523. "及格人数",
  524. "及格率",
  525. "优秀人数",
  526. "优秀率",
  527. "平均分",
  528. "相对平均分"
  529. ];
  530. var legendData = datas.map(function(item) {
  531. return item.name;
  532. });
  533. var barWidth = 22 - datas.length * 2;
  534. var series = datas.map(function(item, index) {
  535. return {
  536. type: "bar",
  537. data: [
  538. item.totalCount,
  539. item.maxScore,
  540. item.minScore,
  541. item.passCount,
  542. item.passRate100,
  543. item.excellentCount,
  544. item.excellentRate100,
  545. item.avgScore,
  546. item.relativeAvgScore
  547. ],
  548. barWidth: barWidth,
  549. name: item.name
  550. };
  551. });
  552. return {
  553. animation: animationIsOpen,
  554. textStyle: textStyle,
  555. color: colors,
  556. legend: {
  557. data: legendData,
  558. left: "center",
  559. bottom: 10,
  560. itemGap: 20,
  561. itemWidth: 14,
  562. textStyle: {
  563. fontSize: 19
  564. }
  565. },
  566. grid: {
  567. show: true,
  568. left: 80,
  569. right: 50,
  570. top: 100,
  571. bottom: 100,
  572. borderColor: "rgba(230,230,230,1)"
  573. },
  574. xAxis: {
  575. type: "category",
  576. data: xAxisData,
  577. axisTick: {
  578. show: false
  579. },
  580. splitArea: {
  581. show: true,
  582. areaStyle: {
  583. color: ["rgba(255,255,255,1)", "rgba(250,250,250,1)"]
  584. }
  585. },
  586. splitLine: {
  587. show: true,
  588. lineStyle: {
  589. color: "rgba(233,233,233,1)"
  590. }
  591. },
  592. axisLabel: {
  593. fontSize: 18,
  594. margin: 12,
  595. interval: 0
  596. }
  597. },
  598. yAxis: {
  599. type: "value",
  600. z: 1,
  601. axisTick: {
  602. show: false
  603. },
  604. axisLine: {
  605. lineStyle: {
  606. color: "rgba(233,233,233,1)"
  607. }
  608. },
  609. splitLine: {
  610. show: true,
  611. lineStyle: {
  612. color: "rgba(233,233,233,1)"
  613. }
  614. },
  615. axisLabel: {
  616. fontSize: 16,
  617. color: "#555"
  618. }
  619. },
  620. series: series
  621. };
  622. }
  623. function getBarTeacherGradeOptions(datas) {
  624. var title = datas.name + "_任课班级成绩分析";
  625. var symbolCircle =
  626. "path://M16,9.2c-3.8,0-6.8,3.1-6.8,6.8s3.1,6.8,6.8,6.8s6.8-3.1,6.8-6.8S19.8,9.2,16,9.2z M29.7,16 c0,7.6-6.1,13.7-13.7,13.7S2.3,23.6,2.3,16S8.4,2.3,16,2.3S29.7,8.4,29.7,16z";
  627. var classes = datas.classes;
  628. var xAxisData = classes.map(function(item) {
  629. return item.name;
  630. });
  631. var avgDatas = classes.map(function(item) {
  632. return item.avgScore;
  633. });
  634. var relateAvgDatas = classes.map(function(item) {
  635. return item.relativeAvgScore;
  636. });
  637. var maxDatas = classes.map(function(item) {
  638. return item.maxScore;
  639. });
  640. var minDatas = classes.map(function(item) {
  641. return item.minScore;
  642. });
  643. var passRateDatas = classes.map(function(item) {
  644. return item.passRate;
  645. });
  646. var excellentRateDatas = classes.map(function(item) {
  647. return item.excellentRate;
  648. });
  649. return {
  650. animation: animationIsOpen,
  651. textStyle: textStyle,
  652. color: [
  653. "rgba(61, 160, 255, 0.8)",
  654. "#4bcb74",
  655. "rgba(151, 94, 229, 0.8)",
  656. "#999999",
  657. "rgba(67, 80, 136, 0.8)",
  658. "rgba(250, 212, 68, 0.8)"
  659. ],
  660. title: {
  661. text: "▲ " + title,
  662. left: "center",
  663. bottom: 0,
  664. textStyle: {
  665. color: "rgba(67, 80, 136, 0.8)"
  666. }
  667. },
  668. grid: {
  669. top: 50,
  670. bottom: 90,
  671. show: true,
  672. borderColor: "rgba(230,230,230,1)"
  673. },
  674. xAxis: {
  675. type: "category",
  676. data: xAxisData,
  677. axisTick: {
  678. show: false
  679. },
  680. splitArea: {
  681. show: true,
  682. areaStyle: {
  683. color: ["rgba(255,255,255,1)", "rgba(250,250,250,1)"]
  684. }
  685. },
  686. splitLine: {
  687. show: true,
  688. lineStyle: {
  689. color: "rgba(233,233,233,1)"
  690. }
  691. },
  692. axisLabel: {
  693. fontSize: 16,
  694. margin: 12,
  695. interval: 0,
  696. formatter: function(value) {
  697. if (value.length > 6) {
  698. return [value.substring(0, 6), value.substring(6)].join("\n");
  699. }
  700. return value;
  701. }
  702. },
  703. axisLine: {
  704. lineStyle: {
  705. color: "rgba(233,233,233,1)"
  706. }
  707. }
  708. },
  709. yAxis: [
  710. {
  711. type: "value",
  712. z: 1,
  713. position: "left",
  714. axisTick: {
  715. show: false
  716. },
  717. axisLine: {
  718. lineStyle: {
  719. color: "rgba(233,233,233,1)"
  720. }
  721. },
  722. splitLine: {
  723. show: true,
  724. lineStyle: {
  725. color: "rgba(233,233,233,1)"
  726. }
  727. },
  728. axisLabel: {
  729. fontSize: 16,
  730. color: "#555"
  731. }
  732. },
  733. {
  734. type: "value",
  735. min: 0,
  736. max: 1,
  737. position: "right",
  738. axisTick: {
  739. show: false
  740. },
  741. axisLine: {
  742. lineStyle: {
  743. color: "rgba(233,233,233,1)"
  744. }
  745. },
  746. axisLabel: {
  747. fontSize: 16,
  748. color: "#555",
  749. formatter: function(value) {
  750. if (!value) return "0";
  751. return value.toFixed(1);
  752. }
  753. }
  754. }
  755. ],
  756. series: [
  757. {
  758. type: "bar",
  759. data: avgDatas,
  760. name: "平均分",
  761. barWidth: 12
  762. },
  763. {
  764. type: "bar",
  765. data: relateAvgDatas,
  766. name: "相对平均分",
  767. barWidth: 12
  768. },
  769. {
  770. type: "bar",
  771. data: maxDatas,
  772. name: "最高分",
  773. barWidth: 12
  774. },
  775. {
  776. type: "bar",
  777. data: minDatas,
  778. name: "最低分",
  779. barWidth: 12
  780. },
  781. {
  782. type: "scatter",
  783. data: passRateDatas,
  784. yAxisIndex: 1,
  785. symbol: symbolCircle,
  786. symbolSize: 10,
  787. name: "及格率"
  788. },
  789. {
  790. type: "scatter",
  791. data: excellentRateDatas,
  792. yAxisIndex: 1,
  793. symbol: symbolCircle,
  794. symbolSize: 10,
  795. name: "优秀率"
  796. }
  797. ]
  798. };
  799. }
  800. function getLineOptions(datas) {
  801. var xAxisData = datas.map(function(item) {
  802. return item.name;
  803. });
  804. var levelDatas = datas.map(function(item) {
  805. return item.difficulty;
  806. });
  807. var linearColor = new echarts.graphic.LinearGradient(0, 1, 0, 0, [
  808. {
  809. offset: 1,
  810. color: "rgba(61,160,255,1)"
  811. },
  812. {
  813. offset: 0,
  814. color: "rgba(61,160,255,0)"
  815. }
  816. ]);
  817. return {
  818. animation: animationIsOpen,
  819. textStyle: textStyle,
  820. grid: {
  821. top: 120,
  822. bottom: 100,
  823. show: true,
  824. borderColor: "rgba(230,230,230,1)"
  825. },
  826. xAxis: {
  827. type: "category",
  828. data: xAxisData,
  829. boundaryGap: false,
  830. splitLine: {
  831. show: true,
  832. lineStyle: {
  833. color: "rgba(233,233,233,1)"
  834. }
  835. },
  836. axisLabel: {
  837. fontSize: 19,
  838. margin: 20,
  839. interval: 0,
  840. formatter: function name(value) {
  841. var str = sectionArr(value, 9);
  842. return str.join("\n");
  843. }
  844. },
  845. axisLine: {
  846. lineStyle: {
  847. color: "rgba(233,233,233,1)"
  848. }
  849. }
  850. },
  851. yAxis: {
  852. type: "value",
  853. min: 0,
  854. max: 1,
  855. interval: 0.1,
  856. axisTick: {
  857. show: false
  858. },
  859. axisLine: {
  860. lineStyle: {
  861. color: "rgba(233,233,233,1)"
  862. }
  863. },
  864. splitLine: {
  865. show: true,
  866. lineStyle: {
  867. color: "rgba(233,233,233,1)"
  868. }
  869. },
  870. axisLabel: {
  871. fontSize: 19,
  872. margin: 30,
  873. color: "#555",
  874. formatter: function(value, index) {
  875. return value.toFixed(1);
  876. }
  877. }
  878. },
  879. series: [
  880. {
  881. type: "line",
  882. data: levelDatas,
  883. showSymbol: levelDatas.length <= 1,
  884. symbol: "circle",
  885. symbolSize: 8,
  886. itemStyle: {
  887. color: "rgba(61, 160, 255, 0.8)"
  888. },
  889. lineStyle: {
  890. color: "rgba(61, 160, 255, 0.8)"
  891. },
  892. areaStyle: {
  893. color: linearColor
  894. }
  895. }
  896. ]
  897. };
  898. }
  899. function getLineReverseOptions(datas) {
  900. var yAxisDatas = datas.map(function(item) {
  901. return [item.name, item.number].join("#");
  902. });
  903. var levelDatas = datas.map(function(item) {
  904. return item.difficulty;
  905. });
  906. var linearColor = new echarts.graphic.LinearGradient(0, 0, 1, 0, [
  907. {
  908. offset: 1,
  909. color: "rgba(61,160,255,1)"
  910. },
  911. {
  912. offset: 0,
  913. color: "rgba(61,160,255,0)"
  914. }
  915. ]);
  916. return {
  917. animation: animationIsOpen,
  918. textStyle: textStyle,
  919. grid: {
  920. top: 150,
  921. left: 200,
  922. bottom: 50,
  923. show: true,
  924. borderColor: "rgba(230,230,230,1)"
  925. },
  926. yAxis: {
  927. type: "category",
  928. boundaryGap: false,
  929. data: yAxisDatas,
  930. inverse: true,
  931. splitLine: {
  932. show: true,
  933. lineStyle: {
  934. color: "rgba(233,233,233,1)"
  935. }
  936. },
  937. axisLabel: {
  938. fontSize: 17,
  939. margin: 20,
  940. interval: 0,
  941. formatter: function(value) {
  942. var str = value.split("#");
  943. if (str[1]) {
  944. if (str[0].length > 10) str[0] = str[0].substr(0, 10) + "...";
  945. return [str[0], str[1]].join(" ");
  946. } else {
  947. if (str[0].length > 13) str[0] = str[0].substr(0, 13) + "...";
  948. return str[0];
  949. }
  950. }
  951. },
  952. axisLine: {
  953. lineStyle: {
  954. color: "rgba(233,233,233,1)"
  955. }
  956. }
  957. },
  958. xAxis: {
  959. type: "value",
  960. min: 0,
  961. max: 1,
  962. interval: 0.1,
  963. position: "top",
  964. axisTick: {
  965. show: false
  966. },
  967. axisLine: {
  968. lineStyle: {
  969. color: "rgba(233,233,233,1)"
  970. }
  971. },
  972. splitLine: {
  973. show: true,
  974. lineStyle: {
  975. color: "rgba(233,233,233,1)"
  976. }
  977. },
  978. axisLabel: {
  979. fontSize: 16,
  980. margin: 20,
  981. color: "#555",
  982. formatter: function(value, index) {
  983. return value.toFixed(1);
  984. }
  985. }
  986. },
  987. series: [
  988. {
  989. type: "line",
  990. data: levelDatas,
  991. showSymbol: levelDatas.length <= 1,
  992. symbol: "circle",
  993. symbolSize: 8,
  994. itemStyle: {
  995. color: "rgba(61, 160, 255, 0.8)"
  996. },
  997. lineStyle: {
  998. color: "rgba(61, 160, 255, 0.8)"
  999. },
  1000. areaStyle: {
  1001. color: linearColor
  1002. }
  1003. }
  1004. ]
  1005. };
  1006. }
  1007. function getLineSmoothOptions(datainfo) {
  1008. var lineColors = colors.slice(0, -1);
  1009. var datas = datainfo.dataList;
  1010. var lineColor = lineColors[datainfo.index % colors.length];
  1011. var xAxisData = datas.map(function(item) {
  1012. return item.score;
  1013. });
  1014. var levelDatas = datas.map(function(item) {
  1015. return item.rangeRate;
  1016. });
  1017. return {
  1018. animation: animationIsOpen,
  1019. textStyle: textStyle,
  1020. grid: {
  1021. top: 110,
  1022. bottom: 80,
  1023. show: true,
  1024. borderColor: "rgba(230,230,230,1)"
  1025. },
  1026. xAxis: {
  1027. type: "category",
  1028. data: xAxisData,
  1029. boundaryGap: false,
  1030. inverse: true,
  1031. splitLine: {
  1032. show: false
  1033. },
  1034. axisLabel: {
  1035. fontSize: 19,
  1036. margin: 20,
  1037. interval: xAxisData.length <= 16 ? 0 : "auto",
  1038. formatter: function(value) {
  1039. return value + "-";
  1040. }
  1041. },
  1042. axisLine: {
  1043. lineStyle: {
  1044. color: "rgba(233,233,233,1)"
  1045. }
  1046. }
  1047. },
  1048. yAxis: {
  1049. type: "value",
  1050. axisTick: {
  1051. show: false
  1052. },
  1053. axisLine: {
  1054. lineStyle: {
  1055. color: "rgba(233,233,233,1)"
  1056. }
  1057. },
  1058. splitLine: {
  1059. show: true,
  1060. lineStyle: {
  1061. color: "rgba(233,233,233,1)"
  1062. }
  1063. },
  1064. axisLabel: {
  1065. fontSize: 19,
  1066. margin: 20,
  1067. formatter: function(value, index) {
  1068. return value.toFixed(2);
  1069. }
  1070. }
  1071. },
  1072. series: [
  1073. {
  1074. type: "line",
  1075. data: levelDatas,
  1076. symbol: "none",
  1077. smooth: true,
  1078. smoothMonotone: "none",
  1079. lineStyle: {
  1080. color: lineColor,
  1081. width: 3
  1082. }
  1083. }
  1084. ]
  1085. };
  1086. }
  1087. function sectionArr(arrayList, sectionLength) {
  1088. var splitArr = [];
  1089. for (var i = 0, len = arrayList.length; i < len; i += sectionLength) {
  1090. splitArr.push(arrayList.slice(i, i + sectionLength));
  1091. }
  1092. return splitArr;
  1093. }
  1094. window.Charts = Charts;
  1095. })(window);