From 0ee67e3e9251515d94a2f40858ed4fdd7398e104 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Thu, 9 Feb 2023 08:11:50 +0100 Subject: [PATCH] plotlyjs v2.16: Add clustering options to scattermapbox (https://github.com/plotly/plotly.js/pull/5827), add top level args for clustering --- src/Plotly.NET/ChartAPI/ChartMap.fs | 30 +++++++ src/Plotly.NET/ChartAPI/GenericChart.fs | 4 +- .../ObjectAbstractions/Map/MapboxCluster.fs | 79 +++++++++++++++++++ src/Plotly.NET/Plotly.NET.fsproj | 1 + src/Plotly.NET/Traces/TraceMapbox.fs | 3 + .../HtmlCodegen/ChartLayout.fs | 4 +- .../HtmlCodegen/MapboxMapCharts.fs | 6 +- .../HtmlCodegen/SimpleTests.fs | 4 +- 8 files changed, 122 insertions(+), 9 deletions(-) create mode 100644 src/Plotly.NET/Layout/ObjectAbstractions/Map/MapboxCluster.fs diff --git a/src/Plotly.NET/ChartAPI/ChartMap.fs b/src/Plotly.NET/ChartAPI/ChartMap.fs index 4e77d6cc0..fe0031a3b 100644 --- a/src/Plotly.NET/ChartAPI/ChartMap.fs +++ b/src/Plotly.NET/ChartAPI/ChartMap.fs @@ -1183,6 +1183,8 @@ module ChartMap = /// sets the drawing style of the line /// Sets the line (use this for more finegrained control than the other line-associated arguments) /// 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 "''". + /// Wether or not to enable clustering for points + /// Sets the clustering options (use this for more finegrained control than the other cluster-associated arguments) /// If set to false, ignore the global default settings set in `Defaults` [] static member ScatterMapbox @@ -1210,6 +1212,8 @@ module ChartMap = [] ?LineDash: StyleParam.DrawingStyle, [] ?Line: Line, [] ?Below: string, + [] ?EnableClustering: bool, + [] ?Cluster: MapboxCluster, [] ?UseDefaults: bool ) = @@ -1239,11 +1243,18 @@ module ChartMap = ?Width = LineWidth ) + let cluster = + Cluster + |> Option.defaultValue (MapboxCluster.init ()) + |> MapboxCluster.style( + ?Enabled = EnableClustering + ) TraceMapbox.initScatterMapbox ( TraceMapboxStyle.ScatterMapbox( Lon = longitudes, Lat = latitudes, + Cluster = cluster, Mode = mode, Marker = marker, Line = line, @@ -1291,6 +1302,8 @@ module ChartMap = /// sets the drawing style of the line /// Sets the line (use this for more finegrained control than the other line-associated arguments) /// 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 "''". + /// Wether or not to enable clustering for points + /// Sets the clustering options (use this for more finegrained control than the other cluster-associated arguments) /// If set to false, ignore the global default settings set in `Defaults` [] static member ScatterMapbox @@ -1317,6 +1330,8 @@ module ChartMap = [] ?LineDash: StyleParam.DrawingStyle, [] ?Line: Line, [] ?Below: string, + [] ?EnableClustering: bool, + [] ?Cluster: MapboxCluster, [] ?UseDefaults: bool ) = @@ -1346,6 +1361,8 @@ module ChartMap = ?LineDash = LineDash, ?Line = Line, ?Below = Below, + ?EnableClustering = EnableClustering, + ?Cluster = Cluster, ?UseDefaults = UseDefaults ) @@ -1373,6 +1390,8 @@ module ChartMap = /// Sets the marker symbol for each individual datum /// Sets the marker (use this for more finegrained control than the other marker-associated arguments) /// 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 "''". + /// Wether or not to enable clustering for points + /// Sets the clustering options (use this for more finegrained control than the other cluster-associated arguments) /// If set to false, ignore the global default settings set in `Defaults` [] static member PointMapbox @@ -1394,6 +1413,8 @@ module ChartMap = [] ?MultiMarkerSymbol: seq, [] ?Marker: Marker, [] ?Below: string, + [] ?EnableClustering: bool, + [] ?Cluster: MapboxCluster, [] ?UseDefaults: bool ) = @@ -1419,6 +1440,8 @@ module ChartMap = ?MultiMarkerSymbol = MultiMarkerSymbol, ?Marker = Marker, ?Below = Below, + ?EnableClustering = EnableClustering, + ?Cluster = Cluster, ?UseDefaults = UseDefaults ) @@ -1446,6 +1469,8 @@ module ChartMap = /// Sets the marker symbol for each individual datum /// Sets the marker (use this for more finegrained control than the other marker-associated arguments) /// 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 "''". + /// Wether or not to enable clustering for points + /// Sets the clustering options (use this for more finegrained control than the other cluster-associated arguments) /// If set to false, ignore the global default settings set in `Defaults` [] static member PointMapbox @@ -1466,6 +1491,8 @@ module ChartMap = [] ?MultiMarkerSymbol: seq, [] ?Marker: Marker, [] ?Below: string, + [] ?EnableClustering: bool, + [] ?Cluster: MapboxCluster, [] ?UseDefaults: bool ) = @@ -1489,6 +1516,8 @@ module ChartMap = ?MultiMarkerSymbol = MultiMarkerSymbol, ?Marker = Marker, ?Below = Below, + ?EnableClustering = EnableClustering, + ?Cluster = Cluster, ?UseDefaults = UseDefaults ) @@ -1723,6 +1752,7 @@ module ChartMap = [] ?MultiMarkerSymbol: seq, [] ?Marker: Marker, [] ?Below: string, + [] ?UseDefaults: bool ) = diff --git a/src/Plotly.NET/ChartAPI/GenericChart.fs b/src/Plotly.NET/ChartAPI/GenericChart.fs index 52dd7d605..d1ec7e1f0 100644 --- a/src/Plotly.NET/ChartAPI/GenericChart.fs +++ b/src/Plotly.NET/ChartAPI/GenericChart.fs @@ -15,7 +15,7 @@ module HTML = - + [ADDITIONAL_HEAD_TAGS]