@graphenedata/cli 0.0.3 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.ts +7 -43
- package/dist/cli/cli.js +509 -277
- package/dist/docs/graphene.md +924 -63
- package/dist/ui/component-utilities/echarts.js +3 -1
- package/dist/ui/component-utilities/themeStores.ts +35 -7
- package/dist/ui/components/AreaChart.svelte +2 -1
- package/dist/ui/components/BarChart.svelte +2 -1
- package/dist/ui/components/BigValue.svelte +1 -1
- package/dist/ui/components/Chart.svelte +10 -1
- package/dist/ui/components/ECharts.svelte +2 -0
- package/dist/ui/components/LineChart.svelte +2 -1
- package/dist/ui/components/PieChart.svelte +1 -1
- package/dist/ui/components/QueryLoad.svelte +5 -6
- package/dist/ui/components/TableRow.svelte +1 -1
- package/dist/ui/components/_Table.svelte +2 -0
- package/dist/ui/internal/queryEngine.ts +16 -13
- package/dist/ui/internal/telemetry.ts +5 -3
- package/dist/ui/web.js +26 -11
- package/package.json +2 -1
- package/dist/docs/data_apps/components/charts/annotations.md +0 -673
- package/dist/docs/data_apps/components/charts/area-chart.md +0 -202
- package/dist/docs/data_apps/components/charts/bar-chart.md +0 -317
- package/dist/docs/data_apps/components/charts/box-plot.md +0 -190
- package/dist/docs/data_apps/components/charts/bubble-chart.md +0 -151
- package/dist/docs/data_apps/components/charts/calendar-heatmap.md +0 -112
- package/dist/docs/data_apps/components/charts/custom-echarts.md +0 -308
- package/dist/docs/data_apps/components/charts/echarts-options.md +0 -217
- package/dist/docs/data_apps/components/charts/funnel-chart.md +0 -106
- package/dist/docs/data_apps/components/charts/heatmap.md +0 -180
- package/dist/docs/data_apps/components/charts/histogram.md +0 -107
- package/dist/docs/data_apps/components/charts/line-chart.md +0 -265
- package/dist/docs/data_apps/components/charts/mixed-type-charts.md +0 -240
- package/dist/docs/data_apps/components/charts/sankey-diagram.md +0 -301
- package/dist/docs/data_apps/components/charts/scatter-plot.md +0 -134
- package/dist/docs/data_apps/components/charts/sparkline.md +0 -68
- package/dist/docs/data_apps/components/data/big-value.md +0 -153
- package/dist/docs/data_apps/components/data/delta.md +0 -89
- package/dist/docs/data_apps/components/data/table.md +0 -470
- package/dist/docs/data_apps/components/data/value.md +0 -97
- package/dist/docs/data_apps/components/inputs/button-group.md +0 -154
- package/dist/docs/data_apps/components/inputs/checkbox.md +0 -52
- package/dist/docs/data_apps/components/inputs/date-input.md +0 -131
- package/dist/docs/data_apps/components/inputs/date-range.md +0 -124
- package/dist/docs/data_apps/components/inputs/dimension-grid.md +0 -67
- package/dist/docs/data_apps/components/inputs/dropdown.md +0 -199
- package/dist/docs/data_apps/components/inputs/index.md +0 -3
- package/dist/docs/data_apps/components/inputs/slider.md +0 -126
- package/dist/docs/data_apps/components/inputs/text-input.md +0 -86
- package/dist/docs/data_apps/components/maps/area-map.md +0 -397
- package/dist/docs/data_apps/components/maps/base-map.md +0 -269
- package/dist/docs/data_apps/components/maps/bubble-map.md +0 -361
- package/dist/docs/data_apps/components/maps/point-map.md +0 -326
- package/dist/docs/data_apps/components/maps/us-map.md +0 -167
- package/dist/docs/data_apps/components/ui/accordion.md +0 -116
- package/dist/docs/data_apps/components/ui/alert.md +0 -37
- package/dist/docs/data_apps/components/ui/big-link.md +0 -19
- package/dist/docs/data_apps/components/ui/details.md +0 -58
- package/dist/docs/data_apps/components/ui/download-data.md +0 -41
- package/dist/docs/data_apps/components/ui/embed.md +0 -47
- package/dist/docs/data_apps/components/ui/grid.md +0 -45
- package/dist/docs/data_apps/components/ui/image.md +0 -61
- package/dist/docs/data_apps/components/ui/info.md +0 -47
- package/dist/docs/data_apps/components/ui/last-refreshed.md +0 -28
- package/dist/docs/data_apps/components/ui/link-button.md +0 -20
- package/dist/docs/data_apps/components/ui/link.md +0 -40
- package/dist/docs/data_apps/components/ui/modal.md +0 -57
- package/dist/docs/data_apps/components/ui/note.md +0 -32
- package/dist/docs/data_apps/components/ui/print-format-components.md +0 -85
- package/dist/docs/data_apps/components/ui/tabs.md +0 -122
|
@@ -1,397 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Area Map
|
|
3
|
-
description: Compare a metric across different regions on a map using a choropleth map
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
Compare a metric across different regions on a map using a choropleth map
|
|
7
|
-
|
|
8
|
-
**Example:**
|
|
9
|
-
|
|
10
|
-
```svelte
|
|
11
|
-
<AreaMap
|
|
12
|
-
data="la_zip_sales"
|
|
13
|
-
areaCol=zip_code
|
|
14
|
-
geoJsonUrl='path/to/your/geoJson'
|
|
15
|
-
geoId=ZCTA5CE10
|
|
16
|
-
value=sales
|
|
17
|
-
valueFmt=usd
|
|
18
|
-
height=250
|
|
19
|
-
/>
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
## Examples
|
|
24
|
-
|
|
25
|
-
### Custom Basemap
|
|
26
|
-
You can add a different basemap by passing in a basemap URL. You can find examples here: https://leaflet-extras.github.io/leaflet-providers/preview/
|
|
27
|
-
|
|
28
|
-
**Example:**
|
|
29
|
-
|
|
30
|
-
**Note:** you need to wrap the url in curly braces and backticks to avoid the curly braces in the URL being read as variables on your page
|
|
31
|
-
|
|
32
|
-
```svelte
|
|
33
|
-
<AreaMap
|
|
34
|
-
data="la_zip_sales"
|
|
35
|
-
areaCol=zip_code
|
|
36
|
-
geoJsonUrl='path/to/your/geoJson'
|
|
37
|
-
geoId=ZCTA5CE10
|
|
38
|
-
value=sales
|
|
39
|
-
valueFmt=usd
|
|
40
|
-
height=250
|
|
41
|
-
basemap="`https://tile.openstreetmap.org/{z"/{x}/{y}.png`}
|
|
42
|
-
/>
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### Using an Online GeoJSON
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
**Example:**
|
|
49
|
-
|
|
50
|
-
```svelte
|
|
51
|
-
<AreaMap
|
|
52
|
-
data="orders_by_state"
|
|
53
|
-
areaCol=state
|
|
54
|
-
geoJsonUrl=https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_110m_admin_1_states_provinces.geojson
|
|
55
|
-
geoId=name
|
|
56
|
-
value=orders
|
|
57
|
-
/>
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
### Custom Tooltip
|
|
61
|
-
|
|
62
|
-
#### `tooltipType=hover`
|
|
63
|
-
|
|
64
|
-
**Example:**
|
|
65
|
-
|
|
66
|
-
```svelte
|
|
67
|
-
<AreaMap
|
|
68
|
-
data="la_zip_sales"
|
|
69
|
-
areaCol=zip_code
|
|
70
|
-
geoJsonUrl='path/to/your/geoJson'
|
|
71
|
-
geoId=ZCTA5CE10
|
|
72
|
-
value=sales
|
|
73
|
-
valueFmt=usd
|
|
74
|
-
height=250
|
|
75
|
-
tooltip="[
|
|
76
|
-
{id: 'zip_code', fmt: 'id', showColumnName: false, valueClass: 'text-xl font-semibold'",
|
|
77
|
-
{id: 'sales', fmt: 'eur', fieldClass: 'text-[grey]', valueClass: 'text-[green]'}
|
|
78
|
-
]}
|
|
79
|
-
/>
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
#### With clickable link and `tooltipType=click`
|
|
83
|
-
|
|
84
|
-
**Example:**
|
|
85
|
-
|
|
86
|
-
```svelte
|
|
87
|
-
<AreaMap
|
|
88
|
-
data="la_zip_sales"
|
|
89
|
-
areaCol=zip_code
|
|
90
|
-
geoJsonUrl='path/to/your/geoJson'
|
|
91
|
-
geoId=ZCTA5CE10
|
|
92
|
-
value=sales
|
|
93
|
-
valueFmt=usd
|
|
94
|
-
height=250
|
|
95
|
-
tooltipType=click
|
|
96
|
-
tooltip="[
|
|
97
|
-
{id: 'zip_code', fmt: 'id', showColumnName: false, valueClass: 'text-xl font-semibold'",
|
|
98
|
-
{id: 'sales', fmt: 'eur', fieldClass: 'text-[grey]', valueClass: 'text-[green]'},
|
|
99
|
-
{id: 'link_col', showColumnName: false, contentType: 'link', linkLabel: 'Click here', valueClass: 'font-bold mt-1'}
|
|
100
|
-
]}
|
|
101
|
-
/>
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### Custom Styling
|
|
105
|
-
|
|
106
|
-
**Example:**
|
|
107
|
-
|
|
108
|
-
```svelte
|
|
109
|
-
<AreaMap
|
|
110
|
-
data="la_zip_sales"
|
|
111
|
-
areaCol=zip_code
|
|
112
|
-
geoJsonUrl='path/to/your/geoJson'
|
|
113
|
-
geoId=ZCTA5CE10
|
|
114
|
-
value=sales
|
|
115
|
-
valueFmt=usd
|
|
116
|
-
height=250
|
|
117
|
-
color=#fff5d9
|
|
118
|
-
borderColor=#737373
|
|
119
|
-
borderWidth=0.5
|
|
120
|
-
/>
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
### Custom Color Palette
|
|
124
|
-
|
|
125
|
-
**Example:**
|
|
126
|
-
|
|
127
|
-
```svelte
|
|
128
|
-
<AreaMap
|
|
129
|
-
data="la_zip_sales"
|
|
130
|
-
areaCol=zip_code
|
|
131
|
-
geoJsonUrl='path/to/your/geoJson'
|
|
132
|
-
geoId=ZCTA5CE10
|
|
133
|
-
value=sales
|
|
134
|
-
valueFmt=usd
|
|
135
|
-
height=250
|
|
136
|
-
colorPalette="[
|
|
137
|
-
['yellow', 'yellow'],
|
|
138
|
-
['orange', 'orange'],
|
|
139
|
-
['red', 'red'],
|
|
140
|
-
['darkred', 'darkred'],
|
|
141
|
-
]"
|
|
142
|
-
/>
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### Link Drilldown
|
|
146
|
-
Pass in a `link` column to enable navigation on click of the point. These can be absolute or relative URLs
|
|
147
|
-
|
|
148
|
-
**Example:**
|
|
149
|
-
|
|
150
|
-
```svelte
|
|
151
|
-
<AreaMap
|
|
152
|
-
data="la_zip_sales"
|
|
153
|
-
areaCol=zip_code
|
|
154
|
-
geoJsonUrl='path/to/your/geoJson'
|
|
155
|
-
geoId=ZCTA5CE10
|
|
156
|
-
value=sales
|
|
157
|
-
valueFmt=usd
|
|
158
|
-
height=250
|
|
159
|
-
link=link_col
|
|
160
|
-
/>
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
### Use Map as Input
|
|
164
|
-
Use the `name` prop to set an input name for the map - when a point is clicked, it will set the input value to that row of data
|
|
165
|
-
|
|
166
|
-
**Example:**
|
|
167
|
-
|
|
168
|
-
```svelte
|
|
169
|
-
<AreaMap
|
|
170
|
-
data="la_zip_sales"
|
|
171
|
-
areaCol=zip_code
|
|
172
|
-
geoJsonUrl='path/to/your/geoJson'
|
|
173
|
-
geoId=ZCTA5CE10
|
|
174
|
-
value=sales
|
|
175
|
-
valueFmt=usd
|
|
176
|
-
height=250
|
|
177
|
-
name=my_area_map
|
|
178
|
-
/>
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
*Click an area on the map to see the input value get updated:*
|
|
182
|
-
|
|
183
|
-
#### Selected value for `{inputs.my_area_map}`:
|
|
184
|
-
|
|
185
|
-
<pre class="text-sm">{JSON.stringify(inputs.my_area_map, null, 2)}</pre>
|
|
186
|
-
|
|
187
|
-
#### Selected value for `{inputs.my_area_map.zip_code}`:
|
|
188
|
-
|
|
189
|
-
{inputs.my_area_map.zip_code}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
#### Filtered Data
|
|
193
|
-
<DataTable data="filtered_areas">
|
|
194
|
-
<Column id=id/>
|
|
195
|
-
<Column id=zip_code fmt=id/>
|
|
196
|
-
<Column id=sales fmt=usd/>
|
|
197
|
-
</DataTable>
|
|
198
|
-
|
|
199
|
-
### Legends
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
#### Categorical Legend
|
|
203
|
-
|
|
204
|
-
**Example:**
|
|
205
|
-
|
|
206
|
-
```svelte
|
|
207
|
-
<AreaMap
|
|
208
|
-
data="grouped_locations"
|
|
209
|
-
lat=lat
|
|
210
|
-
long=long
|
|
211
|
-
value=Category
|
|
212
|
-
geoId=ZCTA5CE10
|
|
213
|
-
areaCol=zip_code
|
|
214
|
-
/>
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
#### Custom Colors
|
|
218
|
-
Set custom legend colors using the `colorPalette` prop to match the number of categories; excess categorical options will default to standard colors.
|
|
219
|
-
|
|
220
|
-
**Example:**
|
|
221
|
-
|
|
222
|
-
```svelte
|
|
223
|
-
<AreaMap
|
|
224
|
-
data="grouped_locations"
|
|
225
|
-
lat=lat
|
|
226
|
-
long=long
|
|
227
|
-
value=Category
|
|
228
|
-
geoId=ZCTA5CE10
|
|
229
|
-
areaCol=zip_code
|
|
230
|
-
colorPalette={['#C65D47', '#5BAF7A', '#4A8EBA', '#D35B85', '#E1C16D', '#6F5B9A', '#4E8D8D']}
|
|
231
|
-
/>
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
#### Scalar Legend
|
|
235
|
-
|
|
236
|
-
**Example:**
|
|
237
|
-
|
|
238
|
-
```svelte
|
|
239
|
-
<AreaMap
|
|
240
|
-
data="grouped_locations"
|
|
241
|
-
lat=lat
|
|
242
|
-
long=long
|
|
243
|
-
value=sales
|
|
244
|
-
geoId=ZCTA5CE10
|
|
245
|
-
areaCol=zip_code
|
|
246
|
-
valueFmt=usd
|
|
247
|
-
/>
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
#### Custom Colors
|
|
251
|
-
Define scalar legend colors using the `colorPalette` prop, allowing specified colors to create a gradient based on the range of values.
|
|
252
|
-
|
|
253
|
-
**Example:**
|
|
254
|
-
|
|
255
|
-
```svelte
|
|
256
|
-
<AreaMap
|
|
257
|
-
data="grouped_locations"
|
|
258
|
-
lat=lat
|
|
259
|
-
long=long
|
|
260
|
-
value=sales
|
|
261
|
-
geoId=ZCTA5CE10
|
|
262
|
-
areaCol=zip_code
|
|
263
|
-
colorPalette={['#C65D47', '#4A8EBA']}
|
|
264
|
-
valueFmt=usd
|
|
265
|
-
/>
|
|
266
|
-
```
|
|
267
|
-
|
|
268
|
-
## Required GeoJSON Data Structure
|
|
269
|
-
The GeoJSON data you pass to the map must be a feature collection. [See here for an example](https://gist.github.com/sgillies/1233327#file-geojson-spec-1-0-L50)
|
|
270
|
-
|
|
271
|
-
## Map Resources
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
Below are a selection of publically available GeoJSON files that may be useful for mapping. These are from the [Natural Earth Data](https://www.naturalearthdata.com) project, and hosted by [GeoJSON.xyz](https://geojson.xyz).
|
|
275
|
-
|
|
276
|
-
### Country, State, and City Locations
|
|
277
|
-
|
|
278
|
-
<DataTable data="useful_geojson_urls" rows=100>
|
|
279
|
-
<Column id=file/>
|
|
280
|
-
<Column id=category/>
|
|
281
|
-
<Column id=scale/>
|
|
282
|
-
<Column id=summary/>
|
|
283
|
-
<Column id=size fmt='0.0,," MB"'/>
|
|
284
|
-
<Column id=url contentType=link title=URL/>
|
|
285
|
-
</DataTable>
|
|
286
|
-
|
|
287
|
-
<Details title="All GeoJSON Files">
|
|
288
|
-
|
|
289
|
-
<DataTable data="all_geojson_urls" rows=all compact>
|
|
290
|
-
<Column id=file/>
|
|
291
|
-
<Column id=category/>
|
|
292
|
-
<Column id=scale/>
|
|
293
|
-
<Column id=summary/>
|
|
294
|
-
<Column id=size fmt='0.0,," MB"'/>
|
|
295
|
-
<Column id=url contentType=link title=URL/>
|
|
296
|
-
</DataTable>
|
|
297
|
-
|
|
298
|
-
</Details>
|
|
299
|
-
|
|
300
|
-
## Options
|
|
301
|
-
|
|
302
|
-
### Areas
|
|
303
|
-
|
|
304
|
-
| Property | Description | Required | Options |
|
|
305
|
-
|----------|-------------|----------|---------|
|
|
306
|
-
| data | Query result, referenced using curly braces | true | query name |
|
|
307
|
-
| geoJsonUrl | Path to source geoJSON data from - can be a URL (see Map Resources) or a file in your project. If the file is in your `static` directory in the root of your project, reference it as `geoJsonUrl="/your_file.geojson"` | true | URL |
|
|
308
|
-
| areaCol | Column in the data that specifies the area each row belongs to. | true | column name |
|
|
309
|
-
| geoId | Property in the GeoJSON that uniquely identifies each feature. | true | geoJSON property name |
|
|
310
|
-
| value | Column that determines the value displayed for each area (used for color scale) | false | column name |
|
|
311
|
-
| valueFmt | Format string for displaying the value. | false | format string |
|
|
312
|
-
| title | Title for the map | false | string |
|
|
313
|
-
| subtitle | Subtitle - appears under the title | false | string |
|
|
314
|
-
| ignoreZoom | Stops map from zooming out to show all data for this layer | false | true, false | false |
|
|
315
|
-
|
|
316
|
-
### Color Scale
|
|
317
|
-
|
|
318
|
-
| Property | Description | Options | Default |
|
|
319
|
-
|----------|-------------|---------|---------|
|
|
320
|
-
| colorPalette | Array of colors used for theming the areas based on data | array of colors | - |
|
|
321
|
-
| min | Minimum value to use for the color scale. | number | min of value column |
|
|
322
|
-
| max | Maximum value to use for the color scale. | number | max of value column |
|
|
323
|
-
|
|
324
|
-
### Legend
|
|
325
|
-
|
|
326
|
-
| Property | Description | Required | Options | Default |
|
|
327
|
-
|----------|-------------|----------|---------|---------|
|
|
328
|
-
| legend | Turns legend on or off | false | true, false | true |
|
|
329
|
-
| legendType | Appends a categorical or scalar legend to the map | false | categorical, scalar | - |
|
|
330
|
-
| legendPosition | Determines the legend's position on the map, with options provided | false | bottomLeft, topLeft, bottomRight, topRight | bottomLeft |
|
|
331
|
-
|
|
332
|
-
### Interactivity
|
|
333
|
-
|
|
334
|
-
| Property | Description | Options |
|
|
335
|
-
|----------|-------------|---------|
|
|
336
|
-
| link | URL to navigate to when a area is clicked. | URL |
|
|
337
|
-
| name | Input name. Can be referenced on your page with `{inputs.my_input_name}` | string |
|
|
338
|
-
|
|
339
|
-
### Styling
|
|
340
|
-
|
|
341
|
-
| Property | Description | Options | Default |
|
|
342
|
-
|----------|-------------|---------|---------|
|
|
343
|
-
| color | Color for the areas. Use when you want all areas to be the same color. | CSS color value | - |
|
|
344
|
-
| borderWidth | Width of the border around each area. | pixel value | 0.75 |
|
|
345
|
-
| borderColor | Color of the border around each area. | CSS color value | white |
|
|
346
|
-
| opacity | Opacity of the areas. | number between 0 and 1 | 0.8 |
|
|
347
|
-
|
|
348
|
-
### Selected State
|
|
349
|
-
|
|
350
|
-
| Property | Description | Options | Default |
|
|
351
|
-
|----------|-------------|---------|---------|
|
|
352
|
-
| selectedColor | When area is selected: Color for the areas. Use when you want all areas to be the same color. | CSS color value | - |
|
|
353
|
-
| selectedBorderWidth | When area is selected: Width of the border around each area. | pixel value | 0.75 |
|
|
354
|
-
| selectedBorderColor | When area is selected: Color of the border around each area. | CSS color value | white |
|
|
355
|
-
| selectedOpacity | When area is selected: Opacity of the areas. | number between 0 and 1 | 0.8 |
|
|
356
|
-
|
|
357
|
-
### Tooltips
|
|
358
|
-
|
|
359
|
-
| Property | Description | Options | Default |
|
|
360
|
-
|----------|-------------|---------|---------|
|
|
361
|
-
| showTooltip | Whether to show tooltips | true, false | true |
|
|
362
|
-
| tooltipType | Determines whether tooltips are activated by hover or click. | hover, click | hover |
|
|
363
|
-
| tooltipClass | CSS class applied to the tooltip content. You can pass Tailwind classes into this prop to custom-style the tooltip | CSS class | - |
|
|
364
|
-
| tooltip | Configuration for tooltips associated with each area. See below example for format | array of objects | - |
|
|
365
|
-
|
|
366
|
-
#### `tooltip` example:
|
|
367
|
-
|
|
368
|
-
```javascript
|
|
369
|
-
tooltip="[
|
|
370
|
-
{id: 'zip_code', fmt: 'id', showColumnName: false, valueClass: 'text-xl font-semibold'",
|
|
371
|
-
{id: 'sales', fmt: 'eur', fieldClass: 'text-[grey]', valueClass: 'text-[green]'},
|
|
372
|
-
{id: 'zip_code', showColumnName: false, contentType: 'link', linkLabel: 'Click here', valueClass: 'font-bold mt-1'}
|
|
373
|
-
]}
|
|
374
|
-
```
|
|
375
|
-
|
|
376
|
-
#### All options available in `tooltip`:
|
|
377
|
-
- `id`: column ID
|
|
378
|
-
- `title`: custom string to use as title of field
|
|
379
|
-
- `fmt`: format to use for value
|
|
380
|
-
- `showColumnName`: whether to show the column name. If `false`, only the value will be shown
|
|
381
|
-
- `contentType`: currently can only be "link"
|
|
382
|
-
- `linkLabel`: text to show for a link when contentType="link"
|
|
383
|
-
- `formatColumnTitle`: whether to automatically uppercase the first letter of the title. Only applies when `title` not passed explicitly
|
|
384
|
-
- `valueClass`: custom Tailwind classes to style the values
|
|
385
|
-
- `fieldClass`: custom Tailwind classes to style the column names
|
|
386
|
-
|
|
387
|
-
### Base Map
|
|
388
|
-
|
|
389
|
-
| Property | Description | Options |
|
|
390
|
-
|----------|-------------|---------|
|
|
391
|
-
| basemap | URL template for the basemap tiles. | URL |
|
|
392
|
-
| attribution | Attribution text to display on the map (e.g., "© OpenStreetMap contributors"). | text |
|
|
393
|
-
| title | Optional title displayed above the map. | text |
|
|
394
|
-
| startingLat | Starting latitude for the map center. | latitude coordinate |
|
|
395
|
-
| startingLong | Starting longitude for the map center. | longitude coordinate |
|
|
396
|
-
| startingZoom | Initial zoom level of the map. | number (1 to 18) |
|
|
397
|
-
| height | Height of the map in pixels. | pixel value | 300 |
|
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: Base Map
|
|
3
|
-
description: Combine multiple map layers including areas, points, and bubbles.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
Combine multiple map layers including areas, points, and bubbles.
|
|
7
|
-
|
|
8
|
-
**Example:**
|
|
9
|
-
|
|
10
|
-
```html
|
|
11
|
-
<BaseMap>
|
|
12
|
-
<Areas data="la_zip_sales" geoId=ZCTA5CE10 areaCol=zip_code value=sales valueFmt=usd/>
|
|
13
|
-
<Points data="la_locations" lat=lat long=long color=#179917/>
|
|
14
|
-
</BaseMap>
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
## Overview
|
|
19
|
-
The BaseMap component provides a flexible and extensible way to create maps with multiple layers. This component serves as the foundation for AreaMap, PointMap, and BubbleMap.
|
|
20
|
-
|
|
21
|
-
Within BaseMap, you can add layers using the following components:
|
|
22
|
-
- `<Areas/>`
|
|
23
|
-
- `<Points/>`
|
|
24
|
-
- `<Bubbles/>`
|
|
25
|
-
|
|
26
|
-
## Examples
|
|
27
|
-
|
|
28
|
-
See the pages for [Area Map](/components/maps/area-map), [Point Map](/components/maps/point-map), and [Bubble Map](/components/maps/bubble-map) for examples specific to those layers. The same options can be applied to the layer components within BaseMap.
|
|
29
|
-
|
|
30
|
-
### Adding Multiple Layers
|
|
31
|
-
|
|
32
|
-
**Example:**
|
|
33
|
-
|
|
34
|
-
```svelte
|
|
35
|
-
<BaseMap>
|
|
36
|
-
<Areas
|
|
37
|
-
data="la_zip_sales"
|
|
38
|
-
areaCol=zip_code
|
|
39
|
-
geoJsonUrl="path/to/your/geoJSON"
|
|
40
|
-
geoId=ZCTA5CE10
|
|
41
|
-
value=sales
|
|
42
|
-
valueFmt=usd
|
|
43
|
-
/>
|
|
44
|
-
<Bubbles
|
|
45
|
-
data="la_locations"
|
|
46
|
-
lat=lat
|
|
47
|
-
long=long
|
|
48
|
-
size=sales
|
|
49
|
-
sizeFmt=usd
|
|
50
|
-
value=sales
|
|
51
|
-
valueFmt=usd
|
|
52
|
-
pointName=point_name
|
|
53
|
-
colorPalette={['yellow','orange','red','darkred']}
|
|
54
|
-
opacity=0.5
|
|
55
|
-
/>
|
|
56
|
-
</BaseMap>
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### Custom Basemap
|
|
60
|
-
You can add a different basemap by passing in a basemap URL. You can find examples here: https://leaflet-extras.github.io/leaflet-providers/preview/
|
|
61
|
-
|
|
62
|
-
**Example:**
|
|
63
|
-
|
|
64
|
-
```svelte
|
|
65
|
-
<BaseMap basemap="`https://tile.openstreetmap.org/{z"/{x}/{y}.png`} attribution='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'>
|
|
66
|
-
<Points
|
|
67
|
-
data="la_locations"
|
|
68
|
-
lat=lat
|
|
69
|
-
long=long
|
|
70
|
-
value=sales
|
|
71
|
-
valueFmt=usd
|
|
72
|
-
pointName=point_name
|
|
73
|
-
color=violet
|
|
74
|
-
borderColor=black
|
|
75
|
-
borderWidth=2
|
|
76
|
-
/>
|
|
77
|
-
</BaseMap>
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### Custom Tooltip
|
|
81
|
-
|
|
82
|
-
#### `tooltipType=hover`
|
|
83
|
-
|
|
84
|
-
**Example:**
|
|
85
|
-
|
|
86
|
-
```svelte
|
|
87
|
-
<BaseMap>
|
|
88
|
-
<Areas
|
|
89
|
-
data="la_zip_sales"
|
|
90
|
-
areaCol=zip_code
|
|
91
|
-
geoJsonUrl='/geo-json/ca_california_zip_codes_geo_1.min.json'
|
|
92
|
-
geoId=ZCTA5CE10
|
|
93
|
-
value=sales
|
|
94
|
-
valueFmt=usd
|
|
95
|
-
height=250
|
|
96
|
-
tooltip="[
|
|
97
|
-
{id: 'zip_code', fmt: 'id', showColumnName: false, valueClass: 'text-xl font-semibold'",
|
|
98
|
-
{id: 'sales', fmt: 'eur', fieldClass: 'text-[grey]', valueClass: 'text-[green]'},
|
|
99
|
-
{id: 'zip_code', showColumnName: false, contentType: 'link', linkLabel: 'Click here', valueClass: 'font-bold mt-1'}
|
|
100
|
-
]}
|
|
101
|
-
/>
|
|
102
|
-
</BaseMap>
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
#### With clickable link and `tooltipType=click`
|
|
106
|
-
|
|
107
|
-
**Example:**
|
|
108
|
-
|
|
109
|
-
```svelte
|
|
110
|
-
<BaseMap>
|
|
111
|
-
<Areas
|
|
112
|
-
data="la_zip_sales"
|
|
113
|
-
areaCol=zip_code
|
|
114
|
-
geoJsonUrl='/geo-json/ca_california_zip_codes_geo_1.min.json'
|
|
115
|
-
geoId=ZCTA5CE10
|
|
116
|
-
value=sales
|
|
117
|
-
valueFmt=usd
|
|
118
|
-
height=250
|
|
119
|
-
tooltipType=click
|
|
120
|
-
tooltip="[
|
|
121
|
-
{id: 'zip_code', fmt: 'id', showColumnName: false, valueClass: 'text-xl font-semibold'",
|
|
122
|
-
{id: 'sales', fmt: 'eur', fieldClass: 'text-[grey]', valueClass: 'text-[green]'},
|
|
123
|
-
{id: 'link_col', showColumnName: false, contentType: 'link', linkLabel: 'Click here', valueClass: 'font-bold mt-1'}
|
|
124
|
-
]}
|
|
125
|
-
/>
|
|
126
|
-
</BaseMap>
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
## Map Resources
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
Below are a selection of publically available GeoJSON files that may be useful for mapping. These are from the [Natural Earth Data](https://www.naturalearthdata.com) project, and hosted by [GeoJSON.xyz](https://geojson.xyz).
|
|
133
|
-
|
|
134
|
-
### Country, State, and City Locations
|
|
135
|
-
|
|
136
|
-
| file | category | scale | summary | size | url |
|
|
137
|
-
|------|----------|-------|---------|------|-----|
|
|
138
|
-
| {useful_geojson_urls.file} | {useful_geojson_urls.category} | {useful_geojson_urls.scale} | {useful_geojson_urls.summary} | {useful_geojson_urls.size} | {useful_geojson_urls.url} |
|
|
139
|
-
|
|
140
|
-
<details>
|
|
141
|
-
<summary>All GeoJSON Files</summary>
|
|
142
|
-
|
|
143
|
-
| file | category | scale | summary | size | url |
|
|
144
|
-
|------|----------|-------|---------|------|-----|
|
|
145
|
-
| {all_geojson_urls.file} | {all_geojson_urls.category} | {all_geojson_urls.scale} | {all_geojson_urls.summary} | {all_geojson_urls.size} | {all_geojson_urls.url} |
|
|
146
|
-
|
|
147
|
-
</details>
|
|
148
|
-
|
|
149
|
-
## Base Map Options
|
|
150
|
-
|
|
151
|
-
| Property | Type | Description |
|
|
152
|
-
|----------|------|-------------|
|
|
153
|
-
| basemap | URL | URL template for the basemap tiles. |
|
|
154
|
-
| attribution | text | Attribution text to display on the map (e.g., "© OpenStreetMap contributors"). |
|
|
155
|
-
| title | text | Optional title displayed above the map. |
|
|
156
|
-
| startingLat | latitude coordinate | Starting latitude for the map center. |
|
|
157
|
-
| startingLong | longitude coordinate | Starting longitude for the map center. |
|
|
158
|
-
| startingZoom | number (1 to 18) | Initial zoom level of the map. |
|
|
159
|
-
| height | pixel value (default: 300) | Height of the map in pixels. |
|
|
160
|
-
| title | string | Title for the map |
|
|
161
|
-
| subtitle | string | Subtitle - appears under the title |
|
|
162
|
-
|
|
163
|
-
## Layer Options
|
|
164
|
-
|
|
165
|
-
### Areas
|
|
166
|
-
Use the `<Areas/>` component to add an area layer
|
|
167
|
-
|
|
168
|
-
| Property | Required | Type | Description |
|
|
169
|
-
|----------|----------|------|-------------|
|
|
170
|
-
| data | ✓ | query name | Query result, referenced using curly braces. |
|
|
171
|
-
| geoJsonUrl | ✓ | URL | Path to source geoJSON data from - can be a URL (see [Map Resources](#map-resources)) or a file in your project. If the file is in your `static` directory in the root of your project, reference it as `geoJsonUrl="/your_file.geojson"` |
|
|
172
|
-
| areaCol | ✓ | column name | Column in the data that specifies the area each row belongs to. |
|
|
173
|
-
| geoId | ✓ | geoJSON property name | Property in the GeoJSON that uniquely identifies each feature. |
|
|
174
|
-
| value | | column name | Column that determines the value displayed for each area (used for color scale). |
|
|
175
|
-
| valueFmt | | format string | Format string for displaying the value. |
|
|
176
|
-
| ignoreZoom | | true/false (default: false) | Stops map from zooming out to show all data for this layer |
|
|
177
|
-
|
|
178
|
-
### Points
|
|
179
|
-
Use the `<Points/>` component to add an area layer
|
|
180
|
-
|
|
181
|
-
| Property | Required | Type | Description |
|
|
182
|
-
|----------|----------|------|-------------|
|
|
183
|
-
| data | ✓ | query name | Query result, referenced using curly braces. |
|
|
184
|
-
| lat | ✓ | column name | Column containing latitude values. |
|
|
185
|
-
| long | ✓ | column name | Column containing longitude values. |
|
|
186
|
-
| value | | column name | Column that determines the value displayed at each point. |
|
|
187
|
-
| valueFmt | | format string | Format string for displaying the value. |
|
|
188
|
-
| pointName | | column name | Column containing the names/labels of the points - by default, this is shown as the title of the tooltip. |
|
|
189
|
-
| ignoreZoom | | true/false (default: false) | Stops map from zooming out to show all data for this layer |
|
|
190
|
-
|
|
191
|
-
### Bubbles
|
|
192
|
-
Use the `<Bubbles/>` component to add an area layer
|
|
193
|
-
|
|
194
|
-
| Property | Required | Type | Description |
|
|
195
|
-
|----------|----------|------|-------------|
|
|
196
|
-
| data | ✓ | query name | Query result, referenced using curly braces. |
|
|
197
|
-
| lat | ✓ | column name | Column containing latitude values. |
|
|
198
|
-
| long | ✓ | column name | Column containing longitude values. |
|
|
199
|
-
| size | ✓ | column name | Column that determines the size displayed for each point. |
|
|
200
|
-
| sizeFmt | | format string | Format string for displaying the size value in tooltips. |
|
|
201
|
-
| maxSize | | number (default: 20) | Maximum size of the bubbles. |
|
|
202
|
-
| value | | column name | Column that determines the value displayed at each point (used for color scale). |
|
|
203
|
-
| valueFmt | | format string | Format string for displaying the value. |
|
|
204
|
-
| pointName | | column name | Column containing the names/labels of the points - by default, this is shown as the title of the tooltip. |
|
|
205
|
-
| paneType | | text | Specifies the type of pane where the bubbles will be rendered. |
|
|
206
|
-
| z | | number | Represents the z-index value for the pane, controlling its stacking order relative to other panes (higher values are on top, e.g., z=2 is above z=1). |
|
|
207
|
-
| ignoreZoom | | true/false (default: false) | Stops map from zooming out to show all data for this layer |
|
|
208
|
-
|
|
209
|
-
### Common Layer Options
|
|
210
|
-
|
|
211
|
-
#### Color Scale
|
|
212
|
-
|
|
213
|
-
| Property | Type | Description |
|
|
214
|
-
|----------|------|-------------|
|
|
215
|
-
| colorPalette | array of colors | Array of colors used for theming the points or areas based on data. |
|
|
216
|
-
| min | number (default: min of value column) | Minimum value to use for the color scale. |
|
|
217
|
-
| max | number (default: max of value column) | Maximum value to use for the color scale. |
|
|
218
|
-
|
|
219
|
-
#### Interactivity
|
|
220
|
-
|
|
221
|
-
| Property | Type | Description |
|
|
222
|
-
|----------|------|-------------|
|
|
223
|
-
| link | URL | URL to navigate to when a point or area is clicked. |
|
|
224
|
-
| name | string | Input name. Can be referenced on your page with {inputs.my_input_name}. |
|
|
225
|
-
|
|
226
|
-
#### Styling
|
|
227
|
-
| Property | Type | Description |
|
|
228
|
-
|----------|------|-------------|
|
|
229
|
-
| color | CSS color value | Color for the points or areas. Use when you want all points or areas to be the same color. |
|
|
230
|
-
| borderWidth | pixel value | Width of the border around each point or area. |
|
|
231
|
-
| borderColor | CSS color value | Color of the border around each point or area. |
|
|
232
|
-
| opacity | number between 0 and 1 | Opacity of the points or areas. |
|
|
233
|
-
|
|
234
|
-
#### Selected State
|
|
235
|
-
| Property | Type | Description |
|
|
236
|
-
|----------|------|-------------|
|
|
237
|
-
| selectedColor | CSS color value | When point or area is selected: Color for the points or areas. |
|
|
238
|
-
| selectedBorderWidth | pixel value | When point or area is selected: Width of the border around each point or area. |
|
|
239
|
-
| selectedBorderColor | CSS color value | When point or area is selected: Color of the border around each point or area. |
|
|
240
|
-
| selectedOpacity | number between 0 and 1 | When point or area is selected: Opacity of the points or areas. |
|
|
241
|
-
|
|
242
|
-
#### Tooltips
|
|
243
|
-
| Property | Type | Default | Description |
|
|
244
|
-
|----------|------|---------|-------------|
|
|
245
|
-
| showTooltip | true/false | true | Whether to show tooltips. |
|
|
246
|
-
| tooltipType | hover/click | hover | Determines whether tooltips are activated by hover or click. |
|
|
247
|
-
| tooltipClass | CSS class | | CSS class applied to the tooltip content. You can pass Tailwind classes into this prop to custom-style the tooltip. |
|
|
248
|
-
| tooltip | array of objects | | Configuration for tooltips associated with each area. See below example for format |
|
|
249
|
-
|
|
250
|
-
#### `tooltip` example:
|
|
251
|
-
|
|
252
|
-
```javascript
|
|
253
|
-
tooltip="[
|
|
254
|
-
{id: 'zip_code', fmt: 'id', showColumnName: false, valueClass: 'text-xl font-semibold'",
|
|
255
|
-
{id: 'sales', fmt: 'eur', fieldClass: 'text-[grey]', valueClass: 'text-[green]'},
|
|
256
|
-
{id: 'zip_code', showColumnName: false, contentType: 'link', linkLabel: 'Click here', valueClass: 'font-bold mt-1'}
|
|
257
|
-
]}
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
#### All options available in `tooltip`:
|
|
261
|
-
- `id`: column ID
|
|
262
|
-
- `title`: custom string to use as title of field
|
|
263
|
-
- `fmt`: format to use for value
|
|
264
|
-
- `showColumnName`: whether to show the column name. If `false`, only the value will be shown
|
|
265
|
-
- `contentType`: currently can only be "link"
|
|
266
|
-
- `linkLabel`: text to show for a link when contentType="link"
|
|
267
|
-
- `formatColumnTitle`: whether to automatically uppercase the first letter of the title. Only applies when `title` not passed explicitly
|
|
268
|
-
- `valueClass`: custom Tailwind classes to style the values
|
|
269
|
-
- `fieldClass`: custom Tailwind classes to style the column names
|