Skip to content
This repository was archived by the owner on Feb 11, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
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
5 changes: 2 additions & 3 deletions hub/graphql/types/model_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1591,6 +1591,7 @@ def statistics_for_choropleth(
# they're gonna all be geo-joined for now.
stats_config: stats.StatisticsConfig,
choropleth_config: Optional[stats.ChoroplethConfig] = None,
map_bounds: Optional[stats.MapBounds] = None,
) -> List[GroupedDataCount]:
choropleth_config = choropleth_config or stats.ChoroplethConfig()

Expand Down Expand Up @@ -1625,9 +1626,7 @@ def statistics_for_choropleth(

return (
stats.statistics(
stats_config,
choropleth_config,
as_grouped_data=True,
stats_config, choropleth_config, as_grouped_data=True, map_bounds=map_bounds
)
or []
) # Convert None to empty list for better front-end integration
5 changes: 2 additions & 3 deletions hub/graphql/types/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,14 @@ class ChoroplethConfig:
category_key: Optional[str] = None
count_key: Optional[str] = None
is_count_key_percentage: Optional[bool] = False
map_bounds: Optional[MapBounds] = None


def statistics(
conf: StatisticsConfig,
choropleth_config: Optional[ChoroplethConfig] = None,
as_grouped_data: bool = False,
return_numeric_keys_only: Optional[bool] = False,
map_bounds: Optional[MapBounds] = None,
):
choropleth_config = choropleth_config or ChoroplethConfig()

Expand Down Expand Up @@ -227,8 +227,7 @@ def statistics(

# Actual SELECT statement is manually constructed below
qs = models.GenericData.objects.values_list("id")
if choropleth_config.map_bounds:
map_bounds = choropleth_config.map_bounds
if map_bounds:
bbox_coords = (
(map_bounds.west, map_bounds.north), # Top left
(map_bounds.east, map_bounds.north), # Top right
Expand Down
4 changes: 2 additions & 2 deletions nextjs/src/__generated__/gql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions nextjs/src/__generated__/graphql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions nextjs/src/__generated__/zodSchema.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion nextjs/src/app/reports/[id]/useDataByBoundary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ const useDataByBoundary = ({
STATISTICS_QUERY,
{
variables: {
mapBounds,
config: {
...(view?.mapOptions?.choropleth.advancedStatisticsConfig! || {}),
groupByArea: tileset.analyticalAreaType!,
},
choroplethConfig: {
mapBounds,
categoryKey:
view?.mapOptions?.choropleth.dataType ===
StatisticalDataType.Nominal
Expand Down Expand Up @@ -126,10 +126,12 @@ export const STATISTICS_QUERY = gql`
query Statistics(
$config: StatisticsConfig!
$choroplethConfig: ChoroplethConfig!
$mapBounds: MapBounds
) {
statisticsForChoropleth(
statsConfig: $config
choroplethConfig: $choroplethConfig
mapBounds: $mapBounds
) {
label
gss
Expand Down
Loading