Skip to content

Commit dd4932a

Browse files
committed
Improve primitive geo docs
1 parent 4a93215 commit dd4932a

1 file changed

Lines changed: 33 additions & 27 deletions

File tree

docs/src/content/guides/primitives.md

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,21 @@ Each circle's fill is determined by its `category` value, resolved through the c
234234

235235
## Geo Mode
236236

237-
When a primitive is placed inside a `GeoProjection` context, positional x/y props automatically resolve through the geo projection instead of chart scales. This means you can plot geographic data directly with primitives — no wrapper component needed.
237+
When a primitive is placed inside a `Chart` with the `geo` prop, positional x/y props automatically resolve through the geo projection instead of chart scales. This means you can plot geographic data directly with primitives — no wrapper component needed.
238238

239239
```svelte
240-
<Chart {data} r="population" rRange={[2, 20]} c="region" cRange={['steelblue', 'coral']}>
241-
<GeoProjection projection={geoNaturalEarth1} fitGeojson={geojson}>
242-
<Svg>
243-
<GeoPath {geojson} class="fill-surface-200 stroke-surface-content/20" />
244-
<Circle cx="longitude" cy="latitude" r="population" fill="region" />
245-
</Svg>
246-
</GeoProjection>
240+
<Chart
241+
{data}
242+
r="population"
243+
rRange={[2, 20]}
244+
c="region"
245+
cRange={['steelblue', 'coral']}
246+
geo={{ projection: geoNaturalEarth1, fitGeojson: geojson }}
247+
>
248+
<Svg>
249+
<GeoPath {geojson} class="fill-surface-200 stroke-surface-content/20" />
250+
<Circle cx="longitude" cy="latitude" r="population" fill="region" />
251+
</Svg>
247252
</Chart>
248253
```
249254

@@ -255,22 +260,20 @@ When a primitive is placed inside a `GeoProjection` context, positional x/y prop
255260

256261
### Projection Mapping
257262

258-
| Prop pairs (projected together) | Non-geo props (unchanged) |
259-
| -------------------------------- | -------------------------------- |
260-
| `cx`/`cy`, `x`/`y` | `r`, `rx`, `ry` |
261-
| `x1`/`y1`, `x2`/`y2` | `width`, `height` |
262-
| `x0`/`y0`, `x1`/`y1` (Rect) | `fill`, `stroke` |
263+
| Prop pairs (projected together) | Non-geo props (unchanged) |
264+
| ------------------------------- | ------------------------- |
265+
| `cx`/`cy`, `x`/`y` | `r`, `rx`, `ry` |
266+
| `x1`/`y1`, `x2`/`y2` | `width`, `height` |
267+
| `x0`/`y0`, `x1`/`y1` (Rect) | `fill`, `stroke` |
263268

264269
### Example: Airports on a Globe
265270

266271
```svelte
267-
<Chart data={airports}>
268-
<GeoProjection projection={geoOrthographic} fitGeojson={geojson}>
269-
<Svg>
270-
<GeoPath {geojson} class="fill-surface-200 stroke-surface-content/20" />
271-
<Circle cx="longitude" cy="latitude" r={2} class="fill-primary" />
272-
</Svg>
273-
</GeoProjection>
272+
<Chart data={airports} geo={{ projection: geoOrthographic, fitGeojson: geojson }}>
273+
<Svg>
274+
<GeoPath {geojson} class="fill-surface-200 stroke-surface-content/20" />
275+
<Circle cx="longitude" cy="latitude" r={2} class="fill-primary" />
276+
</Svg>
274277
</Chart>
275278
```
276279

@@ -281,12 +284,15 @@ Each airport's `longitude` and `latitude` properties are projected through the g
281284
[Spline](/docs/components/Spline) also supports geo mode. When a projection is set, it automatically converts data into a GeoJSON `LineString` and renders via `geoPath` — giving proper geodesic interpolation and antimeridian handling.
282285

283286
```svelte
284-
<Chart data={voyageData} x="longitude" y="latitude">
285-
<GeoProjection projection={geoNaturalEarth1} fitGeojson={geojson}>
286-
<Svg>
287-
<GeoPath {geojson} class="fill-surface-200 stroke-surface-content/20" />
288-
<Spline class="fill-none stroke-primary" />
289-
</Svg>
290-
</GeoProjection>
287+
<Chart
288+
data={voyageData}
289+
x="longitude"
290+
y="latitude"
291+
geo={{ projection: geoNaturalEarth1, fitGeojson: geojson }}
292+
>
293+
<Svg>
294+
<GeoPath {geojson} class="fill-surface-200 stroke-surface-content/20" />
295+
<Spline class="fill-none stroke-primary" />
296+
</Svg>
291297
</Chart>
292298
```

0 commit comments

Comments
 (0)