Skip to content

Commit

Permalink
Default config updates
Browse files Browse the repository at this point in the history
  • Loading branch information
nofurtherinformation committed Mar 22, 2024
1 parent 6567735 commit 937d244
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
13 changes: 7 additions & 6 deletions components/Map/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ export default function MapOuter() {

// Viewport settings
const INITIAL_VIEW_STATE = {
longitude: -122.41669,
latitude: 37.7853,
zoom: 13,
longitude: -98.6,
latitude: 39.8283,
zoom: 4,
pitch: 0,
bearing: 0,
}
Expand Down Expand Up @@ -152,7 +152,7 @@ export const Map = () => {
const handleSetColumn = (col: string | number) => dispatch(setCurrentColumn(col))
const handleChangeData = (data: string) => dispatch(setCurrentData(data))
const handleSetFilter = (filter: string) => dispatch(setCurrentFilter(filter))

console.log('currentColumnSpec', currentColumnSpec)
return (
<div style={{ width: "100vw", height: "100vh", position: "relative", top: 0, left: 0 }}>
<div style={{ position: "absolute", bottom: "2rem", right: "1rem", zIndex: 1000 }}>
Expand All @@ -161,7 +161,7 @@ export const Map = () => {
{!!(colors.length && breaks.length) &&
colors.map((_, i) => <BreakText key={i} colors={colors} breaks={breaks} index={i} />)}
<p style={{ maxWidth: "35ch", fontSize: "0.75rem" }}>
<i>Data source: InfoGroup Reference USA. Concentration index (HHI) includes grocery and superstores only.</i>
<i>{currentDataSpec?.attribution}</i>
</p>
</div>
</div>
Expand Down Expand Up @@ -208,10 +208,11 @@ export const Map = () => {
</div>
<Tooltip dataService={ds} />
<GlMap
hash={true}
// hash={true}
mapboxAccessToken={process.env.NEXT_PUBLIC_MAPBOX_TOKEN}
mapStyle="mapbox://styles/dhalpern/clsb432ya02pi01pf1o813uwa"
initialViewState={INITIAL_VIEW_STATE}
projection={"mercator"}
// @ts-ignore
ref={mapRef}
reuseMaps={true}
Expand Down
10 changes: 5 additions & 5 deletions utils/data/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
const years = [2000,2010,2020]

const hhiColumns: Array<ColumnConfig> = years.map(year => ({
name: `Concentration Index ${year}`,
name: `Concentration Index ${year} (No Dollar Stores)`,
column: year,
description: `Herfindahl-Hirschman Index for ${year}`
}))
Expand All @@ -23,7 +23,7 @@ const DollarStoreHhiConfig: DataConfig = {
id: 'GEOID',
columns: hhiColumns,
eager: true,
attribution: '',
attribution: 'Data source: InfoGroup Reference USA. ACS 2000-2020. Census Centers of Population 2020.',
colorScheme: 'schemeYlOrRd',
nBins: 6,
}
Expand All @@ -34,7 +34,7 @@ const GravityNoDollar: DataConfig = {
id: 'GEOID',
columns: gravityColumns,
eager: true,
attribution: '',
attribution: 'Data source: InfoGroup Reference USA. ACS 2000-2020. Census Centers of Population 2020.',
colorScheme: 'schemeRdYlGn',
nBins: 9,
}
Expand All @@ -45,7 +45,7 @@ const GravityDollar: DataConfig = {
id: 'GEOID',
columns: gravityColumns,
eager: true,
attribution: '',
attribution: 'Data source: InfoGroup Reference USA. ACS 2000-2020. Census Centers of Population 2020.',
colorScheme: 'schemeRdYlGn',
nBins: 9,
// manualBreaks: [
Expand All @@ -61,7 +61,7 @@ const GravityDollar: DataConfig = {
}

export const defaultData = GravityDollar.filename

export const defaultYear = 2020
export default [
GravityDollar,
GravityNoDollar,
Expand Down
1 change: 1 addition & 0 deletions utils/hooks/useDataService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const useDataService = () => {
}
const currentColumn = useAppSelector((state) => state.map.currentColumn)
const currentDataSpec = config.find(f => f.filename == currentData)

const currentColumnSpec = currentDataSpec?.columns?.find((f) => f.column === currentColumn)
const data = ds.data[currentData]
const isReady = completeData.includes(currentData)
Expand Down
6 changes: 3 additions & 3 deletions utils/state/map.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client"
import { createSlice } from '@reduxjs/toolkit'
import type { PayloadAction } from '@reduxjs/toolkit'
import config, { defaultData } from 'utils/data/config'
import config, { defaultData, defaultYear } from 'utils/data/config'
import { DataService } from 'utils/data/service'

export interface MapState {
Expand All @@ -20,14 +20,14 @@ export interface MapState {
}

const initialState: MapState = {
year: 2021,
year: defaultYear,
breaks: [0, 1, 2, 3, 4, 5],
colors: [[
255, 255, 255, 0
]],
completeData: [],
currentData: defaultData,
currentColumn: 2021,
currentColumn: defaultYear,
tooltip: null,
idFilter: undefined
}
Expand Down

0 comments on commit 937d244

Please sign in to comment.