This repository was archived by the owner on Jul 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +63
-4
lines changed
javascripts/discourse/components
stylesheets/modules/sentiment/common Expand file tree Collapse file tree 3 files changed +63
-4
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import { and } from "truth-helpers";
1010import DButton from " discourse/components/d-button" ;
1111import HorizontalOverflowNav from " discourse/components/horizontal-overflow-nav" ;
1212import PostList from " discourse/components/post-list" ;
13+ import bodyClass from " discourse/helpers/body-class" ;
1314import dIcon from " discourse/helpers/d-icon" ;
1415import replaceEmoji from " discourse/helpers/replace-emoji" ;
1516import { ajax } from " discourse/lib/ajax" ;
@@ -318,6 +319,7 @@ export default class AdminReportSentimentAnalysis extends Component {
318319 {{/unless }}
319320
320321 {{#if ( and this . selectedChart this . showingSelectedChart) }}
322+ {{bodyClass " showing-sentiment-analysis-chart" }}
321323 <div class =" admin-report-sentiment-analysis__selected-chart" >
322324 <div class =" admin-report-sentiment-analysis__selected-chart-actions" >
323325 <DButton
Original file line number Diff line number Diff line change @@ -62,6 +62,40 @@ export default class DoughnutChart extends Component {
6262 ctx .save ();
6363 },
6464 },
65+ {
66+ // Custom plugin to draw labels inside the doughnut chart
67+ id: " doughnutLabels" ,
68+ afterDraw (chart ) {
69+ const ctx = chart .ctx ;
70+ const dataset = chart .data .datasets [0 ];
71+ const meta = chart .getDatasetMeta (0 );
72+ const cssFontSize =
73+ getComputedStyle (document .documentElement ).getPropertyValue (
74+ " --font-down-2"
75+ ) || " 1.3em" ;
76+ const cssFontFamily =
77+ getComputedStyle (document .documentElement ).getPropertyValue (
78+ " --font-family"
79+ ) || " sans-serif" ;
80+
81+ ctx .font = ` ${ cssFontSize .trim ()} ${ cssFontFamily .trim ()} ` ;
82+ ctx .fillStyle = " #fafafa" ;
83+ ctx .textAlign = " center" ;
84+ ctx .textBaseline = " middle" ;
85+
86+ meta .data .forEach ((element , index ) => {
87+ const { x , y } = element .tooltipPosition ();
88+ const value = dataset .data [index];
89+ const nonZeroCount = dataset .data .filter ((v ) => v > 0 ).length ;
90+
91+ if (value === 0 || nonZeroCount === 1 ) {
92+ return ;
93+ }
94+
95+ ctx .fillText (value, x, y);
96+ });
97+ },
98+ },
6599 ],
66100 };
67101 }
Original file line number Diff line number Diff line change 4444 display : none ;
4545 }
4646
47+ .control :last-child {
48+ align-self : flex-end ;
49+
50+ input {
51+ }
52+ }
53+
4754 .control :has (.export-csv-btn ) {
4855 display : none ;
4956 }
6370 @include report-container-box ();
6471 flex : 2 ;
6572 display : flex ;
66- gap : 1rem ;
67- justify-content : space-around ;
73+ gap : 2 rem 1rem ;
74+ justify-content : space-evenly ;
6875 align-items : center ;
6976 flex-flow : row wrap ;
77+ padding-inline : 0 ;
78+ padding-block : 1.5rem ;
7079
7180 .admin-report-doughnut {
7281 padding : 0.25rem ;
8796
8897 & :hover {
8998 box-shadow : var (--shadow-card );
90- transform : translateY (-1 rem );
99+ transform : translateY (-0.5 rem );
91100 cursor : pointer ;
92101 }
93102 }
219228 position : sticky ;
220229 top : 0 ;
221230 padding-top : 1rem ;
222- z-index : z (" header" );
231+ z-index : z (" timeline" );
232+ }
233+ }
234+
235+ .showing-sentiment-analysis-chart
236+ .admin-report.sentiment-analysis
237+ .body
238+ .filters {
239+ // Hide elements 2 - 6 when showing selected chart
240+ // as they're not supported being changed in this view
241+ .control :first-of-type {
242+ flex : unset ;
243+ }
244+ .control :nth-of-type (n + 2 ):nth-of-type (-n + 6 ) {
245+ display : none ;
223246 }
224247}
You can’t perform that action at this time.
0 commit comments