diff --git a/src/Plotly.NET/ChartAPI/ChartMap.fs b/src/Plotly.NET/ChartAPI/ChartMap.fs index fe0031a3b..d6ff5f2d5 100644 --- a/src/Plotly.NET/ChartAPI/ChartMap.fs +++ b/src/Plotly.NET/ChartAPI/ChartMap.fs @@ -1163,6 +1163,7 @@ module ChartMap = /// Sets the longitude coordinates (in degrees East). /// Sets the latitude coordinates (in degrees North). /// Determines the drawing mode for this scatter trace. + /// Sets the base mapbox layer. Default is `OpenStreetMap`. Note that you will need an access token for some Mapbox presets. /// Sets the trace name. The trace name appear as the legend item and on hover /// Determines whether or not an item corresponding to this trace is shown in the legend. /// Sets the opactity of the trace @@ -1192,6 +1193,7 @@ module ChartMap = longitudes: seq<#IConvertible>, latitudes: seq<#IConvertible>, mode: StyleParam.Mode, + [] ?MapboxStyle: StyleParam.MapboxStyle, [] ?Name: string, [] ?ShowLegend: bool, [] ?Opacity: float, @@ -1250,6 +1252,10 @@ module ChartMap = ?Enabled = EnableClustering ) + let mapboxStyle = defaultArg MapboxStyle StyleParam.MapboxStyle.OpenStreetMap + + let mapbox = Mapbox.init(Style = mapboxStyle) + TraceMapbox.initScatterMapbox ( TraceMapboxStyle.ScatterMapbox( Lon = longitudes, @@ -1268,8 +1274,14 @@ module ChartMap = ?Below = Below ) ) - |> GenericChart.ofTraceObject useDefaults + |> GenericChart.addLayout( + Layout.init() + |> Layout.setMapbox( + StyleParam.SubPlotId.Mapbox 1, + mapbox + ) + ) /// /// Creates a ScatterMapbox chart, where data is visualized on a geographic map using mapbox. @@ -1283,6 +1295,7 @@ module ChartMap = /// Sets the (longitude,latitude) coordinates (in degrees East, degrees North). /// Determines the drawing mode for this scatter trace. /// Sets the trace name. The trace name appear as the legend item and on hover + /// Sets the base mapbox layer. Default is `OpenStreetMap`. Note that you will need an access token for some Mapbox presets. /// Determines whether or not an item corresponding to this trace is shown in the legend. /// Sets the opactity of the trace /// Sets the opactity of individual datum markers @@ -1311,6 +1324,7 @@ module ChartMap = lonlat: seq<#IConvertible * #IConvertible>, mode: StyleParam.Mode, [] ?Name: string, + [] ?MapboxStyle: StyleParam.MapboxStyle, [] ?ShowLegend: bool, [] ?Opacity: float, [] ?MultiOpacity: seq, @@ -1342,6 +1356,7 @@ module ChartMap = latitudes, mode, ?Name = Name, + ?MapboxStyle = MapboxStyle, ?ShowLegend = ShowLegend, ?Opacity = Opacity, ?MultiOpacity = MultiOpacity, @@ -1376,6 +1391,7 @@ module ChartMap = /// Sets the longitude coordinates (in degrees East). /// Sets the latitude coordinates (in degrees North). /// Sets the trace name. The trace name appear as the legend item and on hover + /// Sets the base mapbox layer. Default is `OpenStreetMap`. Note that you will need an access token for some Mapbox presets. /// Determines whether or not an item corresponding to this trace is shown in the legend. /// Sets the opactity of the trace /// Sets the opactity of individual datum markers @@ -1399,6 +1415,7 @@ module ChartMap = longitudes: seq<#IConvertible>, latitudes: seq<#IConvertible>, [] ?Name: string, + [] ?MapboxStyle: StyleParam.MapboxStyle, [] ?ShowLegend: bool, [] ?Opacity: float, [] ?MultiOpacity: seq, @@ -1426,6 +1443,7 @@ module ChartMap = latitudes, mode = changeMode StyleParam.Mode.Markers, ?Name = Name, + ?MapboxStyle = MapboxStyle, ?ShowLegend = ShowLegend, ?Opacity = Opacity, ?MultiOpacity = MultiOpacity, @@ -1455,6 +1473,7 @@ module ChartMap = /// /// Sets the (longitude,latitude) coordinates (in degrees East, degrees North). /// Sets the trace name. The trace name appear as the legend item and on hover + /// Sets the base mapbox layer. Default is `OpenStreetMap`. Note that you will need an access token for some Mapbox presets. /// Determines whether or not an item corresponding to this trace is shown in the legend. /// Sets the opactity of the trace /// Sets the opactity of individual datum markers @@ -1477,6 +1496,7 @@ module ChartMap = ( lonlat: seq<#IConvertible * #IConvertible>, [] ?Name: string, + [] ?MapboxStyle: StyleParam.MapboxStyle, [] ?ShowLegend: bool, [] ?Opacity: float, [] ?MultiOpacity: seq, @@ -1502,6 +1522,7 @@ module ChartMap = longitudes, latitudes, ?Name = Name, + ?MapboxStyle = MapboxStyle, ?ShowLegend = ShowLegend, ?Opacity = Opacity, ?MultiOpacity = MultiOpacity, @@ -1532,6 +1553,7 @@ module ChartMap = /// Sets the latitude coordinates (in degrees North). /// /// Sets the trace name. The trace name appear as the legend item and on hover + /// Sets the base mapbox layer. Default is `OpenStreetMap`. Note that you will need an access token for some Mapbox presets. /// Determines whether or not an item corresponding to this trace is shown in the legend. /// Sets the opactity of the trace /// Sets the opactity of individual datum markers @@ -1559,6 +1581,7 @@ module ChartMap = latitudes: seq<#IConvertible>, [] ?ShowMarkers: bool, [] ?Name: string, + [] ?MapboxStyle: StyleParam.MapboxStyle, [] ?ShowLegend: bool, [] ?Opacity: float, [] ?MultiOpacity: seq, @@ -1595,6 +1618,7 @@ module ChartMap = latitudes, mode = changeMode StyleParam.Mode.Lines, ?Name = Name, + ?MapboxStyle = MapboxStyle, ?ShowLegend = ShowLegend, ?Opacity = Opacity, ?MultiOpacity = MultiOpacity, @@ -1627,6 +1651,7 @@ module ChartMap = /// Sets the (longitude,latitude) coordinates (in degrees East, degrees North). /// /// Sets the trace name. The trace name appear as the legend item and on hover + /// Sets the base mapbox layer. Default is `OpenStreetMap`. Note that you will need an access token for some Mapbox presets. /// Determines whether or not an item corresponding to this trace is shown in the legend. /// Sets the opactity of the trace /// Sets the opactity of individual datum markers @@ -1653,6 +1678,7 @@ module ChartMap = lonlat: seq<#IConvertible * #IConvertible>, [] ?ShowMarkers: bool, [] ?Name: string, + [] ?MapboxStyle: StyleParam.MapboxStyle, [] ?ShowLegend: bool, [] ?Opacity: float, [] ?MultiOpacity: seq, @@ -1682,6 +1708,7 @@ module ChartMap = latitudes, ?ShowMarkers = ShowMarkers, ?Name = Name, + ?MapboxStyle = MapboxStyle, ?ShowLegend = ShowLegend, ?Opacity = Opacity, ?MultiOpacity = MultiOpacity, @@ -1716,6 +1743,7 @@ module ChartMap = /// Sets the latitude coordinates (in degrees North). /// Sets the size of the points. /// Sets the trace name. The trace name appear as the legend item and on hover + /// Sets the base mapbox layer. Default is `OpenStreetMap`. Note that you will need an access token for some Mapbox presets. /// Determines whether or not an item corresponding to this trace is shown in the legend. /// Sets the opactity of the trace /// Sets the opactity of individual datum markers @@ -1738,6 +1766,7 @@ module ChartMap = latitudes: seq<#IConvertible>, sizes: seq, [] ?Name: string, + [] ?MapboxStyle: StyleParam.MapboxStyle, [] ?ShowLegend: bool, [] ?Opacity: float, [] ?MultiOpacity: seq, @@ -1775,6 +1804,10 @@ module ChartMap = MultiSize = sizes ) + let mapboxStyle = defaultArg MapboxStyle StyleParam.MapboxStyle.OpenStreetMap + + let mapbox = Mapbox.init(Style = mapboxStyle) + TraceMapbox.initScatterMapbox ( TraceMapboxStyle.ScatterMapbox( Lon = longitudes, @@ -1793,6 +1826,13 @@ module ChartMap = ) |> GenericChart.ofTraceObject useDefaults + |> GenericChart.addLayout( + Layout.init() + |> Layout.setMapbox( + StyleParam.SubPlotId.Mapbox 1, + mapbox + ) + ) /// /// Creates a BubbleMapbox chart, where data is visualized on a geographic map as points using mapbox, additionally using the point size as a third dimension. @@ -1803,6 +1843,7 @@ module ChartMap = /// /// Sets the (longitude,latitude) coordinates (in degrees East, degrees North) together with the point size. /// Sets the trace name. The trace name appear as the legend item and on hover + /// Sets the base mapbox layer. Default is `OpenStreetMap`. Note that you will need an access token for some Mapbox presets. /// Determines whether or not an item corresponding to this trace is shown in the legend. /// Sets the opactity of the trace /// Sets the opactity of individual datum markers @@ -1823,6 +1864,7 @@ module ChartMap = ( lonlatsizes: seq<#IConvertible * #IConvertible * int>, [] ?Name: string, + [] ?MapboxStyle: StyleParam.MapboxStyle, [] ?ShowLegend: bool, [] ?Opacity: float, [] ?MultiOpacity: seq, @@ -1848,6 +1890,7 @@ module ChartMap = latitudes, sizes, ?Name = Name, + ?MapboxStyle = MapboxStyle, ?ShowLegend = ShowLegend, ?Opacity = Opacity, ?MultiOpacity = MultiOpacity, @@ -1880,6 +1923,7 @@ module ChartMap = /// The color values for each location /// 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". /// Sets the trace name. The trace name appear as the legend item and on hover. + /// Sets the base mapbox layer. Default is `OpenStreetMap`. Note that you will need an access token for some Mapbox presets. /// Determines whether or not an item corresponding to this trace is shown in the legend. /// 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". /// Sets a text associated with each datum @@ -1897,6 +1941,7 @@ module ChartMap = z: seq<#IConvertible>, geoJson: obj, [] ?Name: string, + [] ?MapboxStyle: StyleParam.MapboxStyle, [] ?ShowLegend: bool, [] ?FeatureIdKey: string, [] ?Text: #IConvertible, @@ -1912,6 +1957,10 @@ module ChartMap = let useDefaults = defaultArg UseDefaults true + let mapboxStyle = defaultArg MapboxStyle StyleParam.MapboxStyle.OpenStreetMap + + let mapbox = Mapbox.init(Style = mapboxStyle) + TraceMapbox.initChoroplethMapbox ( TraceMapboxStyle.ChoroplethMapbox( Locations = locations, @@ -1930,6 +1979,13 @@ module ChartMap = ) ) |> GenericChart.ofTraceObject useDefaults + |> GenericChart.addLayout( + Layout.init() + |> Layout.setMapbox( + StyleParam.SubPlotId.Mapbox 1, + mapbox + ) + ) /// /// 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. @@ -1941,6 +1997,7 @@ module ChartMap = /// Sets the longitude coordinates (in degrees East). /// Sets the latitude coordinates (in degrees North). /// Sets the trace name. The trace name appear as the legend item and on hover. + /// Sets the base mapbox layer. Default is `OpenStreetMap`. Note that you will need an access token for some Mapbox presets. /// Determines whether or not an item corresponding to this trace is shown in the legend. /// Sets the opacity of the trace /// Sets the points' weight. For example, a value of 10 would be equivalent to having 10 points of weight 1 in the same spot @@ -1959,6 +2016,7 @@ module ChartMap = longitudes: seq<#IConvertible>, latitudes: seq<#IConvertible>, [] ?Name: string, + [] ?MapboxStyle: StyleParam.MapboxStyle, [] ?ShowLegend: bool, [] ?Opacity: float, [] ?Z: seq<#IConvertible>, @@ -1976,6 +2034,10 @@ module ChartMap = let useDefaults = defaultArg UseDefaults true + let mapboxStyle = defaultArg MapboxStyle StyleParam.MapboxStyle.OpenStreetMap + + let mapbox = Mapbox.init(Style = mapboxStyle) + TraceMapbox.initDensityMapbox ( TraceMapboxStyle.DensityMapbox( Lon = longitudes, @@ -1996,6 +2058,13 @@ module ChartMap = ) ) |> GenericChart.ofTraceObject useDefaults + |> GenericChart.addLayout( + Layout.init() + |> Layout.setMapbox( + StyleParam.SubPlotId.Mapbox 1, + mapbox + ) + ) /// /// 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. @@ -2006,6 +2075,7 @@ module ChartMap = /// /// Sets the (longitude,latitude) coordinates (in degrees East, degrees North). /// Sets the trace name. The trace name appear as the legend item and on hover. + /// Sets the base mapbox layer. Default is `OpenStreetMap`. Note that you will need an access token for some Mapbox presets. /// Determines whether or not an item corresponding to this trace is shown in the legend. /// Sets the opacity of the trace /// Sets the points' weight. For example, a value of 10 would be equivalent to having 10 points of weight 1 in the same spot @@ -2023,6 +2093,7 @@ module ChartMap = ( lonlat: seq<#IConvertible * #IConvertible>, [] ?Name: string, + [] ?MapboxStyle: StyleParam.MapboxStyle, [] ?ShowLegend: bool, [] ?Opacity: float, [] ?Z: seq<#IConvertible>, @@ -2043,6 +2114,7 @@ module ChartMap = longitudes, latitudes, ?Name = Name, + ?MapboxStyle = MapboxStyle, ?ShowLegend = ShowLegend, ?Opacity = Opacity, ?Z = Z, diff --git a/tests/Plotly.NET.Tests.FSharpConsole/Plotly.NET.Tests.FSharpConsole.fsproj b/tests/Plotly.NET.Tests.FSharpConsole/Plotly.NET.Tests.FSharpConsole.fsproj index e2e6b060c..e4960d3f4 100644 --- a/tests/Plotly.NET.Tests.FSharpConsole/Plotly.NET.Tests.FSharpConsole.fsproj +++ b/tests/Plotly.NET.Tests.FSharpConsole/Plotly.NET.Tests.FSharpConsole.fsproj @@ -12,6 +12,7 @@ + diff --git a/tests/Plotly.NET.Tests.FSharpConsole/Program.fs b/tests/Plotly.NET.Tests.FSharpConsole/Program.fs index 7a1e7bd13..42d0b7c18 100644 --- a/tests/Plotly.NET.Tests.FSharpConsole/Program.fs +++ b/tests/Plotly.NET.Tests.FSharpConsole/Program.fs @@ -1,6 +1,5 @@ -// Learn more about F# at http://docs.microsoft.com/dotnet/fsharp - open System +open Deedle open System.IO open Plotly.NET open Plotly.NET.LayoutObjects @@ -8,30 +7,7 @@ open Plotly.NET.TraceObjects open DynamicObj open Giraffe.ViewEngine -// Define a function to construct a message to print -let from whom = - sprintf "from %s" whom - [] let main argv = - [ - Chart.Line([1,2; 3,4]) - |> Chart.withAxisAnchor(Y=1) - Chart.Spline([100,200; 300,400]) - |> Chart.withAxisAnchor(Y=2) - ] - |> Chart.combine - |> Chart.withYAxis (LinearAxis.init(), Id = StyleParam.SubPlotId.YAxis 1) - |> Chart.withYAxis (LinearAxis.init(Anchor = StyleParam.LinearAxisId.Free, Shift = -50, ShowLine = true), Id = StyleParam.SubPlotId.YAxis 2) - |> Chart.withDescription [ - h1 [] [str "now look at this!"] - ul [] [ - li [] [str "this"] - li [] [str "is"] - li [] [str "a"] - li [] [img [_src "https://images.deepai.org/machine-learning-models/0c7ba850aa2443d7b40f9a45d9c86d3f/text2imgthumb.jpeg"]] - ] - ] - |> Chart.withSize(1000,1000) - |> Chart.show + 0 \ No newline at end of file diff --git a/tests/Plotly.NET.Tests/HtmlCodegen/MapboxMapCharts.fs b/tests/Plotly.NET.Tests/HtmlCodegen/MapboxMapCharts.fs index e8b965d41..d69f89051 100644 --- a/tests/Plotly.NET.Tests/HtmlCodegen/MapboxMapCharts.fs +++ b/tests/Plotly.NET.Tests/HtmlCodegen/MapboxMapCharts.fs @@ -11,12 +11,11 @@ open System open TestUtils.HtmlCodegen let baseLayerOnlyChart = - let mb = - Mapbox.init( - Style = StyleParam.MapboxStyle.OpenStreetMap - ) - Chart.PointMapbox(longitudes = [], latitudes = [], UseDefaults = false) // deliberately empty chart to show the base map only - |> Chart.withMapbox mb // add the mapBox + Chart.PointMapbox( + longitudes = [], + latitudes = [], + UseDefaults = false + ) // deliberately empty chart to show the base map only [] let ``Mapbox charts`` = @@ -55,7 +54,6 @@ let pointMapboxChart = ) |> Chart.withMapbox( Mapbox.init( - Style=StyleParam.MapboxStyle.OpenStreetMap, Center=(-104.6,50.45) ) ) @@ -98,7 +96,6 @@ let flightsChart = |> Chart.withLegend(false) |> Chart.withMapbox( Mapbox.init( - Style=StyleParam.MapboxStyle.OpenStreetMap, Center=(-97.0372,32.8959) ) ) @@ -121,7 +118,7 @@ let ``Scatter and line plots on Mapbox maps charts`` = |> chartGeneratedContains flightsChart ); testCase "Flights mapbox layout" ( fun () -> - "var layout = {\"showlegend\":false,\"mapbox\":{\"style\":\"open-street-map\",\"center\":{\"lon\":-97.0372,\"lat\":32.8959}},\"margin\":{\"l\":0,\"r\":0,\"t\":50,\"b\":0},\"title\":{\"text\":\"Feb. 2011 American Airline flights\"}};" + """var layout = {"mapbox":{"style":"open-street-map","center":{"lon":-97.0372,"lat":32.8959}},"showlegend":false,"margin":{"l":0,"r":0,"t":50,"b":0},"title":{"text":"Feb. 2011 American Airline flights"}};""" |> chartGeneratedContains flightsChart ); ]