Skip to content

Commit

Permalink
Reverse colour scale
Browse files Browse the repository at this point in the history
  • Loading branch information
ev-sc committed Dec 11, 2024
1 parent 3bf9d4b commit 3cda2f4
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,17 @@ const PoliticalChoropleths: React.FC<PoliticalChoroplethsProps> = ({
visibility,
}}
paint={{
'text-opacity': [
'interpolate',
['exponential', 1],
['zoom'],
//
7.5,
0,
//
7.8,
1,
],
'text-color': 'white',
'text-halo-color': '#24262b',
'text-halo-width': 1.5,
Expand All @@ -126,7 +137,17 @@ const PoliticalChoropleths: React.FC<PoliticalChoroplethsProps> = ({
}}
paint={{
'text-color': 'white',
'text-opacity': 1,
'text-opacity': [
'interpolate',
['exponential', 1],
['zoom'],
//
6.5,
0,
//
7,
1,
],
'text-halo-color': '#24262b',
'text-halo-width': 1.5,
}}
Expand Down
29 changes: 23 additions & 6 deletions nextjs/src/app/reports/[id]/mapboxStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function getChoroplethFill(
const colourScale = scaleSequential()
.domain([min, max])
.interpolator(interpolateBlues)
.interpolator((t) => interpolateBlues(1 - t))

let steps = Math.min(max, 30) // Max 30 steps
steps = Math.max(steps, 3) // Min 3 steps (for valid Mapbox fill-color rule)
Expand Down Expand Up @@ -172,14 +173,30 @@ export const getAreaCountLayout = (
'text-size': [
'interpolate',
['linear'],
['get', 'count'],
min,
textScale(min) * 17,
max,
textScale(max) * 17,
['zoom'],
1,
[
'max',
['*', ['/', ['get', 'count'], max], textScale(max) * 9],
textScale(min) * 10,
],
12,
[
'max',
['*', ['/', ['get', 'count'], max], textScale(max) * 18],
textScale(min) * 20,
],
],
'symbol-placement': 'point',
'text-offset': [0, -0.5],
'text-offset': [
'interpolate',
['linear'],
['zoom'],
1,
[0, -0.1],
12,
[0, -1],
],
'text-allow-overlap': true,
'text-ignore-placement': true,
'text-font': ['DIN Offc Pro Medium', 'Arial Unicode MS Bold'],
Expand Down

0 comments on commit 3cda2f4

Please sign in to comment.