Skip to content

Commit

Permalink
Merge pull request #471 from wearepal/units-beta
Browse files Browse the repository at this point in the history
adjustable decimal places on snapshot
  • Loading branch information
paulthatjazz authored Dec 19, 2024
2 parents eafe11b + 76867a3 commit 3ce1da9
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions app/javascript/projects/analysis_panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -127,7 +128,7 @@ const ChartLegend = ({ chartData, sourceType, props }: ChartLegendProps) => {
<input
disabled
type="text"
value={NumStats[key]}
value={parseFloat(NumStats[key].toFixed(decimalPlaces)).toLocaleString()}
/>
<input
type='text'
Expand Down Expand Up @@ -176,6 +177,7 @@ export const AnalysisPanel = ({ selectedArea, setSelectedArea, setShowAP, select
const [chartData, setChartData] = React.useState<ChartData>()
const [bins, setBins] = React.useState<number>(10)
const [colors, setColors] = React.useState<any>(null)
const [decimalPlaces, setDecimalPlaces] = React.useState<number>(2)

let errorMsg: string = ""
let showChart: boolean = false
Expand Down Expand Up @@ -284,19 +286,35 @@ export const AnalysisPanel = ({ selectedArea, setSelectedArea, setShowAP, select
chartType == "hist"
&&
<>
<label style={{ width: 60 }}>Bars</label>
<label style={{ width: 40 }}>Bars</label>
<input
style={{ width: 50 }}
type="number"
value={bins}
onChange={(e) => setBins(+e.target.value)}
min={1}
/>
</>
}
{
data instanceof NumericTileGrid
&&
<>
<label style={{ width: 130 }}>Decimal Places</label>
<input
style={{ width: 50 }}
type="number"
value={decimalPlaces}
onChange={(e) => setDecimalPlaces(+e.target.value)}
min={0}
/>
</>
}
<ChartLegend
chartData={chartData}
sourceType={dataSourceType}
props={data instanceof NumericTileGrid ? data.properties : undefined}
decimalPlaces={decimalPlaces}
/>
</div>
</>
Expand Down

0 comments on commit 3ce1da9

Please sign in to comment.