File tree 3 files changed +63
-4
lines changed
javascripts/discourse/components
stylesheets/modules/sentiment/common
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";
10
10
import DButton from " discourse/components/d-button" ;
11
11
import HorizontalOverflowNav from " discourse/components/horizontal-overflow-nav" ;
12
12
import PostList from " discourse/components/post-list" ;
13
+ import bodyClass from " discourse/helpers/body-class" ;
13
14
import dIcon from " discourse/helpers/d-icon" ;
14
15
import replaceEmoji from " discourse/helpers/replace-emoji" ;
15
16
import { ajax } from " discourse/lib/ajax" ;
@@ -318,6 +319,7 @@ export default class AdminReportSentimentAnalysis extends Component {
318
319
{{/unless }}
319
320
320
321
{{#if ( and this . selectedChart this . showingSelectedChart) }}
322
+ {{bodyClass " showing-sentiment-analysis-chart" }}
321
323
<div class =" admin-report-sentiment-analysis__selected-chart" >
322
324
<div class =" admin-report-sentiment-analysis__selected-chart-actions" >
323
325
<DButton
Original file line number Diff line number Diff line change @@ -62,6 +62,40 @@ export default class DoughnutChart extends Component {
62
62
ctx .save ();
63
63
},
64
64
},
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
+ },
65
99
],
66
100
};
67
101
}
Original file line number Diff line number Diff line change 44
44
display : none ;
45
45
}
46
46
47
+ .control :last-child {
48
+ align-self : flex-end ;
49
+
50
+ input {
51
+ }
52
+ }
53
+
47
54
.control :has (.export-csv-btn ) {
48
55
display : none ;
49
56
}
63
70
@include report-container-box ();
64
71
flex : 2 ;
65
72
display : flex ;
66
- gap : 1rem ;
67
- justify-content : space-around ;
73
+ gap : 2 rem 1rem ;
74
+ justify-content : space-evenly ;
68
75
align-items : center ;
69
76
flex-flow : row wrap ;
77
+ padding-inline : 0 ;
78
+ padding-block : 1.5rem ;
70
79
71
80
.admin-report-doughnut {
72
81
padding : 0.25rem ;
87
96
88
97
& :hover {
89
98
box-shadow : var (--shadow-card );
90
- transform : translateY (-1 rem );
99
+ transform : translateY (-0.5 rem );
91
100
cursor : pointer ;
92
101
}
93
102
}
219
228
position : sticky ;
220
229
top : 0 ;
221
230
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 ;
223
246
}
224
247
}
You can’t perform that action at this time.
0 commit comments