ring.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <div>
  3. <base-chart
  4. :id="this.id"
  5. chartType="ve-ring"
  6. :chartData="chartData"
  7. :chartConfig="chartConfig"
  8. :chartSettings="chartSettings"
  9. :loading="loading"
  10. :chartEvents="chartEvents"
  11. :extraToolbox="extraToolbox" />
  12. <download-excel v-show="false" ref="excel" :data="chartData.rows" :fields="exportExcelColumns" :name="`${exportName||title}.xls`" />
  13. </div>
  14. </template>
  15. <script>
  16. import commonChartProps from './common'
  17. export default {
  18. name: 'OverviewRing',
  19. props: Object.assign({
  20. id: {
  21. type: String,
  22. default: 'overview-ring',
  23. },
  24. title: {
  25. type: String,
  26. default: '',
  27. },
  28. subtitle: {
  29. type: String,
  30. default: '',
  31. },
  32. exportExcelColumns: {
  33. type: Object,
  34. },
  35. exportName: String,
  36. }, commonChartProps()),
  37. computed: {
  38. extraToolbox () {
  39. const ret = {
  40. pdf: {
  41. name: this.exportName || this.title,
  42. target: `#${this.id}`,
  43. },
  44. }
  45. if (this.exportExcelColumns) {
  46. ret.excel = {
  47. export: this.exportExcel,
  48. }
  49. }
  50. return ret
  51. },
  52. chartConfig () {
  53. const config = {
  54. height: this.chartHeigth,
  55. width: '100%',
  56. legend: {
  57. show: this.showLegend,
  58. orient: 'vertical',
  59. left: 'left',
  60. },
  61. title: {
  62. show: this.title && this.title.length > 0,
  63. text: this.title,
  64. subtext: this.subtitle,
  65. left: 'center',
  66. top: '35%',
  67. textStyle: {
  68. color: '#999999',
  69. fontSize: 16,
  70. align: 'center',
  71. },
  72. subtextStyle: {
  73. fontSize: 20,
  74. color: ['#333'],
  75. align: 'center',
  76. },
  77. },
  78. tooltip: {
  79. show: true,
  80. trigger: 'item',
  81. // position: {
  82. // _custom: {
  83. // type: 'function',
  84. // display: '<span>ƒ</span> position(point, params, dom, rect, size)',
  85. // },
  86. // },
  87. },
  88. toolbox: {
  89. show: true,
  90. feature: {},
  91. right: 20,
  92. },
  93. }
  94. return config
  95. },
  96. chartSettings () {
  97. const cs = {
  98. radius: [75, 100],
  99. offsetY: '45%',
  100. labelLine: { length: 10, length2: 10 },
  101. }
  102. if (this.chartData && this.chartData.columns && this.chartData.columns.length > 0) {
  103. cs.dataType = this.yAxisFormat
  104. cs.limitShowNum = 9
  105. }
  106. return Object.assign(cs, this.chartSetting)
  107. },
  108. },
  109. methods: {
  110. exportExcel () {
  111. this.$refs.excel.generate()
  112. },
  113. },
  114. }
  115. </script>