|
1 | 1 | <template> |
2 | | - <div> |
3 | | - <BoxContent title="Category" border> |
4 | | - <GhostLoading :isLoading="loadingTableStatus" setHeight="300"> |
5 | | - <PieChart |
6 | | - chartId="category" |
7 | | - :pieChartData="returnCategoryChartData" |
8 | | - setLegend="left" |
| 2 | + <section class="columns"> |
| 3 | + <BoxContent class="column" title="Category" border> |
| 4 | + <GhostLoading :isLoading="loadingTableStatus" setHeight="350"> |
| 5 | + <ChartBuilder |
| 6 | + chartType="pie" |
| 7 | + chartID="category" |
| 8 | + :chartOptions="options('category')" |
| 9 | + :chartSeries="getSeries('category')" |
| 10 | + chartHeight="350" |
9 | 11 | /> |
10 | 12 | </GhostLoading> |
11 | 13 | </BoxContent> |
12 | 14 |
|
13 | | - <BoxContent title="Object Type" border> |
14 | | - <GhostLoading :isLoading="loadingTableStatus" setHeight="300"> |
15 | | - <PieChart |
16 | | - chartId="objectType" |
17 | | - :pieChartData="returnObjectTypeChartData" |
18 | | - setLegend="left" |
| 15 | + <BoxContent class="column" title="Object Type" border> |
| 16 | + <GhostLoading :isLoading="loadingTableStatus" setHeight="350"> |
| 17 | + <ChartBuilder |
| 18 | + chartType="pie" |
| 19 | + chartID="objectType" |
| 20 | + :chartOptions="options('objectType')" |
| 21 | + :chartSeries="getSeries('objectType')" |
| 22 | + chartHeight="350" |
19 | 23 | /> |
20 | 24 | </GhostLoading> |
21 | 25 | </BoxContent> |
22 | 26 |
|
23 | | - <BoxContent title="Suggestion" border> |
24 | | - <GhostLoading :isLoading="loadingTableStatus" setHeight="300"> |
25 | | - <PieChart |
26 | | - chartId="suggestion" |
27 | | - :pieChartData="returnSuggestionChartData" |
28 | | - setLegend="left" |
| 27 | + <BoxContent class="column" title="Suggestion" border> |
| 28 | + <GhostLoading :isLoading="loadingTableStatus" setHeight="350"> |
| 29 | + <ChartBuilder |
| 30 | + chartType="pie" |
| 31 | + chartID="suggestion" |
| 32 | + :chartOptions="options('suggestion')" |
| 33 | + :chartSeries="getSeries('suggestion')" |
| 34 | + chartHeight="350" |
29 | 35 | /> |
30 | 36 | </GhostLoading> |
31 | 37 | </BoxContent> |
32 | | - </div> |
| 38 | + </section> |
33 | 39 | </template> |
34 | 40 |
|
35 | 41 | <script> |
| 42 | +import _ from 'lodash' |
36 | 43 | import { mapGetters } from 'vuex' |
37 | 44 | import BoxContent from '@/components/common/BoxContent.vue' |
38 | 45 | import GhostLoading from '@/components/common/GhostLoading.vue' |
39 | | -import PieChart from '@/components/common/charts/PieChart.vue' |
| 46 | +import ChartBuilder from '@/components/common/charts/apex/ChartBuilder.vue' |
40 | 47 |
|
41 | 48 | export default { |
42 | 49 | name: 'cloud-sdvisors-recommendations-charts', |
43 | 50 | components: { |
44 | 51 | BoxContent, |
45 | 52 | GhostLoading, |
46 | | - PieChart, |
| 53 | + ChartBuilder, |
| 54 | + }, |
| 55 | + beforeMount() { |
| 56 | + this.returnCategoryChartData |
| 57 | + this.returnObjectTypeChartData |
| 58 | + this.returnSuggestionChartData |
| 59 | + }, |
| 60 | + methods: { |
| 61 | + getSeries(type) { |
| 62 | + if (type === 'category') { |
| 63 | + return this.returnCategoryChartData.series |
| 64 | + } else if (type === 'objectType') { |
| 65 | + return this.returnObjectTypeChartData.series |
| 66 | + } else if (type === 'suggestion') { |
| 67 | + return this.returnSuggestionChartData.series |
| 68 | + } |
| 69 | + }, |
| 70 | + getLabels(type) { |
| 71 | + if (type === 'category') { |
| 72 | + return this.returnCategoryChartData.labels |
| 73 | + } else if (type === 'objectType') { |
| 74 | + return this.returnObjectTypeChartData.labels |
| 75 | + } else if (type === 'suggestion') { |
| 76 | + return this.returnSuggestionChartData.labels |
| 77 | + } |
| 78 | + }, |
| 79 | + options(type) { |
| 80 | + return { |
| 81 | + labels: this.getLabels(type), |
| 82 | + dataLabels: { |
| 83 | + enabled: true, |
| 84 | + formatter: (val) => _.round(val, 1) + '%', |
| 85 | + style: { |
| 86 | + fontSize: '12px', |
| 87 | + colors: ['#000'], |
| 88 | + fontWeight: 'bold', |
| 89 | + }, |
| 90 | + background: { |
| 91 | + enabled: false, |
| 92 | + }, |
| 93 | + dropShadow: { |
| 94 | + enabled: false, |
| 95 | + }, |
| 96 | + }, |
| 97 | + legend: { |
| 98 | + show: true, |
| 99 | + position: 'left', |
| 100 | + fontSize: '14px', |
| 101 | + formatter: (label, series) => { |
| 102 | + return `${label}: <b>${ |
| 103 | + series.w.config.series[series.seriesIndex] |
| 104 | + }</b> - <b>${_.round( |
| 105 | + series.w.globals.seriesPercent[series.seriesIndex], |
| 106 | + 1 |
| 107 | + )}%</b>` |
| 108 | + }, |
| 109 | + }, |
| 110 | + tooltip: { |
| 111 | + enabled: true, |
| 112 | + fillSeriesColor: false, |
| 113 | + y: { |
| 114 | + formatter: (value, series) => { |
| 115 | + return `${value} - ${_.round( |
| 116 | + series.globals.seriesPercent[series.seriesIndex][0], |
| 117 | + 1 |
| 118 | + )}%` |
| 119 | + }, |
| 120 | + }, |
| 121 | + style: { |
| 122 | + fontSize: '14px', |
| 123 | + }, |
| 124 | + onDatasetHover: { |
| 125 | + highlightDataSeries: true, |
| 126 | + }, |
| 127 | + fixed: { |
| 128 | + enabled: true, |
| 129 | + position: 'topRight', |
| 130 | + offsetX: 0, |
| 131 | + offsetY: 0, |
| 132 | + }, |
| 133 | + }, |
| 134 | + colors: [ |
| 135 | + 'rgba(255, 99, 132)', |
| 136 | + 'rgba(54, 162, 235)', |
| 137 | + 'rgba(255, 206, 86)', |
| 138 | + 'rgba(75, 192, 192)', |
| 139 | + 'rgba(153, 102, 255)', |
| 140 | + 'rgba(255, 159, 64)', |
| 141 | + 'rgb(176, 101, 156)', // light purple |
| 142 | + 'rgb(254, 188, 59)', // light orange |
| 143 | + 'rgb(144, 190, 109)', // light green |
| 144 | + 'rgb(253, 128, 128)', // light red |
| 145 | + 'rgb(71, 172, 177)', // light blue |
| 146 | + 'rgb(232, 221, 9)', // yellow |
| 147 | + 'rgb(248, 150, 30)', // dark orange |
| 148 | + 'rgb(139, 117, 215)', // dark purple |
| 149 | + 'rgb(249, 65, 68)', // dark red |
| 150 | + 'rgb(67, 170, 139)', // dark green |
| 151 | + 'rgb(87, 117, 144)', // dark blue |
| 152 | + ].reverse(), |
| 153 | + stroke: { |
| 154 | + show: true, |
| 155 | + width: 0.3, |
| 156 | + }, |
| 157 | + } |
| 158 | + }, |
47 | 159 | }, |
48 | 160 | computed: { |
49 | 161 | ...mapGetters([ |
| 162 | + 'loadingTableStatus', |
50 | 163 | 'returnCategoryChartData', |
51 | 164 | 'returnObjectTypeChartData', |
52 | 165 | 'returnSuggestionChartData', |
53 | | - 'loadingTableStatus', |
54 | 166 | ]), |
55 | 167 | }, |
56 | 168 | } |
|
0 commit comments