index.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <div :id="id" :style="{ width: width, height: height }"></div>
  3. </template>
  4. <script>
  5. import { chartOptionMixins } from "@/views/analyse/custom/mixins";
  6. export default {
  7. mixins: [chartOptionMixins],
  8. name: "CTreemap",
  9. data() {
  10. return {
  11. id: 'treemap'
  12. }
  13. },
  14. mounted() {
  15. },
  16. methods: {
  17. getOption() {
  18. const matrix = this.form.schema.y.field
  19. let data = []
  20. if (matrix) {
  21. this.selected.x.map(x => {
  22. let value = {
  23. name: x,
  24. value: this.getDataCount(x),
  25. itemStyle: {
  26. color: this.getColor(x)
  27. },
  28. children: []
  29. }
  30. this.selected.y.map(y => {
  31. value.children.push({
  32. name: y,
  33. value: this.getDataCount(x, y),
  34. children: []
  35. })
  36. })
  37. data.push(value)
  38. })
  39. } else {
  40. this.selected.x.map(x => {
  41. data.push({
  42. name: x,
  43. value: this.getDataCount(x),
  44. itemStyle: {
  45. color: this.getColor(x)
  46. },
  47. children: []
  48. })
  49. })
  50. }
  51. return {
  52. series: [{
  53. breadcrumb: {
  54. show: false
  55. },
  56. type: 'treemap',
  57. itemStyle: {
  58. borderColor: '#fff'
  59. },
  60. label: this.getDataLabel(),
  61. levels: [
  62. {
  63. itemStyle: {
  64. borderWidth: 0,
  65. gapWidth: 5
  66. }
  67. },
  68. {
  69. itemStyle: {
  70. gapWidth: 1
  71. }
  72. },
  73. {
  74. colorSaturation: [0.35, 0.5],
  75. itemStyle: {
  76. gapWidth: 1,
  77. borderColorSaturation: 0.6
  78. }
  79. }
  80. ],
  81. data: data,
  82. }]
  83. }
  84. },
  85. }
  86. }
  87. </script>