Sfoglia il codice sorgente

Max humidity graph at 100% + better high/low display

Jason Tarka 2 anni fa
parent
commit
0fe812bbbd
2 ha cambiato i file con 14 aggiunte e 2 eliminazioni
  1. 7 0
      web-view/src/js/consts.ts
  2. 7 2
      web-view/src/js/graphs.ts

+ 7 - 0
web-view/src/js/consts.ts

@@ -28,6 +28,8 @@ export type FieldInfo = {
 	excludeGauge: boolean,
 	minValue: number,
 	maxValue: number,
+	/** If the maximum value should be stretched upwards. */
+	stretchMax: boolean,
 	gaugeColours: any,
 }
 
@@ -51,6 +53,7 @@ export const FIELDS: FieldInfo[] = [
 		windowType: WindowType.AVERAGE,
 		minValue: -10,
 		maxValue: 30,
+		stretchMax: true,
 		excludeGauge: false,
 		gaugeColours: {
 			'-10': Colours.PaleBlue,
@@ -70,6 +73,7 @@ export const FIELDS: FieldInfo[] = [
 		windowType: WindowType.AVERAGE,
 		minValue: 0,
 		maxValue: 100,
+		stretchMax: false,
 		excludeGauge: false,
 		gaugeColours: {
 			20: Colours.Orange,
@@ -87,6 +91,7 @@ export const FIELDS: FieldInfo[] = [
 		windowType: WindowType.AVERAGE,
 		minValue: 960,
 		maxValue: 1030,
+		stretchMax: true,
 		excludeGauge: false,
 		gaugeColours: {
 			990: Colours.Blue,
@@ -103,6 +108,7 @@ export const FIELDS: FieldInfo[] = [
 		windowType: WindowType.AVERAGE,
 		minValue: 50,
 		maxValue: 8191,
+		stretchMax: false,
 		excludeGauge: false,
 		gaugeColours: {
 			0: Colours.Blue,
@@ -120,6 +126,7 @@ export const FIELDS: FieldInfo[] = [
 		windowType: WindowType.MAX,
 		minValue: 0,
 		maxValue: 10,
+		stretchMax: true,
 		excludeGauge: true,
 		gaugeColours: null,
 	},

+ 7 - 2
web-view/src/js/graphs.ts

@@ -41,7 +41,7 @@ function addCanvas(
 
 	const minMax: HTMLSpanElement = document.createElement('span');
 	let unit = fieldInfo.unit ? ` ${fieldInfo.unit}` : '';
-	minMax.innerHTML = `(${data.minimum}${unit} - ${data.maximum}${unit})`;
+	minMax.innerHTML = `(H: ${data.maximum}${unit} / L: ${data.minimum}${unit})`;
 
 	const title = document.createElement('div');
 	title.append(header, minMax);
@@ -92,7 +92,12 @@ function createGraph(
 			scales: {
 				y: {
 					suggestedMin: minMax.min - (RANGE_PADDING / 2),
-					suggestedMax: minMax.max < 0 ? 0 : minMax.max + (RANGE_PADDING / 2)
+					suggestedMax: (() => {
+						if (fieldInfo.stretchMax) {
+							return minMax.max < 0 ? 0 : minMax.max + (RANGE_PADDING / 2)
+						}
+						return minMax.max;
+					})()
 				}
 			}
 		}