55abe9a3b3a0fafe547e1ba3f398fcda4e481f8c.svn-base 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <v-chart :forceFit="true" :height="height" :data="data" :padding="[20, 20, 95, 20]" :scale="scale">
  3. <v-tooltip></v-tooltip>
  4. <v-axis :dataKey="axis1Opts.dataKey" :line="axis1Opts.line" :tickLine="axis1Opts.tickLine" :grid="axis1Opts.grid"/>
  5. <v-axis :dataKey="axis2Opts.dataKey" :line="axis2Opts.line" :tickLine="axis2Opts.tickLine" :grid="axis2Opts.grid"/>
  6. <v-legend dataKey="user" marker="circle" :offset="30"/>
  7. <v-coord type="polar" radius="0.8"/>
  8. <v-line position="item*score" color="user" :size="2"/>
  9. <v-point position="item*score" color="user" :size="4" shape="circle"/>
  10. </v-chart>
  11. </template>
  12. <script>
  13. const axis1Opts = {
  14. dataKey: 'item',
  15. line: null,
  16. tickLine: null,
  17. grid: {
  18. lineStyle: {
  19. lineDash: null
  20. },
  21. hideFirstLine: false
  22. }
  23. }
  24. const axis2Opts = {
  25. dataKey: 'score',
  26. line: null,
  27. tickLine: null,
  28. grid: {
  29. type: 'polygon',
  30. lineStyle: {
  31. lineDash: null
  32. }
  33. }
  34. }
  35. const scale = [
  36. {
  37. dataKey: 'score',
  38. min: 0,
  39. max: 100
  40. }, {
  41. dataKey: 'user',
  42. alias: '类型'
  43. }
  44. ]
  45. const sourceData = [
  46. { item: '示例一', score: 40 },
  47. { item: '示例二', score: 20 },
  48. { item: '示例三', score: 67 },
  49. { item: '示例四', score: 43 },
  50. { item: '示例五', score: 90 }
  51. ]
  52. export default {
  53. name: 'Radar',
  54. props: {
  55. height: {
  56. type: Number,
  57. default: 254
  58. },
  59. dataSource: {
  60. type: Array,
  61. default: () => []
  62. }
  63. },
  64. data() {
  65. return {
  66. axis1Opts,
  67. axis2Opts,
  68. scale,
  69. data: sourceData
  70. }
  71. },
  72. watch: {
  73. dataSource(newVal) {
  74. if (newVal.length === 0) {
  75. this.data = sourceData
  76. } else {
  77. this.data = newVal
  78. }
  79. }
  80. }
  81. }
  82. </script>
  83. <style scoped>
  84. </style>