From 22f7d948593223db922168c6d6431d63a9c8ee50 Mon Sep 17 00:00:00 2001 From: io53 Date: Tue, 19 Mar 2024 23:53:00 +0200 Subject: [PATCH] #381 in graphs, show values with resolution according to user selected resolution --- src/components/Graph.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/Graph.js b/src/components/Graph.js index da96844..66584f0 100644 --- a/src/components/Graph.js +++ b/src/components/Graph.js @@ -1,7 +1,7 @@ import React, { Component, Suspense, useEffect, useState } from "react"; import 'uplot/dist/uPlot.min.css'; import { withTranslation } from 'react-i18next'; -import { getUnitHelper, localeNumber, round } from "../UnitHelper"; +import { getDisplayValue, getUnitHelper, localeNumber, round } from "../UnitHelper"; import UplotTouchZoomPlugin from "./UplotTouchZoomPlugin"; import { ruuviTheme } from "../themes"; import { withColorMode } from "../utils/withColorMode"; @@ -52,7 +52,7 @@ let zoomData = { } function DataInfo(props) { - const { graphData, t } = props + const { graphData, t, type } = props const [currZoom, setCurrZoom] = useState(null); useEffect(() => { zoomData.registerListener(v => { @@ -86,9 +86,9 @@ function DataInfo(props) { } let avg = calculateAverage(data) return <> - {t("graph_stat_min")}: {localeNumber(min)} - {t("graph_stat_max")}: {localeNumber(max)} - {t("graph_stat_avg")}: {localeNumber(avg)} + {t("graph_stat_min")}: {getDisplayValue(type, min)} + {t("graph_stat_max")}: {getDisplayValue(type, max)} + {t("graph_stat_avg")}: {getDisplayValue(type, avg)} notify.info(t("graph_stats_info"))}> @@ -366,7 +366,7 @@ class Graph extends Component { points: { show: this.props.points, size: 4, fill: ruuviTheme.graph.fill[colorMode] }, width: 1, ...alertColor(), - value: (self, rawValue) => localeNumber(rawValue) + value: (self, rawValue) => getDisplayValue(this.props.dataKey, rawValue) }], hooks: { drawSeries: [ @@ -505,7 +505,7 @@ class Graph extends Component { {!this.props.cardView && <>
- +
}