You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/5_0_choropleth-map.fsx
+120Lines changed: 120 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -131,4 +131,124 @@ choroplethMap2
131
131
132
132
(***hide***)
133
133
choroplethMap2 |> GenericChart.toChartHTML
134
+
(***include-it-raw***)
135
+
136
+
(**
137
+
## Using GeoJSON
138
+
139
+
[GeoJSON](https://en.wikipedia.org/wiki/GeoJSON) is an open standard format designed for representing simple geographical features, along with their non-spatial attributes.
140
+
141
+
GeoJSON, or at least the type of GeoJSON accepted by plotly.js are `FeatureCollection`s. A feature has for example the `geometry` field, which defines e.g. the corrdinates of it (think for example the coordinates of a polygon on the map)
142
+
and the `properties` field, a key-value pair of properties of the feature.
143
+
144
+
If you want to use GeoJSON with Plotly.NET (or any plotly flavor really), you have to know the property of the feature you are mapping your data to. In the following example this is simply the `id` of a feature, but you can access any property by `property.key`.
145
+
146
+
Consider the following GeoJSON:
147
+
148
+
*)
149
+
150
+
// we are using the awesome FSharp.Data project here to perform a http request
It basically contains all US counties as polygons on the map. Note that the `id` property corresponds to the [**fips code**](https://en.wikipedia.org/wiki/FIPS_county_code).
185
+
186
+
To visualize some data using these counties as locations on a choropleth map, we need some exmaple data:
187
+
*)
188
+
189
+
// we use the awesome Deedle data frame library to parse and extract our location and z data
190
+
#r "nuget: Deedle"
191
+
open Deedle
192
+
open System.IO
193
+
open System.Text
194
+
195
+
let data =
196
+
let dataString = Http.RequestString "https://raw.githubusercontent.com/plotly/datasets/master/fips-unemp-16.csv"
197
+
let byteArray = Encoding.UTF8.GetBytes(dataString)
Copy file name to clipboardExpand all lines: src/Plotly.NET/Chart.fs
+74-56Lines changed: 74 additions & 56 deletions
Original file line number
Diff line number
Diff line change
@@ -616,7 +616,6 @@ type Chart =
616
616
Chart.Range(x, y, upper, lower, ?Name=Name,?ShowMarkers=ShowMarkers,?Showlegend=Showlegend,?Color=Color,?RangeColor=RangeColor,?Labels=Labels,?TextPosition=TextPosition,?TextFont=TextFont)
617
617
618
618
619
-
620
619
/// Displays a range of data by plotting two Y values per data point, with each Y value being drawn as a line
0 commit comments