e424b68376a73cf9c5dcbcfc6f0bbdf1911d34c8.svn-base 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. <!-- -->
  2. <template>
  3. <div>
  4. <div class="simple_header">
  5. <div class="simple_header_icon"></div>
  6. <div class="simple_header_text">
  7. 问题趋势
  8. </div>
  9. <div class="simple_header_control">
  10. <el-radio-group v-model="radio" size="mini" class="myRadio" @change="changeLine()">
  11. <el-radio label="inc">增量</el-radio>
  12. <el-radio label="total" style="margin-left:0;">累计</el-radio>
  13. </el-radio-group>
  14. </div>
  15. </div>
  16. <div class="right_QuestionLineChart_content" >
  17. <div v-show="lineShow" style="width:100%;height:100%;" ref="QuestionLineChart"></div>
  18. </div>
  19. </div>
  20. </template>
  21. <script>
  22. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  23. //例如:import 《组件名称》 from '《组件路径》';
  24. import echarts from 'echarts'
  25. // import theme from '../../store/theme'
  26. export default {
  27. //import引入的组件需要注入到对象中才能使用
  28. props:['GlobalSttmTime','GlobalEntmTime','rightTimeLimit',"xData","yData"],
  29. components: {},
  30. data() {
  31. //这里存放数据
  32. return {
  33. radio: "inc",
  34. lineShow:true,
  35. chartType:'bar',
  36. searchTime:'',
  37. themeColor:'rgba(80, 105, 122, 1)',
  38. };
  39. },
  40. //监听属性 类似于data概念
  41. computed: {
  42. msg(){
  43. // return theme.state.testMsg;
  44. return this.$store.state.theme.testMsg;
  45. },
  46. },
  47. //监控data中的数据变化
  48. watch: {
  49. rightTimeLimit(newValue,oldValue){
  50. this.rightTimeLimit = newValue;
  51. },
  52. xData(newValue,oldValue){
  53. this.initIncChart();
  54. },
  55. yData(newValue,oldValue){
  56. this.initIncChart();
  57. },
  58. msg(n,o){
  59. if( n == 'dark'){
  60. this.themeColor = 'rgba(177, 210, 254, 1)';
  61. this.initIncChart();
  62. }else{
  63. this.themeColor = 'rgba(80, 105, 122, 1)';
  64. this.initIncChart();
  65. }
  66. }
  67. },
  68. //方法集合
  69. methods: {
  70. //切换增量、统计
  71. changeLine(){
  72. if(this.radio === 'inc'){
  73. this.$emit('trendLineChartType',this.radio);
  74. this.chartType = 'bar';
  75. this.initIncChart();
  76. }else{
  77. this.$emit('trendLineChartType',this.radio);
  78. this.chartType = 'line';
  79. this.initIncChart();
  80. }
  81. },
  82. //绘制图表
  83. initIncChart:function(){
  84. var _this = this;
  85. let chart = echarts.init(this.$refs['QuestionLineChart']);
  86. let option = {
  87. // backgroundColor:'rgba(226,250,255,1)',
  88. grid:{
  89. top:'10%',
  90. bottom:'10%',
  91. left:'5%',
  92. right:'10%',
  93. containLabel:true
  94. },
  95. tooltip: {
  96. trigger: 'axis',
  97. label: {
  98. show: true
  99. },
  100. formatter: function (params) {
  101. return params[0].axisValue + ': ' +params[0].data + '个'
  102. }
  103. },
  104. xAxis: {
  105. axisLabel:{
  106. color:_this.themeColor
  107. },
  108. axisLine: {
  109. show: true,
  110. lineStyle: {
  111. color: 'rgba(63, 158, 255, 1)'
  112. }
  113. },
  114. splitLine: {
  115. show: false
  116. },
  117. axisTick: {
  118. show: false,
  119. alignWithLabel: true
  120. },
  121. type: 'category',
  122. data: _this.xData
  123. },
  124. yAxis: {
  125. axisLabel:{
  126. color:_this.themeColor
  127. },
  128. axisLine: {
  129. show: true,
  130. lineStyle: {
  131. color: 'rgba(63, 158, 255, 1)'
  132. }
  133. },
  134. splitLine: {
  135. show: true,
  136. lineStyle: {
  137. type: 'dashed',
  138. color: 'rgba(33,148,246,0.2)'
  139. }
  140. },
  141. axisTick: {
  142. show: false
  143. },
  144. splitArea: {
  145. show: true,
  146. areaStyle: {
  147. color: 'transparent'//浅色主题
  148. // color: ["rgba(250,250,250,0.0)", "rgba(250,250,250,0.05)"]
  149. }
  150. },
  151. type: 'value',
  152. max: function(value) {
  153. return value.max;
  154. },
  155. min: function(value) {
  156. return value.min;
  157. },
  158. },
  159. series: [
  160. // 堆叠样式
  161. // {
  162. // type: 'bar',
  163. // itemStyle: {
  164. // normal: {
  165. // color: '#ddd'
  166. // }
  167. // },
  168. // silent: true,
  169. // barGap: '-100%', // Make series be overlap
  170. // data: [60, 60, 60, 60]
  171. // },
  172. {
  173. barMaxWidth: '50%',
  174. symbol: 'emptyCircle',
  175. symbolSize: 7,
  176. lineStyle: {
  177. color: 'rgba(124, 129, 255, 1)',
  178. shadowBlur: 12,
  179. shadowColor: 'rgba(33,148,246,0.9)',
  180. shadowOffsetX: 1,
  181. shadowOffsetY: 1
  182. },
  183. itemStyle: {
  184. borderWidth: 1,
  185. color: 'rgba(124, 129, 255, 1)',
  186. borderColor: 'rgba(124, 129, 255, 1)',
  187. normal: {
  188. barBorderRadius:[5,5,0,0],
  189. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  190. offset: 0,
  191. color: "rgba(122, 189, 250, 1)"
  192. },
  193. {
  194. offset: 1,
  195. color: "rgba(101, 142, 253, 1)"
  196. }
  197. ])
  198. },
  199. },
  200. label: {
  201. show: false,
  202. distance: 1,
  203. emphasis: {
  204. show: true,
  205. offset: [25, -2],
  206. color: '#FFF',
  207. height: 36,
  208. rich: {
  209. bg: {
  210. width: 78,
  211. color: '#FFF',
  212. },
  213. br: {
  214. width: '100%',
  215. height: '100%'
  216. }
  217. }
  218. }
  219. },
  220. data: _this.yData,
  221. type: _this.chartType,
  222. areaStyle: {
  223. // color: 'rgba(63, 158, 255, 0.3)',
  224. normal: {
  225. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  226. offset: 0,
  227. color: "rgba(63, 158, 255, 0.6)"
  228. },
  229. {
  230. offset: 1,
  231. color: "rgba(63, 158, 255, 0.3)"
  232. }
  233. ])
  234. }
  235. }
  236. }]
  237. };
  238. chart.setOption(option);
  239. },
  240. },
  241. //生命周期 - 创建完成(可以访问当前this实例)
  242. created() {
  243. },
  244. //生命周期 - 挂载完成(可以访问DOM元素)
  245. mounted() {
  246. this.$emit('trendLineChartType',this.radio);
  247. this.chartType = 'bar';
  248. this.initIncChart();
  249. },
  250. beforeCreate() {}, //生命周期 - 创建之前
  251. beforeMount() {}, //生命周期 - 挂载之前
  252. beforeUpdate() {}, //生命周期 - 更新之前
  253. updated() {}, //生命周期 - 更新之后
  254. beforeDestroy() {}, //生命周期 - 销毁之前
  255. destroyed() {}, //生命周期 - 销毁完成
  256. activated() {} //如果页面有keep-alive缓存功能,这个函数会触发
  257. };
  258. </script>
  259. <style lang="scss" scoped>
  260. @media screen and (min-width: 960px) {
  261. @import "@scss/homeForPad";
  262. }
  263. // @media screen and (min-width: 1024px) {
  264. // @import "@scss/home1024";
  265. // }
  266. @media screen and (min-width: 1024px) and (max-width:1920px){
  267. @import "@scss/home";
  268. }
  269. @media screen and (min-width: 1920px) {
  270. @import "@scss/home1920";
  271. }
  272. </style>