-
Notifications
You must be signed in to change notification settings - Fork 101
Expand file tree
/
Copy pathChartMap_Density.fs
More file actions
380 lines (351 loc) · 21.1 KB
/
ChartMap_Density.fs
File metadata and controls
380 lines (351 loc) · 21.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
namespace Plotly.NET
open Plotly.NET.LayoutObjects
open Plotly.NET.TraceObjects
open DynamicObj
open System
open System.IO
open StyleParam
open System.Runtime.InteropServices
open System.Runtime.CompilerServices
[<AutoOpen>]
module ChartMap_Density =
[<Extension>]
type Chart =
/// <summary>
/// Creates a choropleth map using mapbox.
///
/// A choropleth map is a type of thematic map in which a set of pre-defined areas is colored or patterned in proportion to a statistical variable that represents an aggregate summary of a geographic characteristic within each area, such as population density or per-capita income.
///
/// GeoJSON features to be filled are set in `geojson` The data that describes the choropleth value-to-color mapping is set in `locations` and `z`.
///
/// Customize the mapbox layers, style, etc. by using Chart.withMapbox.
///
/// You might need a Mapbox token, which you can also configure with Chart.withMapbox.
/// </summary>
/// <param name="locations">Sets the coordinates via location IDs or names. Coordinates correspond to the centroid of each location given. See `locationmode` for more info.</param>
/// <param name="z">The color values for each location</param>
/// <param name="geoJson">Sets the GeoJSON data associated with this trace. It can be set as a valid GeoJSON object or as a URL string. Note that we only accept GeoJSONs of type "FeatureCollection" or "Feature" with geometries of type "Polygon" or "MultiPolygon".</param>
/// <param name="Name">Sets the trace name. The trace name appear as the legend item and on hover.</param>
/// <param name="MapboxStyle">Sets the base mapbox layer. Default is `OpenStreetMap`. Note that you will need an access token for some Mapbox presets.</param>
/// <param name="ShowLegend">Determines whether or not an item corresponding to this trace is shown in the legend.</param>
/// <param name="FeatureIdKey">Sets the key in GeoJSON features which is used as id to match the items included in the `locations` array. Support nested property, for example "properties.name".</param>
/// <param name="Text">Sets a text associated with each datum</param>
/// <param name="MultiText">Sets individual text for each datum</param>
/// <param name="ColorBar">Sets the colorbar.</param>
/// <param name="ColorScale">Sets the colorscale.</param>
/// <param name="ShowScale">Determines whether or not a colorbar is displayed for this trace.</param>
/// <param name="ReverseScale">Reverses the color mapping if true.</param>
/// <param name="Below">Determines if this scattermapbox trace's layers are to be inserted before the layer with the specified ID. By default, scattermapbox layers are inserted above all the base layers. To place the scattermapbox layers above every other layer, set `below` to "''".</param>
/// <param name="UseDefaults">If set to false, ignore the global default settings set in `Defaults`</param>
[<Extension>]
static member ChoroplethMapbox
(
locations: seq<string>,
z: seq<#IConvertible>,
geoJson: obj,
?Name: string,
?MapboxStyle: StyleParam.MapboxStyle,
?ShowLegend: bool,
?FeatureIdKey: string,
?Text: #IConvertible,
?MultiText: seq<#IConvertible>,
?ColorBar: ColorBar,
?ColorScale: StyleParam.Colorscale,
?ShowScale: bool,
?ReverseScale: bool,
?Below: string,
?UseDefaults: bool
) =
let useDefaults =
defaultArg UseDefaults true
let mapboxStyle =
defaultArg MapboxStyle StyleParam.MapboxStyle.OpenStreetMap
let mapbox =
Mapbox.init (Style = mapboxStyle)
TraceMapbox.initChoroplethMapbox (
TraceMapboxStyle.ChoroplethMapbox(
Locations = locations,
Z = z,
?Name = Name,
?ShowLegend = ShowLegend,
GeoJson = geoJson,
?FeatureIdKey = FeatureIdKey,
?Text = Text,
?MultiText = MultiText,
?ColorBar = ColorBar,
?ColorScale = ColorScale,
?ShowScale = ShowScale,
?ReverseScale = ReverseScale,
?Below = Below
)
)
|> GenericChart.ofTraceObject useDefaults
|> GenericChart.addLayout (Layout.init () |> Layout.setMapbox (StyleParam.SubPlotId.Mapbox 1, mapbox))
/// <summary>
/// Creates a choropleth map using mapbox from encoded color values.
///
/// A choropleth map is a type of thematic map in which a set of pre-defined areas is colored or patterned in proportion to a statistical variable that represents an aggregate summary of a geographic characteristic within each area, such as population density or per-capita income.
///
/// GeoJSON features to be filled are set in `geojson` The data that describes the choropleth value-to-color mapping is set in `locations` and `z`.
///
/// Customize the mapbox layers, style, etc. by using Chart.withMapbox.
///
/// You might need a Mapbox token, which you can also configure with Chart.withMapbox.
/// </summary>
/// <param name="locations">Sets the coordinates via location IDs or names. Coordinates correspond to the centroid of each location given. See `locationmode` for more info.</param>
/// <param name="zEncoded">The color values for each location as an encoded typed array.</param>
/// <param name="geoJson">Sets the GeoJSON data associated with this trace. It can be set as a valid GeoJSON object or as a URL string. Note that we only accept GeoJSONs of type "FeatureCollection" or "Feature" with geometries of type "Polygon" or "MultiPolygon".</param>
/// <param name="Name">Sets the trace name. The trace name appear as the legend item and on hover.</param>
/// <param name="MapboxStyle">Sets the base mapbox layer. Default is `OpenStreetMap`. Note that you will need an access token for some Mapbox presets.</param>
/// <param name="ShowLegend">Determines whether or not an item corresponding to this trace is shown in the legend.</param>
/// <param name="FeatureIdKey">Sets the key in GeoJSON features which is used as id to match the items included in the `locations` array. Support nested property, for example "properties.name".</param>
/// <param name="Text">Sets a text associated with each datum</param>
/// <param name="MultiText">Sets individual text for each datum</param>
/// <param name="ColorBar">Sets the colorbar.</param>
/// <param name="ColorScale">Sets the colorscale.</param>
/// <param name="ShowScale">Determines whether or not a colorbar is displayed for this trace.</param>
/// <param name="ReverseScale">Reverses the color mapping if true.</param>
/// <param name="Below">Determines if this scattermapbox trace's layers are to be inserted before the layer with the specified ID. By default, scattermapbox layers are inserted above all the base layers. To place the scattermapbox layers above every other layer, set `below` to "''".</param>
/// <param name="UseDefaults">If set to false, ignore the global default settings set in `Defaults`</param>
[<Extension>]
static member ChoroplethMapbox
(
locations: seq<string>,
zEncoded: EncodedTypedArray,
geoJson: obj,
?Name: string,
?MapboxStyle: StyleParam.MapboxStyle,
?ShowLegend: bool,
?FeatureIdKey: string,
?Text: #IConvertible,
?MultiText: seq<#IConvertible>,
?ColorBar: ColorBar,
?ColorScale: StyleParam.Colorscale,
?ShowScale: bool,
?ReverseScale: bool,
?Below: string,
?UseDefaults: bool
) =
let useDefaults =
defaultArg UseDefaults true
let mapboxStyle =
defaultArg MapboxStyle StyleParam.MapboxStyle.OpenStreetMap
let mapbox =
Mapbox.init (Style = mapboxStyle)
TraceMapbox.initChoroplethMapbox (
TraceMapboxStyle.ChoroplethMapbox(
Locations = locations,
ZEncoded = zEncoded,
?Name = Name,
?ShowLegend = ShowLegend,
GeoJson = geoJson,
?FeatureIdKey = FeatureIdKey,
?Text = Text,
?MultiText = MultiText,
?ColorBar = ColorBar,
?ColorScale = ColorScale,
?ShowScale = ShowScale,
?ReverseScale = ReverseScale,
?Below = Below
)
)
|> GenericChart.ofTraceObject useDefaults
|> GenericChart.addLayout (Layout.init () |> Layout.setMapbox (StyleParam.SubPlotId.Mapbox 1, mapbox))
/// <summary>
/// Creates a DensityMapbox Chart that draws a bivariate kernel density estimation with a Gaussian kernel from `lon` and `lat` coordinates and optional `z` values using a colorscale.
///
/// Customize the mapbox layers, style, etc. by using Chart.withMapbox.
///
/// You might need a Mapbox token, which you can also configure with Chart.withMapbox.
/// </summary>
/// <param name="longitudes">Sets the longitude coordinates (in degrees East).</param>
/// <param name="latitudes">Sets the latitude coordinates (in degrees North).</param>
/// <param name="Name">Sets the trace name. The trace name appear as the legend item and on hover.</param>
/// <param name="MapboxStyle">Sets the base mapbox layer. Default is `OpenStreetMap`. Note that you will need an access token for some Mapbox presets.</param>
/// <param name="ShowLegend">Determines whether or not an item corresponding to this trace is shown in the legend.</param>
/// <param name="Opacity">Sets the opacity of the trace</param>
/// <param name="Z">Sets the points' weight. For example, a value of 10 would be equivalent to having 10 points of weight 1 in the same spot</param>
/// <param name="Radius">Sets the radius of influence of one `lon` / `lat` point in pixels. Increasing the value makes the densitymapbox trace smoother, but less detailed.</param>
/// <param name="Text">Sets a text associated with each datum</param>
/// <param name="MultiText">Sets individual text for each datum</param>
/// <param name="ColorBar">Sets the colorbar.</param>
/// <param name="ColorScale">Sets the colorscale.</param>
/// <param name="ShowScale">Determines whether or not a colorbar is displayed for this trace.</param>
/// <param name="ReverseScale">Reverses the color mapping if true.</param>
/// <param name="Below">Determines if this scattermapbox trace's layers are to be inserted before the layer with the specified ID. By default, scattermapbox layers are inserted above all the base layers. To place the scattermapbox layers above every other layer, set `below` to "''".</param>
/// <param name="UseDefaults">If set to false, ignore the global default settings set in `Defaults`</param>
[<Extension>]
static member DensityMapbox
(
longitudes: seq<#IConvertible>,
latitudes: seq<#IConvertible>,
?Name: string,
?MapboxStyle: StyleParam.MapboxStyle,
?ShowLegend: bool,
?Opacity: float,
?Z: seq<#IConvertible>,
?Radius: int,
?Text: #IConvertible,
?MultiText: seq<#IConvertible>,
?ColorBar: ColorBar,
?ColorScale: StyleParam.Colorscale,
?ShowScale: bool,
?ReverseScale: bool,
?Below: string,
?UseDefaults: bool
) =
let useDefaults =
defaultArg UseDefaults true
let mapboxStyle =
defaultArg MapboxStyle StyleParam.MapboxStyle.OpenStreetMap
let mapbox =
Mapbox.init (Style = mapboxStyle)
TraceMapbox.initDensityMapbox (
TraceMapboxStyle.DensityMapbox(
Lon = longitudes,
Lat = latitudes,
?Name = Name,
?ShowLegend = ShowLegend,
?Opacity = Opacity,
?Z = Z,
?Radius = Radius,
?Text = Text,
?MultiText = MultiText,
?ColorBar = ColorBar,
?ColorScale = ColorScale,
?ShowScale = ShowScale,
?ReverseScale = ReverseScale,
?Below = Below
)
)
|> GenericChart.ofTraceObject useDefaults
|> GenericChart.addLayout (Layout.init () |> Layout.setMapbox (StyleParam.SubPlotId.Mapbox 1, mapbox))
/// <summary>
/// Creates a DensityMapbox Chart that draws a bivariate kernel density estimation with a Gaussian kernel from `lon` and `lat` coordinates and optional `z` values using a colorscale.
///
/// Customize the mapbox layers, style, etc. by using Chart.withMapbox.
///
/// You might need a Mapbox token, which you can also configure with Chart.withMapbox.
/// </summary>
/// <param name="lonlat">Sets the (longitude,latitude) coordinates (in degrees East, degrees North).</param>
/// <param name="Name">Sets the trace name. The trace name appear as the legend item and on hover.</param>
/// <param name="MapboxStyle">Sets the base mapbox layer. Default is `OpenStreetMap`. Note that you will need an access token for some Mapbox presets.</param>
/// <param name="ShowLegend">Determines whether or not an item corresponding to this trace is shown in the legend.</param>
/// <param name="Opacity">Sets the opacity of the trace</param>
/// <param name="Z">Sets the points' weight. For example, a value of 10 would be equivalent to having 10 points of weight 1 in the same spot</param>
/// <param name="Radius">Sets the radius of influence of one `lon` / `lat` point in pixels. Increasing the value makes the densitymapbox trace smoother, but less detailed.</param>
/// <param name="Text">Sets a text associated with each datum</param>
/// <param name="MultiText">Sets individual text for each datum</param>
/// <param name="ColorBar">Sets the colorbar.</param>
/// <param name="ColorScale">Sets the colorscale.</param>
/// <param name="ShowScale">Determines whether or not a colorbar is displayed for this trace.</param>
/// <param name="ReverseScale">Reverses the color mapping if true.</param>
/// <param name="Below">Determines if this scattermapbox trace's layers are to be inserted before the layer with the specified ID. By default, scattermapbox layers are inserted above all the base layers. To place the scattermapbox layers above every other layer, set `below` to "''".</param>
/// <param name="UseDefaults">If set to false, ignore the global default settings set in `Defaults`</param>
[<Extension>]
static member DensityMapbox
(
lonlat: seq<#IConvertible * #IConvertible>,
?Name: string,
?MapboxStyle: StyleParam.MapboxStyle,
?ShowLegend: bool,
?Opacity: float,
?Z: seq<#IConvertible>,
?Radius: int,
?Text: #IConvertible,
?MultiText: seq<#IConvertible>,
?ColorBar: ColorBar,
?ColorScale: StyleParam.Colorscale,
?ShowScale: bool,
?ReverseScale: bool,
?Below: string,
?UseDefaults: bool
) =
let longitudes, latitudes = Seq.unzip lonlat
Chart.DensityMapbox(
longitudes,
latitudes,
?Name = Name,
?MapboxStyle = MapboxStyle,
?ShowLegend = ShowLegend,
?Opacity = Opacity,
?Z = Z,
?Radius = Radius,
?Text = Text,
?MultiText = MultiText,
?ColorBar = ColorBar,
?ColorScale = ColorScale,
?ShowScale = ShowScale,
?ReverseScale = ReverseScale,
?Below = Below,
?UseDefaults = UseDefaults
)
/// <summary>
/// Creates a DensityMapbox Chart from encoded longitude and latitude coordinates and optional encoded weights.
///
/// Customize the mapbox layers, style, etc. by using Chart.withMapbox.
///
/// You might need a Mapbox token, which you can also configure with Chart.withMapbox.
/// </summary>
/// <param name="longitudesEncoded">Sets the longitude coordinates (in degrees East) as an encoded typed array.</param>
/// <param name="latitudesEncoded">Sets the latitude coordinates (in degrees North) as an encoded typed array.</param>
/// <param name="Name">Sets the trace name. The trace name appear as the legend item and on hover.</param>
/// <param name="MapboxStyle">Sets the base mapbox layer. Default is `OpenStreetMap`. Note that you will need an access token for some Mapbox presets.</param>
/// <param name="ShowLegend">Determines whether or not an item corresponding to this trace is shown in the legend.</param>
/// <param name="Opacity">Sets the opacity of the trace</param>
/// <param name="zEncoded">Sets the points' weight as an encoded typed array. For example, a value of 10 would be equivalent to having 10 points of weight 1 in the same spot.</param>
/// <param name="Radius">Sets the radius of influence of one `lon` / `lat` point in pixels. Increasing the value makes the densitymapbox trace smoother, but less detailed.</param>
/// <param name="Text">Sets a text associated with each datum</param>
/// <param name="MultiText">Sets individual text for each datum</param>
/// <param name="ColorBar">Sets the colorbar.</param>
/// <param name="ColorScale">Sets the colorscale.</param>
/// <param name="ShowScale">Determines whether or not a colorbar is displayed for this trace.</param>
/// <param name="ReverseScale">Reverses the color mapping if true.</param>
/// <param name="Below">Determines if this scattermapbox trace's layers are to be inserted before the layer with the specified ID. By default, scattermapbox layers are inserted above all the base layers. To place the scattermapbox layers above every other layer, set `below` to "''".</param>
/// <param name="UseDefaults">If set to false, ignore the global default settings set in `Defaults`</param>
[<Extension>]
static member DensityMapbox
(
longitudesEncoded: EncodedTypedArray,
latitudesEncoded: EncodedTypedArray,
?Name: string,
?MapboxStyle: StyleParam.MapboxStyle,
?ShowLegend: bool,
?Opacity: float,
?zEncoded: EncodedTypedArray,
?Radius: int,
?Text: #IConvertible,
?MultiText: seq<#IConvertible>,
?ColorBar: ColorBar,
?ColorScale: StyleParam.Colorscale,
?ShowScale: bool,
?ReverseScale: bool,
?Below: string,
?UseDefaults: bool
) =
let useDefaults =
defaultArg UseDefaults true
let mapboxStyle =
defaultArg MapboxStyle StyleParam.MapboxStyle.OpenStreetMap
let mapbox =
Mapbox.init (Style = mapboxStyle)
TraceMapbox.initDensityMapbox (
TraceMapboxStyle.DensityMapbox(
LonEncoded = longitudesEncoded,
LatEncoded = latitudesEncoded,
?Name = Name,
?ShowLegend = ShowLegend,
?Opacity = Opacity,
?ZEncoded = zEncoded,
?Radius = Radius,
?Text = Text,
?MultiText = MultiText,
?ColorBar = ColorBar,
?ColorScale = ColorScale,
?ShowScale = ShowScale,
?ReverseScale = ReverseScale,
?Below = Below
)
)
|> GenericChart.ofTraceObject useDefaults
|> GenericChart.addLayout (Layout.init () |> Layout.setMapbox (StyleParam.SubPlotId.Mapbox 1, mapbox))