Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjustable decimal places on snapshot #471

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading