From 46c49f785076b63e7937d91a15a3478235b456b6 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Fri, 19 Aug 2022 13:28:43 +0200 Subject: [PATCH 1/8] Add C# bindings for Chart.ChoroplethMap --- src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs | 55 +++++++++++++++++++ .../Plotly.NET.Tests.CSharpConsole/Program.cs | 7 ++- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs index 5319c6622..4881c153f 100644 --- a/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs @@ -12,6 +12,61 @@ namespace Plotly.NET.CSharp { public static partial class Chart { + /// + /// Creates a choropleth map using plotly's base geo map. + /// + /// 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. + /// + /// Sets the locations which will be colored. See LocationMode for more info. + /// The color values for each location + /// 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 optional GeoJSON data associated with this trace. If not given, the features on the base map are used. 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 key in GeoJSON features which is used as id to match the items included in the `locations` array. Only has an effect when `geojson` is set. Support nested property, for example "properties.name". + /// Sets the text elements associated with each location. + /// Sets the text elements associated with each location. + /// Sets the colorbar. + /// Sets the colorscale. + /// Determines whether or not a colorbar is displayed for this trace. + /// Reverses the color mapping if true. + /// Determines the set of locations used to match entries in `locations` to regions on the map. Values "ISO-3", "USA-states", "country names" correspond to features on the base map and value "geojson-id" corresponds to features from a custom GeoJSON linked to the `geojson` attribute. + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart ChoroplethMap( + IEnumerable locations, + IEnumerable z, + Optional Name = default, + Optional ShowLegend = default, + Optional GeoJson = default, + Optional FeatureIdKey = default, + Optional Text = default, + Optional> MultiText = default, + Optional ColorBar = default, + Optional ColorScale = default, + Optional ShowScale = default, + Optional ReverseScale = default, + Optional LocationMode = default, + Optional UseDefaults = default + ) + where ZType: IConvertible + where TextType : IConvertible + => + Plotly.NET.ChartMap.Chart.ChoroplethMap( + locations: locations, + z: z, + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + GeoJson: GeoJson.ToOption(), + FeatureIdKey: FeatureIdKey.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + ColorBar: ColorBar.ToOption(), + ColorScale: ColorScale.ToOption(), + ShowScale: ShowScale.ToOption(), + ReverseScale: ReverseScale.ToOption(), + LocationMode: LocationMode.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); + /// /// Creates a ScatterGeo chart, where data is visualized using plotly's base geo map. /// diff --git a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs index 5d6b7b8d4..1011292b5 100644 --- a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs +++ b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs @@ -424,6 +424,12 @@ static void Main(string[] args) Chart.Invisible(), //geo/mapbox traces + Chart.ChoroplethMap( + locations: new string [] {"USA", "Germany", "Australia"}, + z: new int [] {1, 2, 3}, + LocationMode: LocationFormat.CountryNames + ), + Chart.ScatterGeo( longitudes: new int [] { 1, 2 }, latitudes: new int [] { 3, 4 }, @@ -433,7 +439,6 @@ static void Main(string[] args) Chart.Invisible(), Chart.Invisible(), Chart.Invisible(), - Chart.Invisible(), Chart.DensityMapbox( longitudes: new int [] { 1,2,2,2,3,4,5,5 }, latitudes: new int [] { 1,2,2,2,3,4,5,5 }, From 333f9e96e460f28810cdefd437fe104a4acbafe6 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Fri, 19 Aug 2022 13:37:27 +0200 Subject: [PATCH 2/8] Add C# bindings for Chart.PointGeo --- src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs | 74 +++++++++++++++++++ .../Plotly.NET.Tests.CSharpConsole/Program.cs | 33 +++++++-- 2 files changed, 100 insertions(+), 7 deletions(-) diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs index 4881c153f..df10b6498 100644 --- a/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs @@ -161,6 +161,80 @@ public static GenericChart.GenericChart ScatterGeo + /// Creates a PointGeo chart. + /// + /// In general, PointGeo Plots plot two-dimensional data as points using plotly's base geo map. + /// + /// 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 + /// 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 + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the position of text associated with each datum + /// Sets the position of text associated with individual datum + /// Sets the color of the marker + /// Sets the colorscale of the marker + /// Sets the outline of the marker + /// Sets the marker symbol for each datum + /// Sets the marker symbol for each individual datum + /// Sets the marker (use this for more finegrained control than the other marker-associated arguments) + /// Determines the set of locations used to match entries in `locations` to regions on the map. Values "ISO-3", "USA-states", "country names" correspond to features on the base map and value "geojson-id" corresponds to features from a custom GeoJSON linked to the `geojson` attribute. + /// Sets optional GeoJSON data associated with this trace. If not given, the features on the base map are used. 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 key in GeoJSON features which is used as id to match the items included in the `locations` array. Only has an effect when `geojson` is set. Support nested property, for example "properties.name". + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart PointGeo( + IEnumerable longitudes, + IEnumerable latitudes, + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional> MultiOpacity = default, + Optional Text = default, + Optional> MultiText = default, + Optional TextPosition = default, + Optional> MultiTextPosition = default, + Optional MarkerColor = default, + Optional MarkerColorScale = default, + Optional MarkerOutline = default, + Optional MarkerSymbol = default, + Optional> MultiMarkerSymbol = default, + Optional Marker = default, + Optional LocationMode = default, + Optional GeoJson = default, + Optional FeatureIdKey = default, + Optional UseDefaults = default + ) + where LongitudesType : IConvertible + where LatitudesType : IConvertible + where TextType : IConvertible + => + Plotly.NET.ChartMap.Chart.PointGeo( + longitudes: longitudes, + latitudes: latitudes, + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), + MultiOpacity: MultiOpacity.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + TextPosition: TextPosition.ToOption(), + MultiTextPosition: MultiTextPosition.ToOption(), + MarkerColor: MarkerColor.ToOption(), + MarkerColorScale: MarkerColorScale.ToOption(), + MarkerOutline: MarkerOutline.ToOption(), + MarkerSymbol: MarkerSymbol.ToOption(), + MultiMarkerSymbol: MultiMarkerSymbol.ToOption(), + Marker: Marker.ToOption(), + LocationMode: LocationMode.ToOption(), + GeoJson: GeoJson.ToOption(), + FeatureIdKey: FeatureIdKey.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); + /// /// 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. /// diff --git a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs index 1011292b5..e084238c7 100644 --- a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs +++ b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs @@ -424,16 +424,35 @@ static void Main(string[] args) Chart.Invisible(), //geo/mapbox traces + Chart.Combine( + new GenericChart [] + { + Chart.ScatterGeo( + longitudes: new int [] { 1, 20 }, + latitudes: new int [] { 1, 40 }, + mode: Mode.Markers, + Name: "scattergeo" + ), + Chart.PointGeo( + longitudes: new int [] { 40, 50 }, + latitudes: new int [] { 60, 70 }, + Name: "pointgeo" + ), + } + ).WithTraceInfo( + LegendGroup: "scattergeo-derived", + LegendGroupTitle: Plotly.NET.Title.init("scattergeo derived traces", Font: Plotly.NET.Font.init(Size: 20)) + ), Chart.ChoroplethMap( locations: new string [] {"USA", "Germany", "Australia"}, z: new int [] {1, 2, 3}, - LocationMode: LocationFormat.CountryNames - ), - - Chart.ScatterGeo( - longitudes: new int [] { 1, 2 }, - latitudes: new int [] { 3, 4 }, - mode: Mode.Markers + LocationMode: LocationFormat.CountryNames, + ShowScale: false, + ShowLegend: true, + Name: "choropleth" + ).WithTraceInfo( + LegendGroup: "other-geo", + LegendGroupTitle: Plotly.NET.Title.init("other geo charts", Font: Plotly.NET.Font.init(Size: 20)) ), Chart.Invisible(), Chart.Invisible(), From 1fb3456df6b58412800392340b64efcba9d2cc86 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Fri, 19 Aug 2022 13:50:36 +0200 Subject: [PATCH 3/8] Add C# bindings for Chart.LineGeo --- src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs | 96 ++++++++++++++++++- .../Plotly.NET.Tests.CSharpConsole/Program.cs | 5 + 2 files changed, 99 insertions(+), 2 deletions(-) diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs index df10b6498..2c723378f 100644 --- a/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs @@ -124,7 +124,7 @@ public static GenericChart.GenericChart ScatterGeo LineDash = default, Optional Line = default, Optional LocationMode = default, - Optional GeoJson = default, + Optional GeoJson = default, Optional FeatureIdKey = default, Optional UseDefaults = default ) @@ -204,7 +204,7 @@ public static GenericChart.GenericChart PointGeo> MultiMarkerSymbol = default, Optional Marker = default, Optional LocationMode = default, - Optional GeoJson = default, + Optional GeoJson = default, Optional FeatureIdKey = default, Optional UseDefaults = default ) @@ -235,6 +235,98 @@ public static GenericChart.GenericChart PointGeo + /// Creates a LineGeo chart. + /// + /// In general, LineGeo Plots plot two-dimensional data connected by lines using plotly's base geo map. + /// + /// 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 + /// 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 + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the position of text associated with each datum + /// Sets the position of text associated with individual datum + /// Sets the color of the marker + /// Sets the colorscale of the marker + /// Sets the outline of the marker + /// Sets the marker symbol for each datum + /// Sets the marker symbol for each individual datum + /// Sets the marker (use this for more finegrained control than the other marker-associated arguments) + /// Sets the color of the line + /// Sets the colorscale of the line + /// Sets the width of the line + /// sets the drawing style of the line + /// Sets the line (use this for more finegrained control than the other line-associated arguments) + /// Determines the set of locations used to match entries in `locations` to regions on the map. Values "ISO-3", "USA-states", "country names" correspond to features on the base map and value "geojson-id" corresponds to features from a custom GeoJSON linked to the `geojson` attribute. + /// Sets optional GeoJSON data associated with this trace. If not given, the features on the base map are used. 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 key in GeoJSON features which is used as id to match the items included in the `locations` array. Only has an effect when `geojson` is set. Support nested property, for example "properties.name". + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart LineGeo( + IEnumerable longitudes, + IEnumerable latitudes, + Optional ShowMarkers = default, + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional> MultiOpacity = default, + Optional Text = default, + Optional> MultiText = default, + Optional TextPosition = default, + Optional> MultiTextPosition = default, + Optional MarkerColor = default, + Optional MarkerColorScale = default, + Optional MarkerOutline = default, + Optional MarkerSymbol = default, + Optional> MultiMarkerSymbol = default, + Optional Marker = default, + Optional LineColor = default, + Optional LineColorScale = default, + Optional LineWidth = default, + Optional LineDash = default, + Optional Line = default, + Optional LocationMode = default, + Optional GeoJson = default, + Optional FeatureIdKey = default, + Optional UseDefaults = default + ) + where LongitudesType : IConvertible + where LatitudesType : IConvertible + where TextType : IConvertible + => + Plotly.NET.ChartMap.Chart.LineGeo( + longitudes: longitudes, + latitudes: latitudes, + ShowMarkers: ShowMarkers.ToOption(), + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), + MultiOpacity: MultiOpacity.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + TextPosition: TextPosition.ToOption(), + MultiTextPosition: MultiTextPosition.ToOption(), + MarkerColor: MarkerColor.ToOption(), + MarkerColorScale: MarkerColorScale.ToOption(), + MarkerOutline: MarkerOutline.ToOption(), + MarkerSymbol: MarkerSymbol.ToOption(), + MultiMarkerSymbol: MultiMarkerSymbol.ToOption(), + Marker: Marker.ToOption(), + LineColor: LineColor.ToOption(), + LineColorScale: LineColorScale.ToOption(), + LineWidth: LineWidth.ToOption(), + LineDash: LineDash.ToOption(), + Line: Line.ToOption(), + LocationMode: LocationMode.ToOption(), + GeoJson: GeoJson.ToOption(), + FeatureIdKey: FeatureIdKey.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); + /// /// 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. /// diff --git a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs index e084238c7..56821fc36 100644 --- a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs +++ b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs @@ -437,6 +437,11 @@ static void Main(string[] args) longitudes: new int [] { 40, 50 }, latitudes: new int [] { 60, 70 }, Name: "pointgeo" + ), + Chart.LineGeo( + longitudes: new int [] { 10, -100}, + latitudes: new int [] { 50, 50 }, + Name: "linegeo" ), } ).WithTraceInfo( From 51ea960fd5e53bdae4c8c2d42a810d483acd8e50 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Fri, 19 Aug 2022 13:56:51 +0200 Subject: [PATCH 4/8] Add C# bindings or Chart.BubbleGeo --- src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs | 77 +++++++++++++++++++ .../Plotly.NET.Tests.CSharpConsole/Program.cs | 6 ++ 2 files changed, 83 insertions(+) diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs index 2c723378f..a24ca96f8 100644 --- a/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs @@ -327,6 +327,83 @@ public static GenericChart.GenericChart LineGeo + /// Creates a BubbleGeo chart. + /// + /// In general, BubbleGeo Plots plot two-dimensional data as points using plotly's base geo map, additionally using the point size as a third dimension. + /// + /// Sets the longitude coordinates (in degrees East). + /// 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 + /// 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 + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the position of text associated with each datum + /// Sets the position of text associated with individual datum + /// Sets the color of the marker + /// Sets the colorscale of the marker + /// Sets the outline of the marker + /// Sets the marker symbol for each datum + /// Sets the marker symbol for each individual datum + /// Sets the marker (use this for more finegrained control than the other marker-associated arguments) + /// Determines the set of locations used to match entries in `locations` to regions on the map. Values "ISO-3", "USA-states", "country names" correspond to features on the base map and value "geojson-id" corresponds to features from a custom GeoJSON linked to the `geojson` attribute. + /// Sets optional GeoJSON data associated with this trace. If not given, the features on the base map are used. 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 key in GeoJSON features which is used as id to match the items included in the `locations` array. Only has an effect when `geojson` is set. Support nested property, for example "properties.name". + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart BubbleGeo( + IEnumerable longitudes, + IEnumerable latitudes, + IEnumerable sizes, + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional> MultiOpacity = default, + Optional Text = default, + Optional> MultiText = default, + Optional TextPosition = default, + Optional> MultiTextPosition = default, + Optional MarkerColor = default, + Optional MarkerColorScale = default, + Optional MarkerOutline = default, + Optional MarkerSymbol = default, + Optional> MultiMarkerSymbol = default, + Optional Marker = default, + Optional LocationMode = default, + Optional GeoJson = default, + Optional FeatureIdKey = default, + Optional UseDefaults = default + ) + where LongitudesType : IConvertible + where LatitudesType : IConvertible + where TextType : IConvertible + => + Plotly.NET.ChartMap.Chart.BubbleGeo( + longitudes: longitudes, + latitudes: latitudes, + sizes: sizes, + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), + MultiOpacity: MultiOpacity.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + TextPosition: TextPosition.ToOption(), + MultiTextPosition: MultiTextPosition.ToOption(), + MarkerColor: MarkerColor.ToOption(), + MarkerColorScale: MarkerColorScale.ToOption(), + MarkerOutline: MarkerOutline.ToOption(), + MarkerSymbol: MarkerSymbol.ToOption(), + MultiMarkerSymbol: MultiMarkerSymbol.ToOption(), + Marker: Marker.ToOption(), + LocationMode: LocationMode.ToOption(), + GeoJson: GeoJson.ToOption(), + FeatureIdKey: FeatureIdKey.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); + /// /// 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. /// diff --git a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs index 56821fc36..99829df66 100644 --- a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs +++ b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs @@ -442,6 +442,12 @@ static void Main(string[] args) longitudes: new int [] { 10, -100}, latitudes: new int [] { 50, 50 }, Name: "linegeo" + ), + Chart.BubbleGeo( + longitudes: new int [] { 80, -80}, + latitudes: new int [] { 20, -20 }, + sizes: new int [] { 10, 20 }, + Name: "bubblegeo" ), } ).WithTraceInfo( From 21d4422f63e8fb19a0eb0aa012686374fcaada32 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Fri, 19 Aug 2022 14:21:25 +0200 Subject: [PATCH 5/8] Add C# bindings for Chart.ScatterMapbox --- src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs | 90 +++++++++++++++++++ .../Plotly.NET.Tests.CSharpConsole/Program.cs | 46 ++++++++-- 2 files changed, 131 insertions(+), 5 deletions(-) diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs index a24ca96f8..667b06834 100644 --- a/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs @@ -404,6 +404,96 @@ public static GenericChart.GenericChart BubbleGeo + /// Creates a ScatterMapbox chart, where data is visualized on a geographic map using mapbox. + /// + /// Customize the mapbox layers, style, etc. by using Chart.withMapbox. + /// + /// You might need a Mapbox token, which you can also configure with Chart.withMapbox. + /// + /// ScatterMapbox charts are the basis of PointMapbox, LineMapbox, and BubbleMapbox Charts, and can be customized as such. We also provide abstractions for those: Chart.PointMapbox, Chart.LineMapbox, Chart.BubbleMapbox + /// + /// Sets the longitude coordinates (in degrees East). + /// Sets the latitude coordinates (in 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 + /// 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 + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the position of text associated with each datum + /// Sets the position of text associated with individual datum + /// Sets the color of the marker + /// Sets the colorscale of the marker + /// Sets the outline of the marker + /// Sets the marker symbol for each datum + /// Sets the marker symbol for each individual datum + /// Sets the marker (use this for more finegrained control than the other marker-associated arguments) + /// Sets the color of the line + /// Sets the colorscale of the line + /// Sets the width of the line + /// 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 "''". + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart ScatterMapbox( + IEnumerable longitudes, + IEnumerable latitudes, + StyleParam.Mode mode, + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional> MultiOpacity = default, + Optional Text = default, + Optional> MultiText = default, + Optional TextPosition = default, + Optional> MultiTextPosition = default, + Optional MarkerColor = default, + Optional MarkerColorScale = default, + Optional MarkerOutline = default, + Optional MarkerSymbol = default, + Optional> MultiMarkerSymbol = default, + Optional Marker = default, + Optional LineColor = default, + Optional LineColorScale = default, + Optional LineWidth = default, + Optional LineDash = default, + Optional Line = default, + Optional Below = default, + Optional UseDefaults = default + ) + where LongitudesType : IConvertible + where LatitudesType : IConvertible + where TextType : IConvertible + => + Plotly.NET.ChartMap.Chart.ScatterMapbox( + longitudes: longitudes, + latitudes: latitudes, + mode: mode, + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), + MultiOpacity: MultiOpacity.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + TextPosition: TextPosition.ToOption(), + MultiTextPosition: MultiTextPosition.ToOption(), + MarkerColor: MarkerColor.ToOption(), + MarkerColorScale: MarkerColorScale.ToOption(), + MarkerOutline: MarkerOutline.ToOption(), + MarkerSymbol: MarkerSymbol.ToOption(), + MultiMarkerSymbol: MultiMarkerSymbol.ToOption(), + Marker: Marker.ToOption(), + LineColor: LineColor.ToOption(), + LineColorScale: LineColorScale.ToOption(), + LineWidth: LineWidth.ToOption(), + LineDash: LineDash.ToOption(), + Line: Line.ToOption(), + Below: Below.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); + /// /// 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. /// diff --git a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs index 99829df66..a2671c196 100644 --- a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs +++ b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs @@ -465,17 +465,53 @@ static void Main(string[] args) LegendGroup: "other-geo", LegendGroupTitle: Plotly.NET.Title.init("other geo charts", Font: Plotly.NET.Font.init(Size: 20)) ), - Chart.Invisible(), - Chart.Invisible(), - Chart.Invisible(), - Chart.Invisible(), + Chart.Combine( + new GenericChart [] + { + Chart.ScatterMapbox( + longitudes: new int [] { 1, 20 }, + latitudes: new int [] { 1, 40 }, + mode: Mode.Markers, + Name: "scattermapbox" + ) + //Chart.PointMapbox( + // longitudes: new int [] { 40, 50 }, + // latitudes: new int [] { 60, 70 }, + // Name: "pointgeo" + //), + //Chart.LineMapbox( + // longitudes: new int [] { 10, -100}, + // latitudes: new int [] { 50, 50 }, + // Name: "linemapbox" + //), + //Chart.BubbleMapbox( + // longitudes: new int [] { 80, -80}, + // latitudes: new int [] { 20, -20 }, + // sizes: new int [] { 10, 20 }, + // Name: "bubblemapbox" + //), + } + ).WithMaboxStyle( + Style: MapboxStyle.OpenStreetMap, + Id: 38 + ).WithTraceInfo( + LegendGroup: "scattermapbox-derived", + LegendGroupTitle: Plotly.NET.Title.init("scattermapbox derived traces", Font: Plotly.NET.Font.init(Size: 20)) + ), Chart.DensityMapbox( longitudes: new int [] { 1,2,2,2,3,4,5,5 }, latitudes: new int [] { 1,2,2,2,3,4,5,5 }, ShowScale: false ).WithMaboxStyle( - Style: MapboxStyle.OpenStreetMap + Style: MapboxStyle.OpenStreetMap, + Id: 39 + ).WithTraceInfo( + LegendGroup: "other-mapbox", + LegendGroupTitle: Plotly.NET.Title.init("other mapbox charts", Font: Plotly.NET.Font.init(Size: 20)) ), + Chart.Invisible(), + Chart.Invisible(), + Chart.Invisible(), //ternary traces Chart.ScatterTernary( From 6551adb9c3020e2929a6d780b33464f156afe14b Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Fri, 19 Aug 2022 14:32:08 +0200 Subject: [PATCH 6/8] Add C# bindings for Chart.LineMapbox --- src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs | 158 ++++++++++++++++++ .../Plotly.NET.Tests.CSharpConsole/Program.cs | 26 +-- 2 files changed, 171 insertions(+), 13 deletions(-) diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs index 667b06834..f841ca085 100644 --- a/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs @@ -494,6 +494,164 @@ public static GenericChart.GenericChart ScatterMapbox + /// Creates a PointMapbox chart, where data is visualized on a geographic map as points using mapbox. + /// + /// Customize the mapbox layers, style, etc. by using Chart.withMapbox. + /// + /// You might need a Mapbox token, which you can also configure with Chart.withMapbox. + /// + /// 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 + /// 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 + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the position of text associated with each datum + /// Sets the position of text associated with individual datum + /// Sets the color of the marker + /// Sets the colorscale of the marker + /// Sets the outline of the marker + /// Sets the marker symbol for each datum + /// 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 "''". + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart PointMapbox( + IEnumerable longitudes, + IEnumerable latitudes, + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional> MultiOpacity = default, + Optional Text = default, + Optional> MultiText = default, + Optional TextPosition = default, + Optional> MultiTextPosition = default, + Optional MarkerColor = default, + Optional MarkerColorScale = default, + Optional MarkerOutline = default, + Optional MarkerSymbol = default, + Optional> MultiMarkerSymbol = default, + Optional Marker = default, + Optional Below = default, + Optional UseDefaults = default + ) + where LongitudesType : IConvertible + where LatitudesType : IConvertible + where TextType : IConvertible + => + Plotly.NET.ChartMap.Chart.PointMapbox( + longitudes: longitudes, + latitudes: latitudes, + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), + MultiOpacity: MultiOpacity.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + TextPosition: TextPosition.ToOption(), + MultiTextPosition: MultiTextPosition.ToOption(), + MarkerColor: MarkerColor.ToOption(), + MarkerColorScale: MarkerColorScale.ToOption(), + MarkerOutline: MarkerOutline.ToOption(), + MarkerSymbol: MarkerSymbol.ToOption(), + MultiMarkerSymbol: MultiMarkerSymbol.ToOption(), + Marker: Marker.ToOption(), + Below: Below.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); + + /// + /// Creates a LineMapbox chart, where data is visualized on a geographic map connected by a line using mapbox. + /// + /// Customize the mapbox layers, style, etc. by using Chart.withMapbox. + /// + /// You might need a Mapbox token, which you can also configure with Chart.withMapbox. + /// + /// 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 + /// 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 + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the position of text associated with each datum + /// Sets the position of text associated with individual datum + /// Sets the color of the marker + /// Sets the colorscale of the marker + /// Sets the outline of the marker + /// Sets the marker symbol for each datum + /// Sets the marker symbol for each individual datum + /// Sets the marker (use this for more finegrained control than the other marker-associated arguments) + /// Sets the color of the line + /// Sets the colorscale of the line + /// Sets the width of the line + /// 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 "''". + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart LineMapbox( + IEnumerable longitudes, + IEnumerable latitudes, + Optional ShowMarkers = default, + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional> MultiOpacity = default, + Optional Text = default, + Optional> MultiText = default, + Optional TextPosition = default, + Optional> MultiTextPosition = default, + Optional MarkerColor = default, + Optional MarkerColorScale = default, + Optional MarkerOutline = default, + Optional MarkerSymbol = default, + Optional> MultiMarkerSymbol = default, + Optional Marker = default, + Optional LineColor = default, + Optional LineColorScale = default, + Optional LineWidth = default, + Optional LineDash = default, + Optional Line = default, + Optional Below = default, + Optional UseDefaults = default + ) + where LongitudesType : IConvertible + where LatitudesType : IConvertible + where TextType : IConvertible + => + Plotly.NET.ChartMap.Chart.LineMapbox( + longitudes: longitudes, + latitudes: latitudes, + ShowMarkers: ShowMarkers.ToOption(), + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), + MultiOpacity: MultiOpacity.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + TextPosition: TextPosition.ToOption(), + MultiTextPosition: MultiTextPosition.ToOption(), + MarkerColor: MarkerColor.ToOption(), + MarkerColorScale: MarkerColorScale.ToOption(), + MarkerOutline: MarkerOutline.ToOption(), + MarkerSymbol: MarkerSymbol.ToOption(), + MultiMarkerSymbol: MultiMarkerSymbol.ToOption(), + Marker: Marker.ToOption(), + LineColor: LineColor.ToOption(), + LineColorScale: LineColorScale.ToOption(), + LineWidth: LineWidth.ToOption(), + LineDash: LineDash.ToOption(), + Line: Line.ToOption(), + Below: Below.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); + /// /// 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. /// diff --git a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs index a2671c196..23816a873 100644 --- a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs +++ b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs @@ -469,21 +469,21 @@ static void Main(string[] args) new GenericChart [] { Chart.ScatterMapbox( - longitudes: new int [] { 1, 20 }, - latitudes: new int [] { 1, 40 }, + longitudes: new int [] { 1, 2 }, + latitudes: new int [] { 1, 2 }, mode: Mode.Markers, Name: "scattermapbox" - ) - //Chart.PointMapbox( - // longitudes: new int [] { 40, 50 }, - // latitudes: new int [] { 60, 70 }, - // Name: "pointgeo" - //), - //Chart.LineMapbox( - // longitudes: new int [] { 10, -100}, - // latitudes: new int [] { 50, 50 }, - // Name: "linemapbox" - //), + ), + Chart.PointMapbox( + longitudes: new int [] { 10, 11 }, + latitudes: new int [] { 10, 11 }, + Name: "pointmapbox" + ), + Chart.LineMapbox( + longitudes: new int [] { -1, 11}, + latitudes: new int [] { 11, 1 }, + Name: "linemapbox" + ), //Chart.BubbleMapbox( // longitudes: new int [] { 80, -80}, // latitudes: new int [] { 20, -20 }, From 733d4cb7a0c14e6ddec27dd8a2f8cc68cacdb0dc Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Fri, 19 Aug 2022 14:35:38 +0200 Subject: [PATCH 7/8] Add C# binding for Chart.BubbleMapbox --- src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs | 73 +++++++++++++++++++ .../Plotly.NET.Tests.CSharpConsole/Program.cs | 12 +-- 2 files changed, 79 insertions(+), 6 deletions(-) diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs index f841ca085..27f7fa696 100644 --- a/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs @@ -652,6 +652,79 @@ public static GenericChart.GenericChart LineMapbox + /// 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. + /// + /// Customize the mapbox layers, style, etc. by using Chart.withMapbox. + /// + /// You might need a Mapbox token, which you can also configure with Chart.withMapbox. + /// + /// Sets the longitude coordinates (in degrees East). + /// 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 + /// 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 + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the position of text associated with each datum + /// Sets the position of text associated with individual datum + /// Sets the color of the marker + /// Sets the colorscale of the marker + /// Sets the outline of the marker + /// Sets the marker symbol for each datum + /// 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 "''". + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart BubbleMapbox( + IEnumerable longitudes, + IEnumerable latitudes, + IEnumerable sizes, + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional> MultiOpacity = default, + Optional Text = default, + Optional> MultiText = default, + Optional TextPosition = default, + Optional> MultiTextPosition = default, + Optional MarkerColor = default, + Optional MarkerColorScale = default, + Optional MarkerOutline = default, + Optional MarkerSymbol = default, + Optional> MultiMarkerSymbol = default, + Optional Marker = default, + Optional Below = default, + Optional UseDefaults = default + ) + where LongitudesType : IConvertible + where LatitudesType : IConvertible + where TextType : IConvertible + => + Plotly.NET.ChartMap.Chart.BubbleMapbox( + longitudes: longitudes, + latitudes: latitudes, + sizes: sizes, + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), + MultiOpacity: MultiOpacity.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + TextPosition: TextPosition.ToOption(), + MultiTextPosition: MultiTextPosition.ToOption(), + MarkerColor: MarkerColor.ToOption(), + MarkerColorScale: MarkerColorScale.ToOption(), + MarkerOutline: MarkerOutline.ToOption(), + MarkerSymbol: MarkerSymbol.ToOption(), + MultiMarkerSymbol: MultiMarkerSymbol.ToOption(), + Marker: Marker.ToOption(), + Below: Below.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); + /// /// 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. /// diff --git a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs index 23816a873..c929311df 100644 --- a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs +++ b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs @@ -484,12 +484,12 @@ static void Main(string[] args) latitudes: new int [] { 11, 1 }, Name: "linemapbox" ), - //Chart.BubbleMapbox( - // longitudes: new int [] { 80, -80}, - // latitudes: new int [] { 20, -20 }, - // sizes: new int [] { 10, 20 }, - // Name: "bubblemapbox" - //), + Chart.BubbleMapbox( + longitudes: new int [] { 22, -11}, + latitudes: new int [] { 5, 5 }, + sizes: new int [] { 10, 20 }, + Name: "bubblemapbox" + ), } ).WithMaboxStyle( Style: MapboxStyle.OpenStreetMap, From e2c2563e6e6e2ccdbfdf16009a2d434d38976c31 Mon Sep 17 00:00:00 2001 From: Kevin Schneider Date: Fri, 19 Aug 2022 14:47:15 +0200 Subject: [PATCH 8/8] Add C# binding for Chart.ChoroplethMapbox --- src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs index 27f7fa696..270cbfcb3 100644 --- a/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs @@ -725,6 +725,67 @@ public static GenericChart.GenericChart BubbleMapbox + /// 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. + /// + /// Sets the coordinates via location IDs or names. Coordinates correspond to the centroid of each location given. See `locationmode` for more info. + /// 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. + /// 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 + /// Sets individual text for each datum + /// Sets the colorbar. + /// Sets the colorscale. + /// Determines whether or not a colorbar is displayed for this trace. + /// Reverses the color mapping if true. + /// 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 "''". + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart ChoroplethMapbox( + IEnumerable locations, + IEnumerable z, + object geoJson, + Optional Name = default, + Optional ShowLegend = default, + Optional FeatureIdKey = default, + Optional Text = default, + Optional> MultiText = default, + Optional ColorBar = default, + Optional ColorScale = default, + Optional ShowScale = default, + Optional ReverseScale = default, + Optional Below = default, + Optional UseDefaults = default + ) + where ZType : IConvertible + where TextType : IConvertible + => + Plotly.NET.ChartMap.Chart.ChoroplethMapbox( + locations: locations, + z: z, + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + geoJson: geoJson, + FeatureIdKey: FeatureIdKey.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + ColorBar: ColorBar.ToOption(), + ColorScale: ColorScale.ToOption(), + ShowScale: ShowScale.ToOption(), + ReverseScale: ReverseScale.ToOption(), + Below: Below.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); + /// /// 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. ///