祁阳图书馆智慧大屏
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

222 lines
6.5 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. <template>
  2. <div style="height: calc(100% - 200px); display: flex; align-items: center; justify-content: flex-start;">
  3. <div id="modelType" style="width:400px; height: 230px" />
  4. </div>
  5. </template>
  6. <script>
  7. export default {
  8. props: {
  9. yearAllNum: {
  10. type: Object,
  11. require: true,
  12. default: function() {
  13. return {}
  14. }
  15. }
  16. },
  17. data() {
  18. return {
  19. }
  20. },
  21. watch: {
  22. 'yearAllNum': {
  23. handler(val) {
  24. setTimeout(() => {
  25. this.initYearCircle()
  26. }, 100)
  27. },
  28. immediate: true,
  29. deep: true
  30. }
  31. },
  32. created() {
  33. },
  34. beforeDestroy() {
  35. },
  36. mounted() {
  37. this.initYearCircle()
  38. },
  39. methods: {
  40. initYearCircle() {
  41. const optionData = [
  42. { value: this.yearAllNum.headerLib || 0, name: '总馆' },
  43. { value: this.yearAllNum.branchLib || 0, name: '分馆' }
  44. ]
  45. const myChart = this.$echarts.init(document.getElementById('modelType'))
  46. function arrCount(arr) {
  47. let count = 0
  48. arr.forEach(item => {
  49. count = count + item.value
  50. })
  51. return count
  52. }
  53. var centerImg = require('@/assets/images/circle-bg.png')
  54. const option = {
  55. tooltip: {
  56. show: false,
  57. trigger: 'item',
  58. position: 'bottom',
  59. textStyle: {
  60. color: '#EEF6FF',
  61. fontSize: '18'
  62. }
  63. // backgroundColor: 'rgba(74, 144, 226, 0.84)',
  64. // formatter: (params) => {
  65. // return `<div>${params.seriesName} <br> ${params.data.name}:${this.$parent.formatter(params.data.value)} (${params.percent}%)</div>`
  66. // }
  67. },
  68. legend: {
  69. orient: 'vertical',
  70. right: 70,
  71. top: 55,
  72. // textStyle: {
  73. // color: '#EEF6FF',
  74. // padding: [20, 0, 18, 4],
  75. // fontSize: '14'
  76. // },
  77. itemWidth: 10,
  78. itemHeight: 10,
  79. icon: 'circle',
  80. selectedMode: false,
  81. data: ['总馆', '分馆'],
  82. formatter: (name) => {
  83. // `${name} ${((flag.value / count).toFixed(2)) * 100 + '%'}`
  84. const count = arrCount(optionData)
  85. if (optionData) {
  86. const flag = optionData?.find(item => name === item.name)
  87. if (flag) return [`{name|${name}}`, `{num|${((flag.value / count).toFixed(2)) * 100 + '%'}}`]
  88. } else return name
  89. },
  90. textStyle: {
  91. rich: {
  92. name: {
  93. fontSize: 18,
  94. color: '#EEF6FF',
  95. fontFamily: 'DingTalk_JinBuTi_Regular',
  96. padding: [20, 0, 20, 4]
  97. },
  98. num: {
  99. fontSize: 20,
  100. fontWeight: 600,
  101. padding: [20, 0, 20, 15],
  102. color: '#4C90FF',
  103. fontFamily: 'DingTalk_JinBuTi_Regular'
  104. }
  105. }
  106. }
  107. // formatter: function(name) {
  108. // let tarValue
  109. // const count = arrCount(optionData)
  110. // for (let i = 0; i < optionData.length; i++) {
  111. // if (data[i].name === name) {
  112. // tarValue = data[i].value
  113. // }
  114. // }
  115. // return [`{name|${name}}`, `{num|${((tarValue / count).toFixed(2)) * 100 + '%'}}`].join('\n')
  116. // }
  117. },
  118. // 中心图片配置(关键代码)
  119. graphic: [
  120. {
  121. type: 'image',
  122. id: 'logo',
  123. left: '8.5%', // 调整图片位置
  124. top: '22%', // 调整图片位置
  125. z: -10,
  126. bounding: 'raw',
  127. rotation: 0, // 旋转
  128. origin: [64.5, 32.5], // 中心点
  129. scale: [1.0, 1.0], // 缩放
  130. // 设置图片样式
  131. style: {
  132. image: centerImg,
  133. width: 132,
  134. height: 131,
  135. opacity: 1
  136. }
  137. }
  138. ],
  139. series: [
  140. {
  141. name: '本年累计借阅',
  142. type: 'pie',
  143. left: '-50%',
  144. radius: ['60%', '70%'],
  145. avoidLabelOverlap: false,
  146. label: {
  147. show: false,
  148. position: 'center'
  149. },
  150. labelLine: {
  151. show: true
  152. },
  153. itemStyle: {
  154. borderWidth: 2,
  155. borderColor: 'rgba(16,16,21,0.4)'
  156. },
  157. emphasis: {
  158. label: {
  159. show: true,
  160. // 自定义文字显示,函数默认params接受当前指向所有属性
  161. formatter: function(params) {
  162. const { value, name } = params
  163. return [
  164. `{c| ${value}}`,
  165. `{b| ${name}}`
  166. ].join('\n') // 换行
  167. },
  168. rich: {
  169. c: {
  170. fontSize: 24,
  171. fontWeight: 600,
  172. color: '#317FFF',
  173. fontFamily: 'DingTalk_JinBuTi_Regular',
  174. // color: {
  175. // type: 'linear',
  176. // x: 0,
  177. // y: 0,
  178. // x2: 0,
  179. // y2: 1,
  180. // colorStops: [
  181. // {
  182. // offset: 0,
  183. // color: 'red' // 0% 处的颜色
  184. // },
  185. // {
  186. // offset: 1,
  187. // color: 'yellow' // 100% 处的颜色
  188. // }
  189. // ],
  190. // globalCoord: false // 缺省为 false
  191. // },
  192. lineHeight: 34
  193. },
  194. b: {
  195. fontSize: 18,
  196. color: '#fff',
  197. fontFamily: 'DingTalk_JinBuTi_Regular'
  198. }
  199. }
  200. }
  201. },
  202. color: ['#317FFF', '#31DFFF'],
  203. data: optionData
  204. }
  205. ]
  206. }
  207. myChart.setOption(option)
  208. this.$LoopShowTooltip(myChart, option, { loopSeries: true, interval: 4000 })
  209. }
  210. }
  211. }
  212. </script>
  213. <style lang="scss">
  214. @import "~@/assets/styles/index.scss";
  215. @import "~@/assets/styles/font-some.css";
  216. </style>