You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ri...@apache.org on 2026/05/25 10:12:22 UTC
(streampipes) branch fix-gauge-color-mapping created (now aa98ba50aa)
This is an automated email from the ASF dual-hosted git repository.
dominikriemer pushed a change to branch fix-gauge-color-mapping
in repository https://gitbox.apache.org/repos/asf/streampipes.git
at aa98ba50aa fix: Color mapping in gauge chart
This branch includes the following new commits:
new aa98ba50aa fix: Color mapping in gauge chart
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(streampipes) 01/01: fix: Color mapping in gauge chart
Posted by ri...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
dominikriemer pushed a commit to branch fix-gauge-color-mapping
in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit aa98ba50aafd465aed92f3459b2d6e11ca87a251
Author: Dominik Riemer <do...@gmail.com>
AuthorDate: Mon May 25 12:12:04 2026 +0200
fix: Color mapping in gauge chart
---
.../charts/gauge/gauge-renderer.service.ts | 63 +++++++++-------------
1 file changed, 26 insertions(+), 37 deletions(-)
diff --git a/ui/src/app/chart-shared/components/charts/gauge/gauge-renderer.service.ts b/ui/src/app/chart-shared/components/charts/gauge/gauge-renderer.service.ts
index 225f8e8abf..745c5629fd 100644
--- a/ui/src/app/chart-shared/components/charts/gauge/gauge-renderer.service.ts
+++ b/ui/src/app/chart-shared/components/charts/gauge/gauge-renderer.service.ts
@@ -49,8 +49,7 @@ export class SpGaugeRendererService implements SpEchartsRenderer<GaugeWidgetMode
gaugeLayout: GaugeLayout,
): GaugeSeriesOption {
const visConfig = widgetConfig.visualizationConfig;
- const minDimension = Math.min(widgetSize.width, widgetSize.height);
- const clamp = Math.min(Math.max(minDimension / 320, 0.7), 1.4);
+ const clamp = this.getSizeClamp(widgetSize);
const useThresholdColors = !!visConfig.enableThresholdColors;
const displayName = this.makeDisplayName(
visConfig.displayName,
@@ -69,7 +68,7 @@ export class SpGaugeRendererService implements SpEchartsRenderer<GaugeWidgetMode
show: visConfig.showPointer,
},
progress: {
- show: true,
+ show: !useThresholdColors,
},
axisLabel: {
fontSize: 10 * clamp,
@@ -93,17 +92,15 @@ export class SpGaugeRendererService implements SpEchartsRenderer<GaugeWidgetMode
};
if (useThresholdColors) {
- const thresholdSegments = this.makeThresholdSegments(visConfig);
- const progressColor = this.getProgressColor(value, visConfig);
- series.progress = {
- ...series.progress,
- itemStyle: {
- color: progressColor,
- },
- };
series.axisLine = {
lineStyle: {
- color: thresholdSegments,
+ color: this.makeThresholdSegments(visConfig),
+ },
+ };
+ series.pointer = {
+ ...series.pointer,
+ itemStyle: {
+ color: 'auto',
},
};
}
@@ -258,19 +255,6 @@ export class SpGaugeRendererService implements SpEchartsRenderer<GaugeWidgetMode
];
}
- private getProgressColor(value: number, visConfig: GaugeVisConfig): string {
- const normalizedThresholds = this.normalizeThresholds(visConfig);
- if (value <= normalizedThresholds.low) {
- return this.getLowColor(visConfig);
- }
-
- if (value <= normalizedThresholds.high) {
- return this.getMediumColor(visConfig);
- }
-
- return this.getHighColor(visConfig);
- }
-
private normalizeThresholds(visConfig: GaugeVisConfig): {
min: number;
max: number;
@@ -302,22 +286,15 @@ export class SpGaugeRendererService implements SpEchartsRenderer<GaugeWidgetMode
: { min, max, range, low: high, high: low };
}
- private getLowColor(visConfig: GaugeVisConfig): string {
- return visConfig.thresholdColorLow || '#91cc75';
- }
-
- private getMediumColor(visConfig: GaugeVisConfig): string {
- return visConfig.thresholdColorMedium || '#fac858';
- }
-
- private getHighColor(visConfig: GaugeVisConfig): string {
- return visConfig.thresholdColorHigh || '#ee6666';
- }
-
private normalizeSplitNumber(splitNumber: number): number {
return Math.max(1, Math.round(this.toFiniteNumber(splitNumber, 10)));
}
+ private getSizeClamp(widgetSize: WidgetSize): number {
+ const minDimension = Math.min(widgetSize.width, widgetSize.height);
+ return Math.min(Math.max(minDimension / 320, 0.7), 1.4);
+ }
+
private clamp(value: number, min: number, max: number): number {
return Math.min(max, Math.max(min, value));
}
@@ -327,6 +304,18 @@ export class SpGaugeRendererService implements SpEchartsRenderer<GaugeWidgetMode
return Number.isFinite(parsedValue) ? parsedValue : fallback;
}
+ private getLowColor(visConfig: GaugeVisConfig): string {
+ return visConfig.thresholdColorLow || '#91cc75';
+ }
+
+ private getMediumColor(visConfig: GaugeVisConfig): string {
+ return visConfig.thresholdColorMedium || '#fac858';
+ }
+
+ private getHighColor(visConfig: GaugeVisConfig): string {
+ return visConfig.thresholdColorHigh || '#ee6666';
+ }
+
private makeDisplayName(displayName: unknown, fallback: string): string {
if (typeof displayName === 'string' && displayName.trim().length > 0) {
return displayName;