From 76867a322bb0483884b4b10729b712cf09b00e05 Mon Sep 17 00:00:00 2001 From: Paul Crossley Date: Thu, 19 Dec 2024 12:10:35 +0000 Subject: [PATCH] adjustable decimal places in snapshot --- app/javascript/projects/analysis_panel.tsx | 24 +++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/app/javascript/projects/analysis_panel.tsx b/app/javascript/projects/analysis_panel.tsx index 58206d0..778f16c 100644 --- a/app/javascript/projects/analysis_panel.tsx +++ b/app/javascript/projects/analysis_panel.tsx @@ -95,9 +95,10 @@ interface ChartLegendProps { chartData: ChartData | undefined sourceType: string props: TileGridProps | undefined + decimalPlaces: number } -const ChartLegend = ({ chartData, sourceType, props }: ChartLegendProps) => { +const ChartLegend = ({ chartData, sourceType, props, decimalPlaces }: ChartLegendProps) => { if (!chartData) { return null } @@ -127,7 +128,7 @@ const ChartLegend = ({ chartData, sourceType, props }: ChartLegendProps) => { () const [bins, setBins] = React.useState(10) const [colors, setColors] = React.useState(null) + const [decimalPlaces, setDecimalPlaces] = React.useState(2) let errorMsg: string = "" let showChart: boolean = false @@ -284,8 +286,9 @@ export const AnalysisPanel = ({ selectedArea, setSelectedArea, setShowAP, select chartType == "hist" && <> - + setBins(+e.target.value)} @@ -293,10 +296,25 @@ export const AnalysisPanel = ({ selectedArea, setSelectedArea, setShowAP, select /> } + { + data instanceof NumericTileGrid + && + <> + + setDecimalPlaces(+e.target.value)} + min={0} + /> + + }