Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Commit 99ac3cf

Browse files
committed
WIP...
1 parent 49b62db commit 99ac3cf

File tree

2 files changed

+74
-7
lines changed

2 files changed

+74
-7
lines changed

assets/javascripts/discourse/components/admin-report-sentiment-analysis.gjs

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

assets/stylesheets/modules/sentiment/common/dashboard.scss

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,27 @@
99
}
1010
}
1111
}
12+
13+
.admin-report.sentiment-analyis {
14+
.filters {
15+
order: 1;
16+
width: 100%;
17+
}
18+
19+
.main {
20+
order: 2;
21+
}
22+
}
23+
24+
.admin-report-sentiment-analysis {
25+
margin-top: 1rem;
26+
display: grid;
27+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
28+
gap: 2.5rem;
29+
justify-items: center;
30+
31+
.admin-report-doughnut {
32+
max-width: 300px; /* Adjust size */
33+
max-height: 300px;
34+
}
35+
}

0 commit comments

Comments
 (0)