SAbarline.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <div class="barline_box">
  3. <div id="barline" style="width:100%; height:450px;"></div>
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. data() {
  9. return {
  10. now_url: this.$route.path,
  11. }
  12. },
  13. created() {
  14. this.init();
  15. },
  16. computed: {
  17. barline() {
  18. return this.$store.state.barline
  19. }
  20. },
  21. methods: {
  22. drawLine(obj) {
  23. let myChart = this.$echarts.init(document.getElementById('barline'));
  24. let _this = this;
  25. myChart.setOption({
  26. title: {
  27. text: obj.titlename,
  28. top: "0%",
  29. },
  30. tooltip: {
  31. trigger: 'axis',
  32. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  33. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  34. }
  35. },
  36. legend: {
  37. data: obj.titledata,
  38. x: 'center',
  39. top: "3%"
  40. },
  41. grid: {
  42. left: '1.5%',
  43. right: '4%',
  44. bottom: '4.5%',
  45. containLabel: true,
  46. x: 100,
  47. y2: 200,
  48. },
  49. toolbox: {
  50. show: true,
  51. orient: 'horizontal',
  52. y:"2%",
  53. feature: {
  54. mark: { show: true },
  55. dataView: { show: true, readOnly: false },
  56. magicType: { show: true, type: ['bar', 'line',] },
  57. restore: { show: false },
  58. saveAsImage: { show: true }
  59. }
  60. },
  61. calculable: true,
  62. xAxis: [
  63. {
  64. type: 'category',
  65. boundaryGap: true,
  66. data: obj.object_name,
  67. axisLabel: {
  68. interval: 0, //强制文字产生间隔
  69. rotate: 50, //文字逆时针旋转50°
  70. textStyle: { //文字样式
  71. color: "#333",
  72. fontSize: 11,
  73. fontFamily: 'Microsoft YaHei',
  74. }
  75. },
  76. }
  77. ],
  78. dataZoom: {
  79. show: true,
  80. realtime: true,
  81. backgroundColor: "rgba(0,0,0,0)",
  82. handleSize: 15,
  83. backgroundColor: '#fff',
  84. showDataShadow: false,
  85. handleIcon: 'M-292,322.2c-3.2,0-6.4-0.6-9.3-1.9c-2.9-1.2-5.4-2.9-7.6-5.1s-3.9-4.8-5.1-7.6c-1.3-3-1.9-6.1-1.9-9.3c0-3.2,0.6-6.4,1.9-9.3c1.2-2.9,2.9-5.4,5.1-7.6s4.8-3.9,7.6-5.1c3-1.3,6.1-1.9,9.3-1.9c3.2,0,6.4,0.6,9.3,1.9c2.9,1.2,5.4,2.9,7.6,5.1s3.9,4.8,5.1,7.6c1.3,3,1.9,6.1,1.9,9.3c0,3.2-0.6,6.4-1.9,9.3c-1.2,2.9-2.9,5.4-5.1,7.6s-4.8,3.9-7.6,5.1C-285.6,321.5-288.8,322.2-292,322.2z',
  86. fillerColor: new this.$echarts.graphic.LinearGradient(1, 0, 0, 0, [{
  87. //给颜色设置渐变色 前面4个参数,给第一个设置1,第四个设置0 ,就是水平渐变
  88. //给第一个设置0,第四个设置1,就是垂直渐变
  89. offset: 0,
  90. color: '#1eb5e5'
  91. }, {
  92. offset: 1,
  93. color: '#5ccbb1'
  94. }]),
  95. handleColor: '#ddd',//h滑动图标的颜色
  96. handleStyle: {
  97. borderColor: "#cacaca",
  98. borderWidth: "1",
  99. shadowBlur: 0,
  100. background: "#ddd",
  101. shadowColor: "#ddd",
  102. },
  103. backgroundColor: '#eee',//两边未选中的滑动条区域的颜色
  104. y: 420,
  105. height: 8,
  106. start: 0,
  107. end: 45,
  108. },
  109. yAxis: [
  110. {
  111. type: 'value'
  112. }
  113. ],
  114. series: [
  115. {
  116. name: obj.one_data.name,
  117. type: 'bar',
  118. barWidth: 10,
  119. smooth: true,
  120. itemStyle: { normal: { areaStyle: { type: 'default' } } },
  121. data: obj.one_data.data,
  122. itemStyle: {
  123. normal: {
  124. color: '#4EDAB5'
  125. }
  126. },
  127. markPoint: {
  128. data: [
  129. { type: 'max', name: '最大值' },
  130. { type: 'min', name: '最小值' }
  131. ]
  132. },
  133. markLine: {
  134. itemStyle: {
  135. normal: { lineStyle: { type: 'solid' }, label: { show: true, position: 'middle' } }
  136. },
  137. large: true,
  138. effect: {
  139. show: false,
  140. loop: true,
  141. period: 0,
  142. scaleSize: 2,
  143. color: null,
  144. shadowColor: null,
  145. shadowBlur: null
  146. },
  147. data: [
  148. {
  149. name: '区级平均分',
  150. type: 'average',
  151. // 单独配置每条线的样式
  152. yAxis: 86,
  153. lineStyle: {
  154. color: 'blue',
  155. },
  156. label: {
  157. formatter: '区级平均分'
  158. }
  159. },
  160. {
  161. name: '校级平均分',
  162. yAxis: 89,
  163. // 单独配置每条线的样式
  164. lineStyle: {
  165. color: 'red'
  166. },
  167. label: {
  168. formatter:'校级平均分'
  169. }
  170. },
  171. {
  172. name: '任教班级平均分',
  173. yAxis: 80,
  174. // 单独配置每条线的样式
  175. lineStyle: {
  176. color: 'green'
  177. },
  178. label: {
  179. formatter: '任教班级平均分'
  180. }
  181. },
  182. ]
  183. }
  184. },
  185. {
  186. name: obj.last_data.name,
  187. type: 'bar',
  188. smooth: true,
  189. barWidth: 10,
  190. itemStyle: { normal: { areaStyle: { type: 'default' } } },
  191. data: obj.last_data.data,
  192. itemStyle: {
  193. normal: {
  194. color: '#7AB6FE'
  195. }
  196. },
  197. }
  198. ]
  199. })
  200. myChart.on('click', function (param) {
  201. console.log(param, 123456789);
  202. console.log(param.seriesName);
  203. console.log(param.name);
  204. _this.barclick();
  205. })
  206. },
  207. init() {
  208. this.$api.FindTeachbargraph({})
  209. .then((response) => {
  210. // console.log(response.result.data, '老师测试页面');
  211. this.$store.state.barline = response.result.data;
  212. })
  213. },
  214. //点击班级 联动PR值
  215. barclick() {
  216. this.$api.FindClickPR({})
  217. .then((response) => {
  218. //console.log(response.result.data,77777)
  219. this.$store.state.accuracyPR = response.result.data;
  220. })
  221. }
  222. },
  223. watch: {
  224. // 监听指令
  225. barline(a) {
  226. if (a) {
  227. this.drawLine(a)
  228. }
  229. },
  230. }
  231. }
  232. </script>
  233. <style scoped>
  234. .barline_box {
  235. width:100%;
  236. height:450px;
  237. }
  238. #myChart {
  239. padding: 4% 2% 0% 2% !important;
  240. }
  241. </style>