Radar.vue 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <template>
  2. <v-chart :forceFit="true" height="400" :data="data" :padding="[20, 20, 95, 20]" :scale="scale">
  3. <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 DataSet = require('@antv/data-set')
  14. const sourceData = [
  15. {item: '引用', a: 70, b: 30, c: 40},
  16. {item: '口碑', a: 60, b: 70, c: 40},
  17. {item: '产量', a: 50, b: 60, c: 40},
  18. {item: '贡献', a: 40, b: 50, c: 40},
  19. {item: '热度', a: 60, b: 70, c: 40},
  20. {item: '引用', a: 70, b: 50, c: 40}
  21. ]
  22. const dv = new DataSet.View().source(sourceData)
  23. dv.transform({
  24. type: 'fold',
  25. fields: ['a', 'b', 'c'],
  26. key: 'user',
  27. value: 'score'
  28. })
  29. const scale = [{
  30. dataKey: 'score',
  31. min: 0,
  32. max: 80
  33. }]
  34. const data = dv.rows
  35. const axis1Opts = {
  36. dataKey: 'item',
  37. line: null,
  38. tickLine: null,
  39. grid: {
  40. lineStyle: {
  41. lineDash: null
  42. },
  43. hideFirstLine: false
  44. }
  45. }
  46. const axis2Opts = {
  47. dataKey: 'score',
  48. line: null,
  49. tickLine: null,
  50. grid: {
  51. type: 'polygon',
  52. lineStyle: {
  53. lineDash: null
  54. }
  55. }
  56. }
  57. export default {
  58. name: 'Radar',
  59. data () {
  60. return {
  61. sourceData,
  62. data,
  63. axis1Opts,
  64. axis2Opts,
  65. scale
  66. }
  67. }
  68. }
  69. </script>
  70. <style scoped>
  71. </style>