-
- {{ (item as FeedbackStatisticsRecordType).satisfaction_average }}
-
- von
-
- {{ (item as FeedbackStatisticsRecordType).satisfaction_max }}
-
+
+
+
+ {{
+ (
+ item as FeedbackStatisticsRecordType
+ ).satisfaction_average.toFixed(1)
+ }}
+
+
+
+
+ {{ (item as FeedbackStatisticsRecordType).satisfaction_max }}
+
+
+
{{ $t("a.Allgemeine Zufriedenheit") }}
diff --git a/client/src/utils/ratingToColor.ts b/client/src/utils/ratingToColor.ts
new file mode 100644
index 00000000..bd1b9e05
--- /dev/null
+++ b/client/src/utils/ratingToColor.ts
@@ -0,0 +1,47 @@
+type RGB = [number, number, number];
+
+const red: RGB = [221, 103, 81]; // red-600
+const yellow: RGB = [250, 200, 82]; // yellow-500
+const lightGreen: RGB = [120, 222, 163]; // green-500
+const darkGreen: RGB = [91, 183, 130]; // green-600
+
+const blendColorValue = (v1: number, v2: number, weight: number): number => {
+ return v1 * (1 - weight) + v2 * weight;
+};
+
+const blendColors = (c1: RGB, c2: RGB, weight: number): RGB => {
+ const [r1, g1, b1] = c1;
+ const [r2, g2, b2] = c2;
+ return [
+ blendColorValue(r1, r2, weight),
+ blendColorValue(g1, g2, weight),
+ blendColorValue(b1, b2, weight),
+ ];
+};
+
+const getRGBString = (color: RGB): string => {
+ const [r, g, b] = color;
+ return `rgb(${Math.floor(r)}, ${Math.floor(g)}, ${Math.floor(b)})`;
+};
+
+export const getBlendedColorForRating = (rating: number): string => {
+ const scale = Math.floor(rating);
+ const weight = rating % 1;
+ let colors: [RGB, RGB];
+
+ switch (scale) {
+ case 1:
+ colors = [red, yellow];
+ break;
+ case 2:
+ colors = [yellow, lightGreen];
+ break;
+ case 3:
+ default:
+ colors = [lightGreen, darkGreen];
+ break;
+ }
+
+ const blendedColor = blendColors(colors[0], colors[1], weight);
+ return getRGBString(blendedColor);
+};