Skip to content

Commit 44a66d1

Browse files
authored
[Fix] Fill and Stroke color working in Graduated symbology (#952)
* Making Fill and Stroke colore working in Graduated symbology * remove manual fill color input
1 parent c7ba8de commit 44a66d1

File tree

2 files changed

+12
-176
lines changed

2 files changed

+12
-176
lines changed

examples/earthquakes.jGIS

Lines changed: 4 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -109,79 +109,7 @@
109109
8.1,
110110
8.1
111111
],
112-
"circle-stroke-color": [
113-
"interpolate",
114-
[
115-
"linear"
116-
],
117-
[
118-
"get",
119-
"mag"
120-
],
121-
1.2522222222222221,
122-
[
123-
68.0,
124-
1.0,
125-
84.0,
126-
1.0
127-
],
128-
1.5544444444444445,
129-
[
130-
71.0,
131-
44.0,
132-
122.0,
133-
1.0
134-
],
135-
1.8566666666666667,
136-
[
137-
59.0,
138-
81.0,
139-
139.0,
140-
1.0
141-
],
142-
2.158888888888889,
143-
[
144-
44.0,
145-
113.0,
146-
142.0,
147-
1.0
148-
],
149-
2.4611111111111112,
150-
[
151-
33.0,
152-
144.0,
153-
141.0,
154-
1.0
155-
],
156-
2.786666666666666,
157-
[
158-
39.0,
159-
173.0,
160-
129.0,
161-
1.0
162-
],
163-
3.166666666666667,
164-
[
165-
92.0,
166-
200.0,
167-
99.0,
168-
1.0
169-
],
170-
3.723333333333333,
171-
[
172-
170.0,
173-
220.0,
174-
50.0,
175-
1.0
176-
],
177-
8.1,
178-
[
179-
253.0,
180-
231.0,
181-
37.0,
182-
1.0
183-
]
184-
],
112+
"circle-stroke-color": "#3399CC",
185113
"circle-stroke-width": 1.25,
186114
"fill-color": [
187115
"interpolate",
@@ -256,89 +184,18 @@
256184
1.0
257185
]
258186
],
259-
"stroke-color": [
260-
"interpolate",
261-
[
262-
"linear"
263-
],
264-
[
265-
"get",
266-
"mag"
267-
],
268-
1.2522222222222221,
269-
[
270-
68.0,
271-
1.0,
272-
84.0,
273-
1.0
274-
],
275-
1.5544444444444445,
276-
[
277-
71.0,
278-
44.0,
279-
122.0,
280-
1.0
281-
],
282-
1.8566666666666667,
283-
[
284-
59.0,
285-
81.0,
286-
139.0,
287-
1.0
288-
],
289-
2.158888888888889,
290-
[
291-
44.0,
292-
113.0,
293-
142.0,
294-
1.0
295-
],
296-
2.4611111111111112,
297-
[
298-
33.0,
299-
144.0,
300-
141.0,
301-
1.0
302-
],
303-
2.786666666666666,
304-
[
305-
39.0,
306-
173.0,
307-
129.0,
308-
1.0
309-
],
310-
3.166666666666667,
311-
[
312-
92.0,
313-
200.0,
314-
99.0,
315-
1.0
316-
],
317-
3.723333333333333,
318-
[
319-
170.0,
320-
220.0,
321-
50.0,
322-
1.0
323-
],
324-
8.1,
325-
[
326-
253.0,
327-
231.0,
328-
37.0,
329-
1.0
330-
]
331-
],
187+
"stroke-color": "#3399CC",
332188
"stroke-width": 1.25
333189
},
334190
"opacity": 1.0,
335191
"source": "578fb13e-9c82-4711-91f2-fb3671820583",
336192
"symbologyState": {
337193
"colorRamp": "viridis",
338-
"method": "radius",
194+
"method": "color",
339195
"mode": "quantile",
340196
"nClasses": "9",
341197
"renderType": "Graduated",
198+
"reverse": false,
342199
"value": "mag"
343200
}
344201
},

packages/base/src/dialogs/symbology/vector_layer/types/Graduated.tsx

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ const Graduated: React.FC<ISymbologyTabbedDialogWithAttributesProps> = ({
4444
ColorRampOptions | undefined
4545
>();
4646
const [colorManualStyle, setColorManualStyle] = useState({
47-
fillColor: '#3399CC',
4847
strokeColor: '#3399CC',
4948
strokeWidth: 1.25,
5049
});
@@ -80,20 +79,13 @@ const Graduated: React.FC<ISymbologyTabbedDialogWithAttributesProps> = ({
8079

8180
useEffect(() => {
8281
if (layer?.parameters?.color) {
83-
const fillColor = layer.parameters.color['fill-color'];
84-
const circleFillColor = layer.parameters.color['circle-fill-color'];
8582
const strokeColor = layer.parameters.color['stroke-color'];
8683
const circleStrokeColor = layer.parameters.color['circle-stroke-color'];
8784

8885
const isSimpleColor = (val: any) =>
8986
typeof val === 'string' && /^#?[0-9A-Fa-f]{3,8}$/.test(val);
9087

9188
setColorManualStyle({
92-
fillColor: isSimpleColor(fillColor)
93-
? fillColor
94-
: isSimpleColor(circleFillColor)
95-
? circleFillColor
96-
: '#3399CC',
9789
strokeColor: isSimpleColor(strokeColor)
9890
? strokeColor
9991
: isSimpleColor(circleStrokeColor)
@@ -170,12 +162,11 @@ const Graduated: React.FC<ISymbologyTabbedDialogWithAttributesProps> = ({
170162
newStyle['stroke-color'] = colorExpr;
171163
newStyle['circle-stroke-color'] = colorExpr;
172164
} else {
173-
newStyle['fill-color'] = undefined;
174-
newStyle['circle-fill-color'] = undefined;
175-
newStyle['stroke-color'] = colorManualStyleRef.current.strokeColor;
176-
newStyle['circle-stroke-color'] = colorManualStyleRef.current.strokeColor;
165+
// use manual style
177166
}
178167

168+
newStyle['stroke-color'] = colorManualStyleRef.current.strokeColor;
169+
newStyle['circle-stroke-color'] = colorManualStyleRef.current.strokeColor;
179170
newStyle['stroke-width'] = colorManualStyleRef.current.strokeWidth;
180171
newStyle['circle-stroke-width'] = colorManualStyleRef.current.strokeWidth;
181172

@@ -290,9 +281,7 @@ const Graduated: React.FC<ISymbologyTabbedDialogWithAttributesProps> = ({
290281
const newStyle = { ...layer.parameters.color };
291282

292283
if (method === 'color') {
293-
delete newStyle['fill-color'];
294284
delete newStyle['stroke-color'];
295-
delete newStyle['circle-fill-color'];
296285
setColorStopRows([]);
297286
setColorRampOptions(undefined);
298287
}
@@ -325,21 +314,11 @@ const Graduated: React.FC<ISymbologyTabbedDialogWithAttributesProps> = ({
325314
<div className="jp-gis-layer-symbology-container">
326315
{symbologyTab === 'color' && (
327316
<>
328-
<div className="jp-gis-symbology-row">
329-
<label>Fill Color:</label>
330-
<input
331-
type="color"
332-
className="jp-mod-styled"
333-
value={colorManualStyle.fillColor}
334-
onChange={e => {
335-
handleReset('color');
336-
setColorManualStyle({
337-
...colorManualStyle,
338-
fillColor: e.target.value,
339-
});
340-
}}
341-
/>
342-
</div>
317+
<p className="jp-info-text">
318+
Fill color is automatically controlled by the color ramp. To
319+
control fill manually, switch to <strong>Simple</strong>{' '}
320+
symbology.
321+
</p>
343322
<div className="jp-gis-symbology-row">
344323
<label>Stroke Color:</label>
345324
<input

0 commit comments

Comments
 (0)