SAlinechart.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <template>
  2. <Row class="linechart_box">
  3. <Col span="24" class="select_box">
  4. <div class="type_box">
  5. <Select v-model="model1" style="width:180px;height:40px;" @on-change="ExamType">
  6. <Option v-for="item in linechart" :value="item.value" :key="item.value" >{{ item.label }}</Option>
  7. </Select>
  8. </div>
  9. <div class="artsscience" v-if="this.now_url =='/saindex'">
  10. <li class="wenke" @click="arts_btn" v-if="wenli_show">显示文科</li>
  11. <li class="like" @click="science_btn" v-if="wenli_show">显示理科</li>
  12. </div>
  13. </Col>
  14. <Col span="24">
  15. <div id="myChart_line" :style="{width: '100%', height: '300px'}"></div>
  16. </Col>
  17. </Row>
  18. </template>
  19. <script>
  20. export default {
  21. name: "linechart",
  22. data() {
  23. return {
  24. cityList: [],
  25. model1: 'liankao',
  26. now_url: this.$route.path,
  27. }
  28. },
  29. created() {
  30. this.init();
  31. this.type_init();
  32. },
  33. computed: {
  34. // 命令发布监听
  35. //mode() {
  36. // return this.$store.state.linechart.mode
  37. //},
  38. linechart_standard() {
  39. return this.$store.state.linechart
  40. },
  41. linechart() {
  42. return this.$store.state.examtype
  43. },
  44. wenli_show() {
  45. return this.$store.state.wenli_show
  46. }
  47. },
  48. methods: {
  49. drawLine(obj) {
  50. //this.$store.state.linechart.mode = false;
  51. let myChart = this.$echarts.init(document.getElementById('myChart_line'));
  52. myChart.setOption({
  53. title: {
  54. text: '各校历次总分统计图',
  55. },
  56. legend: {
  57. data: obj.obj_name,
  58. top: '10%',
  59. },
  60. tooltip: {
  61. trigger: 'axis',
  62. //backgroundColor: 'rgba(0,0,0,0.7)',//背景颜色(此时为默认色)
  63. borderRadius: 8,//边框圆角
  64. padding: 10, // [5, 10, 15, 20] 内边距
  65. //echarts点击事件
  66. // formatter: function (params,ticket,callback) {
  67. // console.log(params)
  68. // },
  69. },
  70. grid: {
  71. left: '2%',
  72. right: '3%',
  73. bottom: '3%',
  74. containLabel: true
  75. },
  76. toolbox: {
  77. show: true, //是否显示
  78. orient: 'horizontal', //水平显示(vertical为垂直显示)
  79. right: '3%', //距离右边多远
  80. feature: {
  81. magicType: {//动态类型切换
  82. type: ['bar', 'line']
  83. },
  84. saveAsImage: {
  85. show: true
  86. }
  87. },
  88. },
  89. xAxis: {
  90. type: 'category',
  91. boundaryGap: false,
  92. data: obj.obj_data,
  93. min: 'dataMin',
  94. max: 'dataMax',
  95. splitLine: {
  96. show: true
  97. }
  98. },
  99. yAxis: {
  100. type: 'value',
  101. min: 'dataMin',
  102. max: 'dataMax',
  103. splitLine: {
  104. show: true
  105. }
  106. },
  107. series: [
  108. {
  109. name: obj.obj_series[0].name,
  110. type: 'line',
  111. data: obj.obj_series[0].data,
  112. itemStyle: {
  113. normal: {
  114. color: '#FF3030',
  115. lineStyle: {
  116. color: '#FF3030',
  117. width: 2,
  118. }
  119. }
  120. },
  121. areaStyle: {
  122. color: {
  123. type: 'linear',
  124. x: 0,
  125. y: 0,
  126. x2: 0,
  127. y2: 1,
  128. colorStops: [{
  129. offset: 0, color:obj.start_color // 0% 处的颜色
  130. }, {
  131. offset: 1, color: obj.end_color // 100% 处的颜色
  132. }],
  133. }
  134. },
  135. },
  136. {
  137. name: obj.obj_series[1].name,
  138. type: 'line',
  139. data: obj.obj_series[1].data,
  140. itemStyle: {
  141. normal: {
  142. color: "#00F5FF",
  143. lineStyle: {
  144. color: '#00F5FF',
  145. width: 2,
  146. }
  147. }
  148. },
  149. areaStyle: {
  150. color: {
  151. type: 'linear',
  152. x: 0,
  153. y: 0,
  154. x2: 0,
  155. y2: 1,
  156. colorStops: [{
  157. offset: 0, color: 'rgba(245,245,245,1)' // 0% 处的颜色
  158. }, {
  159. offset: 1, color: 'rgba(245,245,245,.5)' // 100% 处的颜色
  160. }],
  161. }
  162. },
  163. },
  164. {
  165. name: obj.obj_series[2].name,
  166. type: 'line',
  167. data: obj.obj_series[2].data,
  168. itemStyle: {
  169. normal: {
  170. color: "#4169E1",
  171. lineStyle: {
  172. color: '#4169E1',
  173. width: 2,
  174. }
  175. }
  176. },
  177. areaStyle: {
  178. color: {
  179. type: 'linear',
  180. x: 0,
  181. y: 0,
  182. x2: 0,
  183. y2: 1,
  184. colorStops: [{
  185. offset: 0, color: 'rgba(245,245,245,1)' // 0% 处的颜色
  186. }, {
  187. offset: 1, color: 'rgba(245,245,245,.5)' // 100% 处的颜色
  188. }],
  189. }
  190. },
  191. },
  192. {
  193. name: obj.obj_series[3].name,
  194. type: 'line',
  195. data: obj.obj_series[3].data,
  196. itemStyle: {
  197. normal: {
  198. color: "#912CEE",
  199. lineStyle: {
  200. color: '#912CEE',
  201. width: 2,
  202. }
  203. }
  204. },
  205. areaStyle: {
  206. color: {
  207. type: 'linear',
  208. x: 0,
  209. y: 0,
  210. x2: 0,
  211. y2: 1,
  212. colorStops: [{
  213. offset: 0, color: 'rgba(245,245,245,1)' // 0% 处的颜色
  214. }, {
  215. offset: 1, color: 'rgba(245,245,245,.5)' // 100% 处的颜色
  216. }],
  217. }
  218. },
  219. },
  220. {
  221. name: obj.obj_series[4].name,
  222. type: 'line',
  223. data: obj.obj_series[4].data,
  224. itemStyle: {
  225. normal: {
  226. color: "#FF8247",
  227. lineStyle: {
  228. color: '#FF8247',
  229. width: 2,
  230. }
  231. }
  232. },
  233. areaStyle: {
  234. color: {
  235. type: 'linear',
  236. x: 0,
  237. y: 0,
  238. x2: 0,
  239. y2: 1,
  240. colorStops: [{
  241. offset: 0, color: 'rgba(245,245,245,1)' // 0% 处的颜色
  242. }, {
  243. offset: 1, color: 'rgba(245,245,245,.5)' // 100% 处的颜色
  244. }],
  245. }
  246. },
  247. },
  248. {
  249. name: obj.obj_series[5].name,
  250. type: 'line',
  251. data: obj.obj_series[5].data,
  252. itemStyle: {
  253. normal: {
  254. color: "#6AD4B9",
  255. lineStyle: {
  256. color: '#6AD4B9',
  257. width: 2,
  258. }
  259. }
  260. },
  261. areaStyle: {
  262. color: {
  263. type: 'linear',
  264. x: 0,
  265. y: 0,
  266. x2: 0,
  267. y2: 1,
  268. colorStops: [{
  269. offset: 0, color: 'rgba(245,245,245,1)' // 0% 处的颜色
  270. }, {
  271. offset: 1, color: 'rgba(245,245,245,.5)' // 100% 处的颜色
  272. }],
  273. }
  274. },
  275. }
  276. ]
  277. })
  278. myChart.on("click", function (e) {
  279. console.log(e);
  280. console.log(e.seriesName)
  281. console.log(e.name)
  282. })
  283. },
  284. init() {
  285. if (this.now_url == '/saindex') {
  286. this.$api.FindLinechart({})
  287. .then((response) => {
  288. //console.log(response.result.data,11111)
  289. this.$store.state.linechart = response.result.data;
  290. })
  291. } else if (this.now_url =='/teach') {
  292. this.$api.FindTeachHistory({})
  293. .then((response) => {
  294. //console.log(response.result.data, 8877822228888)
  295. this.$store.state.linechart = response.result.data;
  296. })
  297. }
  298. },
  299. type_init() {
  300. this.$api.FindExamtype({})
  301. .then((response) => {
  302. //console.log(response.result.data, 111)
  303. //this.cityList = response.result.data;
  304. this.$store.state.examtype = response.result.data;
  305. })
  306. },
  307. //考试类型
  308. ExamType(value) {
  309. this.$api.FindSelectExamType({})
  310. .then((response) => {
  311. //console.log(response.result.data, 8889)
  312. this.$store.state.selectgrade = response.result.data.selectgrade
  313. //获取新的学年期
  314. this.$store.state.selectterm = response.result.data.term
  315. //获取新的考试次数情况
  316. this.$store.state.selectexam = response.result.data.exam[0].data;
  317. //获取新的基础信息
  318. this.$store.state.basicsdata = response.result.data.base;
  319. //获取新的各校成绩排名
  320. this.$store.state.zhuxhuang = response.result.data.barecharts;
  321. //获取新的各项科目表现
  322. this.$store.state.leida = response.result.data.leida;
  323. //获取新的科目表现对比
  324. this.$store.state.pie = response.result.data.pie
  325. //获取新的考试类型
  326. this.$store.state.examtype = response.result.data.examtype;
  327. //获取新的各校历次总分统计图
  328. this.$store.state.linechart = response.result.data.linechart;
  329. })
  330. },
  331. //显示文科
  332. arts_btn() {
  333. this.$api.FindSelectArts({})
  334. .then((response) => {
  335. // console.log(response.result.data, 5555555);
  336. this.$store.state.selectgrade = response.result.data.selectgrade
  337. //获取新的学年期
  338. this.$store.state.selectterm = response.result.data.term
  339. //获取新的考试次数情况
  340. this.$store.state.selectexam = response.result.data.exam[0].data;
  341. //获取新的基础信息
  342. this.$store.state.basicsdata = response.result.data.base;
  343. //获取新的各校成绩排名
  344. this.$store.state.zhuxhuang = response.result.data.barecharts;
  345. //获取新的各项科目表现
  346. this.$store.state.leida = response.result.data.leida;
  347. //获取新的科目表现对比
  348. this.$store.state.pie = response.result.data.pie
  349. //获取新的考试类型
  350. this.$store.state.examtype = response.result.data.examtype;
  351. //获取新的各校历次总分统计图
  352. this.$store.state.linechart = response.result.data.linechart;
  353. })
  354. },
  355. //显示理科
  356. science_btn() {
  357. this.$api.FindSelectScience({})
  358. .then((response) => {
  359. //console.log(response.result.data,77899)
  360. this.$store.state.selectgrade = response.result.data.selectgrade
  361. //获取新的学年期
  362. this.$store.state.selectterm = response.result.data.term
  363. //获取新的考试次数情况
  364. this.$store.state.selectexam = response.result.data.exam[0].data;
  365. //获取新的基础信息
  366. this.$store.state.basicsdata = response.result.data.base;
  367. //获取新的各校成绩排名
  368. this.$store.state.zhuxhuang = response.result.data.barecharts;
  369. //获取新的各项科目表现
  370. this.$store.state.leida = response.result.data.leida;
  371. //获取新的科目表现对比
  372. this.$store.state.pie = response.result.data.pie
  373. //获取新的考试类型
  374. this.$store.state.examtype = response.result.data.examtype;
  375. //获取新的各校历次总分统计图
  376. this.$store.state.linechart = response.result.data.linechart;
  377. })
  378. }
  379. },
  380. watch: {
  381. // 监听指令
  382. linechart_standard(a) {
  383. if (a){
  384. this.drawLine(a);
  385. }
  386. },
  387. }
  388. }
  389. </script>