File tree Expand file tree Collapse file tree 3 files changed +21
-10
lines changed Expand file tree Collapse file tree 3 files changed +21
-10
lines changed Original file line number Diff line number Diff line change 78
78
id =" attribute-select"
79
79
title =" Attribute"
80
80
on:change ={onChange }
81
+ class =" w-[80%] truncate"
81
82
/>
82
83
<button
83
84
bind:this ={trigger }
Original file line number Diff line number Diff line change 1
1
<script lang =" ts" >
2
2
import type { Feature } from ' geojson' ;
3
3
4
- import { deriveExtent , deriveThresholds } from ' $lib/interaction/scales' ;
4
+ import { deriveExtent } from ' $lib/interaction/scales' ;
5
5
import type { ConstantStroke , QuantitativeFill } from ' $lib/types' ;
6
6
7
7
export let fill: QuantitativeFill ;
10
10
11
11
$ : colors = fill .scheme [fill .count ] as string [];
12
12
$ : [min , max ] = deriveExtent (fill .attribute , features );
13
- $ : stops = deriveThresholds ({
14
- method: fill .method ,
15
- attribute: fill .attribute ,
16
- features: features ,
17
- range: colors ,
18
- thresholds: fill .thresholds
19
- });
20
13
</script >
21
14
22
15
<div class =" stack stack-xs ml-8 text-white" >
42
35
{/each }
43
36
</ul >
44
37
<ul class =" stack stack-xs" >
45
- {#each [min , ... stops , max ] as stop }
38
+ {#each [min , ... fill . thresholds , max ] as stop }
46
39
<li class =" stack-h stack-h-xs h-4 font-mono text-3xs" >
47
40
<span class =" text-slate-400" > → </span >
48
41
<span >{stop .toFixed (2 )}</span >
Original file line number Diff line number Diff line change @@ -278,10 +278,27 @@ export function dispatchLayerUpdate({
278
278
( map . getSource ( layerId ) as GeoJSONSource ) . setData ( features ) ;
279
279
break ;
280
280
}
281
- case 'Choropleth' :
281
+ case 'Choropleth' : {
282
282
lyr . style . fill . attribute = payload . attribute ;
283
+
284
+ if ( lyr . style . fill . type === 'Quantitative' ) {
285
+ lyr . style . fill . thresholds = deriveThresholds ( {
286
+ method : lyr . style . fill . method ,
287
+ attribute : payload . attribute ,
288
+ features : lyr . data . geojson . features ,
289
+ range : lyr . style . fill . scheme [ lyr . style . fill . count ] as string [ ] ,
290
+ thresholds : lyr . style . fill . thresholds
291
+ } ) ;
292
+ } else {
293
+ lyr . style . fill . categories = enumerateAttributeCategories (
294
+ lyr . data . geojson . features ,
295
+ payload . attribute
296
+ ) ;
297
+ }
298
+
283
299
map . setPaintProperty ( lyr . id , 'fill-color' , deriveColorScale ( lyr ) ) ;
284
300
break ;
301
+ }
285
302
}
286
303
287
304
return ir ;
You can’t perform that action at this time.
0 commit comments