StructureChart.vue 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <template>
  2. <div>
  3. <div :id="id" :options="options"></div>
  4. </div>
  5. </template>
  6. <script>
  7. import HighCharts from 'highcharts';
  8. export default {
  9. // 验证类型
  10. props: {
  11. id: {
  12. type: String
  13. },
  14. options: {
  15. type: Object
  16. },
  17. negative: {
  18. type: Boolean
  19. }
  20. },
  21. data() {
  22. return {
  23. title: this.negative ? "扣分构成图" : "奖分构成图",
  24. chart: null
  25. }
  26. },
  27. mounted() {
  28. this.chart = HighCharts.chart(this.id, this.options)
  29. },
  30. methods: {
  31. updateData: function (data) {
  32. if (!data) {
  33. return;
  34. }
  35. while (this.chart.series.length > 0) {
  36. this.chart.series[0].remove()
  37. }
  38. if (data.filter_text) {
  39. let filterText = data.filter_text
  40. let titleSuffix = "( " + filterText.time_range + ")"
  41. if (filterText.employee) {
  42. titleSuffix += "・" + filterText.employee
  43. }
  44. if (filterText.dept) {
  45. titleSuffix += "・" + filterText.dept
  46. }
  47. if (filterText.category) {
  48. titleSuffix += "・" + filterText.category
  49. }
  50. this.chart.setTitle({text: this.title + titleSuffix})
  51. }
  52. if (data.chart) {
  53. let chartData = data.chart
  54. if (chartData) {
  55. this.chart.addSeries({
  56. size: '80%',
  57. innerSize: '60%',
  58. name: '分值',
  59. data: chartData,
  60. dataLabels: {
  61. style: {
  62. fontSize: '13px'
  63. }
  64. }
  65. })
  66. }
  67. }
  68. }
  69. }
  70. }
  71. </script>