ColumnBarChart.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <ve-histogram
  3. :height="options.height"
  4. :colors="options.colors"
  5. :data="datas"
  6. :mark-point="barChartMarkPoint"
  7. :settings="options.settings"
  8. :after-config="options.config"
  9. :extend="defaultOptions"
  10. @ready="options.onReady"
  11. >
  12. </ve-histogram>
  13. </template>
  14. <script>
  15. import { VeHistogram } from 'v-charts'
  16. export default {
  17. name: 'chart',
  18. props: {
  19. datas: Object,
  20. options: {
  21. height: String,
  22. colors: Array || Object,
  23. settings: Object,
  24. config: Function,
  25. onReady: Function
  26. }
  27. },
  28. components: {
  29. VeHistogram
  30. },
  31. data () {
  32. return {
  33. barChartMarkPoint: {
  34. symbol: 'circle',
  35. symbolOffset: [0, 0],
  36. itemStyle: {
  37. borderColor: '#fff',
  38. color: '#FB483D'
  39. },
  40. symbolSize: 8,
  41. label: {
  42. show: true,
  43. position: 'bottom',
  44. fontSize: 12,
  45. padding: [-6, 0],
  46. offset: [0, 7],
  47. formatter: (val) => {
  48. return val.value + '天'
  49. }
  50. }
  51. },
  52. defaultOptions: {
  53. color: ['#05A6F3'],
  54. grid: {
  55. left: 12,
  56. right: 12,
  57. top: 10
  58. },
  59. yAxis: {
  60. axisLabel: {
  61. fontSize: 12,
  62. margin: 4
  63. },
  64. splitLine: {
  65. lineStyle: {
  66. type: 'dashed',
  67. width: 0.5
  68. }
  69. },
  70. nameGap: 20,
  71. nameTextStyle: {
  72. fontSize: 12,
  73. align: 'left',
  74. padding: [0, 0, 0, -20]
  75. }
  76. },
  77. xAxis: {
  78. min: 0,
  79. axisLabel: {
  80. showMinLabel: true,
  81. showMaxLabel: true,
  82. margin: 16,
  83. textStyle: {
  84. color: '#626262',
  85. fontSize: 12
  86. },
  87. formatter: (val, index) => {
  88. if (val.indexOf('天') > -1) {
  89. val = val.replace('天', '').split('-')[1]
  90. }
  91. return val
  92. }
  93. },
  94. axisTick: {
  95. interval: 0
  96. },
  97. nameGap: 20,
  98. nameLocation: 'end',
  99. nameTextStyle: {
  100. fontSize: 10,
  101. align: 'right',
  102. padding: [80, 20, 0, 0],
  103. color: '#9B9CA3'
  104. }
  105. },
  106. series: [
  107. {
  108. type: 'bar',
  109. name: '类似项目标书编制周期',
  110. barWidth: 10,
  111. barMaxWidth: 10,
  112. itemStyle: {
  113. color: '#05A6F3'
  114. }
  115. }
  116. ],
  117. graphic: [
  118. {
  119. type: 'group',
  120. bottom: 10,
  121. left: 32,
  122. children: [{
  123. type: 'circle',
  124. z: 100,
  125. top: 'middle',
  126. style: {
  127. fill: '#FB483D'
  128. },
  129. shape: {
  130. cx: 0,
  131. cy: 0,
  132. r: 4
  133. }
  134. },
  135. {
  136. type: 'text',
  137. z: 100,
  138. top: 'middle',
  139. style: {
  140. fill: '#333',
  141. text: '当前项目标书编制周期',
  142. font: '12px Microsoft YaHei',
  143. x: 8
  144. }
  145. }
  146. ]
  147. },
  148. {
  149. type: 'group',
  150. bottom: 10,
  151. right: 20,
  152. children: [{
  153. type: 'circle',
  154. z: 100,
  155. top: 'middle',
  156. style: {
  157. fill: '#3399FF'
  158. },
  159. shape: {
  160. cx: 0,
  161. cy: 0,
  162. r: 4
  163. }
  164. },
  165. {
  166. type: 'text',
  167. z: 100,
  168. top: 'middle',
  169. style: {
  170. fill: '#333',
  171. text: '类似项目标书编制周期',
  172. font: '12px Microsoft YaHei',
  173. x: 8
  174. }
  175. }
  176. ]
  177. }
  178. ],
  179. legend: {
  180. show: false
  181. },
  182. tooltip: {
  183. backgroundColor: '#fff',
  184. confine: true,
  185. textStyle: {
  186. color: '#171826',
  187. fontSize: 12
  188. },
  189. padding: [7, 12],
  190. extraCssText: 'box-shadow: 0px 4px 16px rgba(8, 31, 38, 0.08)',
  191. borderWidth: 2,
  192. borderColor: '#F5F6F7',
  193. formatter: (params) => {
  194. let tip = ''
  195. for (var i = 0; i < params.length; i++) {
  196. params[i].value === undefined ? params[i].value = 0 : params[i].value // eslint-disable-line
  197. if (params[i].seriesName === '项目数量') {
  198. tip = tip + '编制周期:' + params[i].name + '<br/>' + params[i].seriesName + ':' + params[i].value + '个' + '<br/>'
  199. }
  200. }
  201. return tip
  202. }
  203. }
  204. }
  205. }
  206. },
  207. computed: {},
  208. watch: {},
  209. mounted () {},
  210. methods: {},
  211. beforeDestroy () {}
  212. }
  213. </script>
  214. <style lang="scss" scoped>
  215. </style>