@@ -6,23 +6,66 @@ export default class AdminReportSentimentAnalysis extends Component {
66 return {
77 type: " doughnut" ,
88 data: {
9- labels: [" Positive" , " Negative " , " Neutral " ],
9+ labels: [" Positive" , " Neutral " , " Negative " ],
1010 datasets: [
1111 {
1212 data: [300 , 50 , 100 ],
13- backgroundColor: [" #28a745 " , " #dc3545 " , " #ffc107 " ],
13+ backgroundColor: [" #2ecc71 " , " #95a5a6 " , " #e74c3c " ],
1414 },
1515 ],
1616 },
17+ options: {
18+ responsive: true ,
19+ plugins: {
20+ legend: {
21+ position: " bottom" ,
22+ },
23+ },
24+ },
25+ plugins: [
26+ {
27+ id: " centerText" ,
28+ afterDraw : function (chart ) {
29+ const cssVarColor =
30+ getComputedStyle (document .documentElement ).getPropertyValue (
31+ " --primary"
32+ ) || " #000" ;
33+ const cssFontSize =
34+ getComputedStyle (document .documentElement ).getPropertyValue (
35+ " --font-down-2"
36+ ) || " 1.3em" ;
37+ const cssFontFamily =
38+ getComputedStyle (document .documentElement ).getPropertyValue (
39+ " --font-family"
40+ ) || " sans-serif" ;
41+
42+ const { ctx , chartArea } = chart;
43+ const centerX = (chartArea .left + chartArea .right ) / 2 ;
44+ const centerY = (chartArea .top + chartArea .bottom ) / 2 ;
45+
46+ ctx .restore ();
47+ ctx .textAlign = " center" ;
48+ ctx .textBaseline = " middle" ;
49+ ctx .fillStyle = cssVarColor .trim ();
50+ ctx .font = ` ${ cssFontSize .trim ()} ${ cssFontFamily .trim ()} ` ;
51+
52+ // TODO: populate with actual tag / category title
53+ ctx .fillText (" member-experience" , centerX, centerY);
54+ ctx .save ();
55+ },
56+ },
57+ ],
1758 };
1859 }
1960
2061 <template >
21- <div >
22- <Chart
23- @ chartConfig ={{this .chartConfig }}
24- class =" admin-report-chart admin-report-doughnut"
25- />
62+ {{! TODO each-loop based on data, display doughnut component }}
63+ <div class =" admin-report-sentiment-analysis" >
64+ <Chart @ chartConfig ={{this .chartConfig }} class =" admin-report-doughnut" />
65+ <Chart @ chartConfig ={{this .chartConfig }} class =" admin-report-doughnut" />
66+ <Chart @ chartConfig ={{this .chartConfig }} class =" admin-report-doughnut" />
67+ <Chart @ chartConfig ={{this .chartConfig }} class =" admin-report-doughnut" />
68+ <Chart @ chartConfig ={{this .chartConfig }} class =" admin-report-doughnut" />
2669 </div >
2770 </template >
2871}
0 commit comments