diff --git a/src/Plotly.NET.CSharp/ChartAPI/Chart.cs b/src/Plotly.NET.CSharp/ChartAPI/Chart.cs index 73f0dfeb4..0e5e5ffee 100644 --- a/src/Plotly.NET.CSharp/ChartAPI/Chart.cs +++ b/src/Plotly.NET.CSharp/ChartAPI/Chart.cs @@ -6,6 +6,7 @@ using Plotly.NET; using Plotly.NET.LayoutObjects; using Plotly.NET.TraceObjects; +using System.Runtime.InteropServices; namespace Plotly.NET.CSharp { @@ -36,30 +37,30 @@ public static GenericChart.GenericChart Grid( IEnumerable gCharts, int nRows, int nCols, - Tuple[][]? SubPlots = null, - StyleParam.LinearAxisId[]? XAxes = null, - StyleParam.LinearAxisId[]? YAxes = null, - StyleParam.LayoutGridRowOrder? RowOrder = null, - StyleParam.LayoutGridPattern? Pattern = null, - double? XGap = null, - double? YGap = null, - Domain? Domain = null, - StyleParam.LayoutGridXSide? XSide = null, - StyleParam.LayoutGridYSide? YSide = null + Optional[][]> SubPlots = default, + Optional XAxes = default, + Optional YAxes = default, + Optional RowOrder = default, + Optional Pattern = default, + Optional XGap = default, + Optional YGap = default, + Optional Domain = default, + Optional XSide = default, + Optional YSide = default ) => Plotly.NET.Chart.Grid>( nRows: nRows, nCols: nCols, - SubPlots: Helpers.ToOption(SubPlots), - XAxes: Helpers.ToOption(XAxes), - YAxes: Helpers.ToOption(YAxes), - RowOrder: Helpers.ToOption(RowOrder), - Pattern: Helpers.ToOption(Pattern), - XGap: Helpers.ToOptionV(XGap), - YGap: Helpers.ToOptionV(YGap), - Domain: Helpers.ToOption(Domain), - XSide: Helpers.ToOption(XSide), - YSide: Helpers.ToOption(YSide) + SubPlots: SubPlots.ToOption(), + XAxes: XAxes.ToOption(), + YAxes: YAxes.ToOption(), + RowOrder: RowOrder.ToOption(), + Pattern: Pattern.ToOption(), + XGap: XGap.ToOption(), + YGap: YGap.ToOption(), + Domain: Domain.ToOption(), + XSide: XSide.ToOption(), + YSide: YSide.ToOption() ).Invoke(gCharts); } } diff --git a/src/Plotly.NET.CSharp/ChartAPI/Chart2D.cs b/src/Plotly.NET.CSharp/ChartAPI/Chart2D.cs index ead50d7d4..b2a59d6e8 100644 --- a/src/Plotly.NET.CSharp/ChartAPI/Chart2D.cs +++ b/src/Plotly.NET.CSharp/ChartAPI/Chart2D.cs @@ -6,6 +6,7 @@ using Plotly.NET; using Plotly.NET.LayoutObjects; using Plotly.NET.TraceObjects; +using System.Runtime.InteropServices; namespace Plotly.NET.CSharp { @@ -49,67 +50,67 @@ public static GenericChart.GenericChart Scatter( IEnumerable x, IEnumerable y, StyleParam.Mode mode, - string? Name = null, - bool? ShowLegend = null, - double? Opacity = null, - IEnumerable? MultiOpacity = null, - TextType? Text = null, - IEnumerable? MultiText = null, - StyleParam.TextPosition? TextPosition = null, - IEnumerable? MultiTextPosition = null, - Color? MarkerColor = null, - StyleParam.Colorscale? MarkerColorScale = null, - Line? MarkerOutline = null, - StyleParam.MarkerSymbol? MarkerSymbol = null, - IEnumerable? MultiMarkerSymbol = null, - Marker? Marker = null, - Color? LineColor = null, - StyleParam.Colorscale? LineColorScale = null, - double? LineWidth = null, - StyleParam.DrawingStyle? LineDash = null, - Line? Line = null, - string? StackGroup = null, - StyleParam.Orientation? Orientation = null, - StyleParam.GroupNorm? GroupNorm = null, - StyleParam.Fill? Fill = null, - Color? FillColor = null, - bool? UseWebGL = null, - bool? UseDefaults = null + 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 StackGroup = default, + Optional Orientation = default, + Optional GroupNorm = default, + Optional Fill = default, + Optional FillColor = default, + Optional UseWebGL = default, + Optional UseDefaults = default ) where XType : IConvertible where YType : IConvertible - where TextType : class, IConvertible + where TextType : IConvertible => Plotly.NET.Chart2D.Chart.Scatter( x: x, y: y, mode: mode, - Name: Helpers.ToOption(Name), - ShowLegend: Helpers.ToOptionV(ShowLegend), - Opacity: Helpers.ToOptionV(Opacity), - MultiOpacity: Helpers.ToOption(MultiOpacity), - Text: Helpers.ToOption(Text), - MultiText: Helpers.ToOption(MultiText), - TextPosition: Helpers.ToOption(TextPosition), - MultiTextPosition: Helpers.ToOption(MultiTextPosition), - MarkerColor: Helpers.ToOption(MarkerColor), - MarkerColorScale: Helpers.ToOption(MarkerColorScale), - MarkerOutline: Helpers.ToOption(MarkerOutline), - MarkerSymbol: Helpers.ToOption(MarkerSymbol), - MultiMarkerSymbol: Helpers.ToOption(MultiMarkerSymbol), - Marker: Helpers.ToOption(Marker), - LineColor: Helpers.ToOption(LineColor), - LineColorScale: Helpers.ToOption(LineColorScale), - LineWidth: Helpers.ToOptionV(LineWidth), - LineDash: Helpers.ToOption(LineDash), - Line: Helpers.ToOption(Line), - StackGroup: Helpers.ToOption(StackGroup), - Orientation: Helpers.ToOption(Orientation), - GroupNorm: Helpers.ToOption(GroupNorm), - Fill: Helpers.ToOption(Fill), - FillColor: Helpers.ToOption(FillColor), - UseWebGL: Helpers.ToOptionV(UseWebGL), - UseDefaults: Helpers.ToOptionV(UseDefaults) + 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(), + StackGroup: StackGroup.ToOption(), + Orientation: Orientation.ToOption(), + GroupNorm: GroupNorm.ToOption(), + Fill: Fill.ToOption(), + FillColor: FillColor.ToOption(), + UseWebGL: UseWebGL.ToOption(), + UseDefaults: UseDefaults.ToOption() ); /// @@ -139,52 +140,52 @@ public static GenericChart.GenericChart Scatter( public static GenericChart.GenericChart Point( IEnumerable x, IEnumerable y, - string? Name = null, - bool? ShowLegend = null, - double? Opacity = null, - IEnumerable? MultiOpacity = null, - TextType? Text = null, - IEnumerable? MultiText = null, - StyleParam.TextPosition? TextPosition = null, - IEnumerable? MultiTextPosition = null, - Color? MarkerColor = null, - StyleParam.Colorscale? MarkerColorScale = null, - Line? MarkerOutline = null, - StyleParam.MarkerSymbol? MarkerSymbol = null, - IEnumerable? MultiMarkerSymbol = null, - Marker? Marker = null, - string? StackGroup = null, - StyleParam.Orientation? Orientation = null, - StyleParam.GroupNorm? GroupNorm = null, - bool? UseWebGL = null, - bool? UseDefaults = null + 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 StackGroup = default, + Optional Orientation = default, + Optional GroupNorm = default, + Optional UseWebGL = default, + Optional UseDefaults = default ) where XType : IConvertible where YType : IConvertible - where TextType : class, IConvertible + where TextType : IConvertible => Plotly.NET.Chart2D.Chart.Point( x: x, y: y, - Name: Helpers.ToOption(Name), - ShowLegend: Helpers.ToOptionV(ShowLegend), - Opacity: Helpers.ToOptionV(Opacity), - MultiOpacity: Helpers.ToOption(MultiOpacity), - Text: Helpers.ToOption(Text), - MultiText: Helpers.ToOption(MultiText), - TextPosition: Helpers.ToOption(TextPosition), - MultiTextPosition: Helpers.ToOption(MultiTextPosition), - MarkerColor: Helpers.ToOption(MarkerColor), - MarkerColorScale: Helpers.ToOption(MarkerColorScale), - MarkerOutline: Helpers.ToOption(MarkerOutline), - MarkerSymbol: Helpers.ToOption(MarkerSymbol), - MultiMarkerSymbol: Helpers.ToOption(MultiMarkerSymbol), - Marker: Helpers.ToOption(Marker), - StackGroup: Helpers.ToOption(StackGroup), - Orientation: Helpers.ToOption(Orientation), - GroupNorm: Helpers.ToOption(GroupNorm), - UseWebGL: Helpers.ToOptionV(UseWebGL), - UseDefaults: Helpers.ToOptionV(UseDefaults) + 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(), + StackGroup: StackGroup.ToOption(), + Orientation: Orientation.ToOption(), + GroupNorm: GroupNorm.ToOption(), + UseWebGL: UseWebGL.ToOption(), + UseDefaults: UseDefaults.ToOption() ); /// Creates a Line chart, which uses a Line plotted between the given datums in a 2D space to visualize typically an evolution of Y depending on X. @@ -220,68 +221,68 @@ public static GenericChart.GenericChart Point( public static GenericChart.GenericChart Line( IEnumerable x, IEnumerable y, - bool? ShowMarkers = null, - string? Name = null, - bool? ShowLegend = null, - double? Opacity = null, - IEnumerable? MultiOpacity = null, - TextType? Text = null, - IEnumerable? MultiText = null, - StyleParam.TextPosition? TextPosition = null, - IEnumerable? MultiTextPosition = null, - Color? MarkerColor = null, - StyleParam.Colorscale? MarkerColorScale = null, - Line? MarkerOutline = null, - StyleParam.MarkerSymbol? MarkerSymbol = null, - IEnumerable? MultiMarkerSymbol = null, - Marker? Marker = null, - Color? LineColor = null, - StyleParam.Colorscale? LineColorScale = null, - double? LineWidth = null, - StyleParam.DrawingStyle? LineDash = null, - Line? Line = null, - string? StackGroup = null, - StyleParam.Orientation? Orientation = null, - StyleParam.GroupNorm? GroupNorm = null, - StyleParam.Fill? Fill = null, - Color? FillColor = null, - bool? UseWebGL = null, - bool? UseDefaults = null + 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 StackGroup = default, + Optional Orientation = default, + Optional GroupNorm = default, + Optional Fill = default, + Optional FillColor = default, + Optional UseWebGL = default, + Optional UseDefaults = default ) where XType : IConvertible where YType : IConvertible - where TextType : class, IConvertible + where TextType : IConvertible => Plotly.NET.Chart2D.Chart.Line( x: x, y: y, - ShowMarkers: Helpers.ToOptionV(ShowMarkers), - Name: Helpers.ToOption(Name), - ShowLegend: Helpers.ToOptionV(ShowLegend), - Opacity: Helpers.ToOptionV(Opacity), - MultiOpacity: Helpers.ToOption(MultiOpacity), - Text: Helpers.ToOption(Text), - MultiText: Helpers.ToOption(MultiText), - TextPosition: Helpers.ToOption(TextPosition), - MultiTextPosition: Helpers.ToOption(MultiTextPosition), - MarkerColor: Helpers.ToOption(MarkerColor), - MarkerColorScale: Helpers.ToOption(MarkerColorScale), - MarkerOutline: Helpers.ToOption(MarkerOutline), - MarkerSymbol: Helpers.ToOption(MarkerSymbol), - MultiMarkerSymbol: Helpers.ToOption(MultiMarkerSymbol), - Marker: Helpers.ToOption(Marker), - LineColor: Helpers.ToOption(LineColor), - LineColorScale: Helpers.ToOption(LineColorScale), - LineWidth: Helpers.ToOptionV(LineWidth), - LineDash: Helpers.ToOption(LineDash), - Line: Helpers.ToOption(Line), - StackGroup: Helpers.ToOption(StackGroup), - Orientation: Helpers.ToOption(Orientation), - GroupNorm: Helpers.ToOption(GroupNorm), - Fill: Helpers.ToOption(Fill), - FillColor: Helpers.ToOption(FillColor), - UseWebGL: Helpers.ToOptionV(UseWebGL), - UseDefaults: Helpers.ToOptionV(UseDefaults) + 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(), + StackGroup: StackGroup.ToOption(), + Orientation: Orientation.ToOption(), + GroupNorm: GroupNorm.ToOption(), + Fill: Fill.ToOption(), + FillColor: FillColor.ToOption(), + UseWebGL: UseWebGL.ToOption(), + UseDefaults: UseDefaults.ToOption() ); /// @@ -311,38 +312,38 @@ public static GenericChart.GenericChart Line( /// Sets the position of text associated with individual datum /// If set to false, ignore the global default settings set in `Defaults` public static GenericChart.GenericChart Bar( - IEnumerable values, - IEnumerable? Keys = null, - string? Name = null, - bool? ShowLegend = null, - double? Opacity = null, - IEnumerable? MultiOpacity = null, - TextType? Text = null, - IEnumerable? MultiText = null, - Color? MarkerColor = null, - StyleParam.Colorscale? MarkerColorScale = null, - Line? MarkerOutline = null, - StyleParam.PatternShape? MarkerPatternShape = null, - IEnumerable? MultiMarkerPatternShape = null, - Pattern? MarkerPattern = null, - Marker? Marker = null, - IConvertible? Base = null, - IConvertible? Width = null, - IEnumerable? MultiWidth = null, - StyleParam.TextPosition? TextPosition = null, - IEnumerable? MultiTextPosition = null, - bool? UseDefaults = null + IEnumerable values, + Optional> Keys = default, + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional> MultiOpacity = default, + Optional Text = default, + Optional> MultiText = default, + Optional MarkerColor = default, + Optional MarkerColorScale = default, + Optional MarkerOutline = default, + Optional MarkerPatternShape = default, + Optional> MultiMarkerPatternShape = default, + Optional MarkerPattern = default, + Optional Marker = default, + Optional TextPosition = default, + Optional> MultiTextPosition = default, + Optional> MultiWidth = default, + Optional UseDefaults = default, + Optional Base = default, + Optional Width = default ) where ValuesType : IConvertible where KeysType : IConvertible - where TextType: class, IConvertible + where TextType: IConvertible => - Plotly.NET.Chart2D.Chart.Bar( + Plotly.NET.Chart2D.Chart.Bar( values: values, Keys: Keys.ToOption(), Name: Name.ToOption(), - ShowLegend: ShowLegend.ToOptionV(), - Opacity: Opacity.ToOptionV(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), MultiOpacity: MultiOpacity.ToOption(), Text: Text.ToOption(), MultiText: MultiText.ToOption(), @@ -358,7 +359,7 @@ public static GenericChart.GenericChart Bar( MultiWidth: MultiWidth.ToOption(), TextPosition: TextPosition.ToOption(), MultiTextPosition: MultiTextPosition.ToOption(), - UseDefaults: UseDefaults.ToOptionV() + UseDefaults: UseDefaults.ToOption() ); /// /// Creates a column chart, with bars plotted vertically @@ -388,37 +389,37 @@ public static GenericChart.GenericChart Bar( /// If set to false, ignore the global default settings set in `Defaults` public static GenericChart.GenericChart Column( IEnumerable values, - IEnumerable? Keys = null, - string? Name = null, - bool? ShowLegend = null, - double? Opacity = null, - IEnumerable? MultiOpacity = null, - TextType? Text = null, - IEnumerable? MultiText = null, - Color? MarkerColor = null, - StyleParam.Colorscale? MarkerColorScale = null, - Line? MarkerOutline = null, - StyleParam.PatternShape? MarkerPatternShape = null, - IEnumerable? MultiMarkerPatternShape = null, - Pattern? MarkerPattern = null, - Marker? Marker = null, - IConvertible? Base = null, - IConvertible? Width = null, - IEnumerable? MultiWidth = null, - StyleParam.TextPosition? TextPosition = null, - IEnumerable? MultiTextPosition = null, - bool? UseDefaults = null + Optional> Keys = default, + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional> MultiOpacity = default, + Optional Text = default, + Optional> MultiText = default, + Optional MarkerColor = default, + Optional MarkerColorScale = default, + Optional MarkerOutline = default, + Optional MarkerPatternShape = default, + Optional> MultiMarkerPatternShape = default, + Optional MarkerPattern = default, + Optional Marker = default, + Optional TextPosition = default, + Optional> MultiTextPosition = default, + Optional> MultiWidth = default, + Optional UseDefaults = default, + Optional Base = default, + Optional Width = default ) where ValuesType : IConvertible where KeysType : IConvertible - where TextType : class, IConvertible + where TextType : IConvertible => - Plotly.NET.Chart2D.Chart.Column( + Plotly.NET.Chart2D.Chart.Column( values: values, Keys: Keys.ToOption(), Name: Name.ToOption(), - ShowLegend: ShowLegend.ToOptionV(), - Opacity: Opacity.ToOptionV(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), MultiOpacity: MultiOpacity.ToOption(), Text: Text.ToOption(), MultiText: MultiText.ToOption(), @@ -434,7 +435,541 @@ public static GenericChart.GenericChart Column( MultiWidth: MultiWidth.ToOption(), TextPosition: TextPosition.ToOption(), MultiTextPosition: MultiTextPosition.ToOption(), - UseDefaults: UseDefaults.ToOptionV() + UseDefaults: UseDefaults.ToOption() + ); + /// + /// Visualizes the distribution of the input data as a histogram. + /// + /// A histogram is an approximate representation of the distribution of numerical data. To construct a histogram, the first step is to "bin" the range of values - that is, divide the entire range of values into a series of intervals - and then count how many values fall into each interval. + /// The bins are usually specified as consecutive, non-overlapping intervals of a variable. + /// + /// The sample data from which statistics are computed is set in `x` for vertically spanning histograms and in `y` for horizontally spanning histograms. Binning options are set `xbins` and `ybins` respectively if no aggregation data is provided. + /// + /// Sets the sample data to be binned on the x axis. + /// Sets the sample data to be binned on the y axis. + /// Sets the orientation of the bars. With "v" ("h"), the value of the each bar spans along the vertical (horizontal). + /// 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 Opacity of the trace. + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Specifies the binning function used for this histogram trace. If "count", the histogram values are computed by counting the number of values lying inside each bin. If "sum", "avg", "min", "max", the histogram values are computed using the sum, the average, the minimum or the maximum of the values lying inside each bin respectively. + /// Specifies the type of normalization used for this histogram trace. If "", the span of each bar corresponds to the number of occurrences (i.e. the number of data points lying inside the bins). If "percent" / "probability", the span of each bar corresponds to the percentage / fraction of occurrences with respect to the total number of sample points (here, the sum of all bin HEIGHTS equals 100% / 1). If "density", the span of each bar corresponds to the number of occurrences in a bin divided by the size of the bin interval (here, the sum of all bin AREAS equals the total number of sample points). If "probability density", the area of each bar corresponds to the probability that an event will fall into the corresponding bin (here, the sum of all bin AREAS equals 1). + /// Set several traces linked to the same position axis or matching axes to the same alignmentgroup. This controls whether bars compute their positional range dependently or independently. + /// Set several traces linked to the same position axis or matching axes to the same offsetgroup where bars of the same position coordinate will line up. + /// Specifies the maximum number of desired bins. This value will be used in an algorithm that will decide the optimal bin size such that the histogram best visualizes the distribution of the data. Ignored if `xbins.size` is provided. + /// Specifies the maximum number of desired bins. This value will be used in an algorithm that will decide the optimal bin size such that the histogram best visualizes the distribution of the data. Ignored if `ybins.size` is provided. + /// Set a group of histogram traces which will have compatible bin settings. Note that traces on the same subplot and with the same "orientation" under `barmode` "stack", "relative" and "group" are forced into the same bingroup, Using `bingroup`, traces under `barmode` "overlay" and on different axes (of the same axis type) can have compatible bin settings. Note that histogram and histogram2d" trace can share the same `bingroup` + /// Sets the binning across the x dimension + /// Sets the binning across the y dimension + /// Sets the color of the histogram's bars. + /// Sets the marker for the histogram's bars (use this for more finegrained control than the other marker-associated arguments). + /// Sets the outline of the histogram's bars. + /// Sets the x error of this trace. + /// Sets the y error of this trace. + /// Sets wether and how the cumulative distribution is displayed + /// Sets the style of the hoverlabels of this trace. + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart Histogram( + Optional> X = default, + Optional> Y = default, + Optional Orientation = default, + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional Text = default, + Optional> MultiText = default, + Optional HistFunc = default, + Optional HistNorm = default, + Optional AlignmentGroup = default, + Optional OffsetGroup = default, + Optional NBinsX = default, + Optional NBinsY = default, + Optional BinGroup = default, + Optional XBins = default, + Optional YBins = default, + Optional MarkerColor = default, + Optional Marker = default, + Optional Line = default, + Optional XError = default, + Optional YError = default, + Optional Cumulative = default, + Optional HoverLabel = default, + Optional UseDefaults = default + ) + where XType : IConvertible + where YType : IConvertible + where TextType : IConvertible + => + Plotly.NET.Chart2D.Chart.Histogram( + X: X.ToOption(), + Y: Y.ToOption(), + Orientation: Orientation.ToOption(), + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + HistFunc: HistFunc.ToOption(), + HistNorm: HistNorm.ToOption(), + AlignmentGroup: AlignmentGroup.ToOption(), + OffsetGroup: OffsetGroup.ToOption(), + NBinsX: NBinsX.ToOption(), + NBinsY: NBinsY.ToOption(), + BinGroup: BinGroup.ToOption(), + XBins: XBins.ToOption(), + YBins: YBins.ToOption(), + MarkerColor: MarkerColor.ToOption(), + Marker: Marker.ToOption(), + Line: Line.ToOption(), + XError: XError.ToOption(), + YError: YError.ToOption(), + Cumulative: Cumulative.ToOption(), + HoverLabel: HoverLabel.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); + /// + /// Visualizes the distribution of the 2-dimensional input data as 2D Histogram. + /// + ///The sample data from which statistics are computed is set in `x` and `y` (where `x` and `y` represent marginal distributions, binning is set in `xbins` and `ybins` in this case) or `z` (where `z` represent the 2D distribution and binning set, binning is set by `x` and `y` in this case). The resulting distribution is visualized as a heatmap. + /// + /// Sets the sample data to be binned on the x axis. + /// Sets the sample data to be binned on the y axis. + /// Sets the aggregation data. + /// 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 Opacity of the trace. + /// Sets the horizontal gap (in pixels) between bricks. + /// Sets the vertical gap (in pixels) between bricks. + /// Specifies the binning function used for this histogram trace. If "count", the histogram values are computed by counting the number of values lying inside each bin. If "sum", "avg", "min", "max", the histogram values are computed using the sum, the average, the minimum or the maximum of the values lying inside each bin respectively. + /// Specifies the type of normalization used for this histogram trace. If "", the span of each bar corresponds to the number of occurrences (i.e. the number of data points lying inside the bins). If "percent" / "probability", the span of each bar corresponds to the percentage / fraction of occurrences with respect to the total number of sample points (here, the sum of all bin HEIGHTS equals 100% / 1). If "density", the span of each bar corresponds to the number of occurrences in a bin divided by the size of the bin interval (here, the sum of all bin AREAS equals the total number of sample points). If "probability density", the area of each bar corresponds to the probability that an event will fall into the corresponding bin (here, the sum of all bin AREAS equals 1). + /// Specifies the maximum number of desired bins. This value will be used in an algorithm that will decide the optimal bin size such that the histogram best visualizes the distribution of the data. Ignored if `xbins.size` is provided. + /// Specifies the maximum number of desired bins. This value will be used in an algorithm that will decide the optimal bin size such that the histogram best visualizes the distribution of the data. Ignored if `ybins.size` is provided. + /// Sets the binning across the x dimension + /// Sets the binning across the y dimension + /// Sets the styles of the colorbar for this trace. + /// Sets the colorscale for this trace. + /// Wether or not to show the colorscale/colorbar + /// Reverses the color mapping if true. If true, `zmin` will correspond to the last color in the array and `zmax` will correspond to the first color. + /// Picks a smoothing algorithm use to smooth `z` data. + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart Histogram2D( + IEnumerable x, + IEnumerable y, + Optional>> Z = default, + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional XGap = default, + Optional YGap = default, + Optional HistFunc = default, + Optional HistNorm = default, + Optional NBinsX = default, + Optional NBinsY = default, + Optional XBins = default, + Optional YBins = default, + Optional ColorBar = default, + Optional ColorScale = default, + Optional ShowScale = default, + Optional ReverseScale = default, + Optional ZSmooth = default, + Optional UseDefaults = default + ) + where XType : IConvertible + where YType : IConvertible + where ZType : IConvertible + => + Plotly.NET.Chart2D.Chart.Histogram2D, ZType>( + x: x, + y: y, + Z: Z.ToOption(), + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), + XGap: XGap.ToOption(), + YGap: YGap.ToOption(), + HistFunc: HistFunc.ToOption(), + HistNorm: HistNorm.ToOption(), + NBinsX: NBinsX.ToOption(), + NBinsY: NBinsY.ToOption(), + XBins: XBins.ToOption(), + YBins: YBins.ToOption(), + ColorBar: ColorBar.ToOption(), + ColorScale: ColorScale.ToOption(), + ShowScale: ShowScale.ToOption(), + ReverseScale: ReverseScale.ToOption(), + ZSmooth: ZSmooth.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); + + /// + /// Visualizes the distribution of the input data as a box plot. + /// + /// A box plot is a method for graphically demonstrating the locality, spread and skewness groups of numerical data through their quartiles. + /// The default style is based on the five number summary: minimum, first quartile, median, third quartile, and maximum. + /// + /// The sample data from which statistics are computed is set in `x` for vertically spanning boxes and in `y` for horizontally spanning boxes. + /// + /// Sets the x sample data or coordinates + /// Sets the y sample data or coordinates + /// 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 a text associated with each datum + /// Sets individual text for each datum + /// Sets the fill color. Defaults to a half-transparent variant of the line color, marker color, or marker line color, whichever is available. + /// Sets the marker color. + /// Sets the marker for the box (use this for more finegrained control than the other marker-associated arguments).// Sets the opacity of this trace. + /// Sets the width of the whiskers relative to the box' width. For example, with 1, the whiskers are as wide as the box(es). + /// If "outliers", only the sample points lying outside the whiskers are shown If "suspectedoutliers", the outlier points are shown and points either less than 4"Q1-3"Q3 or greater than 4"Q3-3"Q1 are highlighted (see `outliercolor`) If "all", all sample points are shown If "false", only the box(es) are shown with no sample points Defaults to "suspectedoutliers" when `marker.outliercolor` or `marker.line.outliercolor` is set. Defaults to "all" under the q1/median/q3 signature. Otherwise defaults to "outliers". + /// If "true", the mean of the box(es)' underlying distribution is drawn as a dashed line inside the box(es). If "sd" the standard deviation is also drawn. Defaults to "true" when `mean` is set. Defaults to "sd" when `sd` is set Otherwise defaults to "false". + /// Sets the amount of jitter in the sample points drawn. If "0", the sample points align along the distribution axis. If "1", the sample points are drawn in a random jitter of width equal to the width of the box(es). + /// Sets the position of the sample points in relation to the box(es). If "0", the sample points are places over the center of the box(es). Positive (negative) values correspond to positions to the right (left) for vertical boxes and above (below) for horizontal boxes + /// Sets the orientation of the box(es). If "v" ("h"), the distribution is visualized along the vertical (horizontal). + /// Sets the color of the box outline + /// Sets the width of the box outline + /// Sets the box outline (use this for more finegrained control than the other outline-associated arguments). + /// Set several traces linked to the same position axis or matching axes to the same alignmentgroup. This controls whether bars compute their positional range dependently or independently. + /// Set several traces linked to the same position axis or matching axes to the same offsetgroup where bars of the same position coordinate will line up. + /// Determines whether or not notches are drawn. Notches displays a confidence interval around the median. We compute the confidence interval as median +/- 1.57 " IQR / sqrt(N), where IQR is the interquartile range and N is the sample size. If two boxes' notches do not overlap there is 95% confidence their medians differ. See https://sites.google.com/site/davidsstatistics/home/notched-box-plots for more info. Defaults to "false" unless `notchwidth` or `notchspan` is set. + /// Sets the width of the notches relative to the box' width. For example, with 0, the notches are as wide as the box(es). + /// Sets the method used to compute the sample's Q1 and Q3 quartiles. The "linear" method uses the 25th percentile for Q1 and 75th percentile for Q3 as computed using method #10 (listed on http://www.amstat.org/publications/jse/v14n3/langford.html). The "exclusive" method uses the median to divide the ordered dataset into two halves if the sample is odd, it does not include the median in either half - Q1 is then the median of the lower half and Q3 the median of the upper half. The "inclusive" method also uses the median to divide the ordered dataset into two halves but if the sample is odd, it includes the median in both halves - Q1 is then the median of the lower half and Q3 the median of the upper half. + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart BoxPlot( + Optional> X = default, + Optional> Y = default, + Optional Name = default, + Optional ShowLegend = default, + Optional Text = default, + Optional> MultiText = default, + Optional FillColor = default, + Optional MarkerColor = default, + Optional Marker = default, + Optional Opacity = default, + Optional WhiskerWidth = default, + Optional BoxPoints = default, + Optional BoxMean = default, + Optional Jitter = default, + Optional PointPos = default, + Optional Orientation = default, + Optional OutlineColor = default, + Optional OutlineWidth = default, + Optional Outline = default, + Optional AlignmentGroup = default, + Optional OffsetGroup = default, + Optional Notched = default, + Optional NotchWidth = default, + Optional QuartileMethod = default, + Optional UseDefaults = default + ) + where XType : IConvertible + where YType : IConvertible + where TextType : IConvertible + => + Plotly.NET.Chart2D.Chart.BoxPlot( + X: X.ToOption(), + Y: Y.ToOption(), + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + FillColor: FillColor.ToOption(), + MarkerColor: MarkerColor.ToOption(), + Marker: Marker.ToOption(), + Opacity: Opacity.ToOption(), + WhiskerWidth: WhiskerWidth.ToOption(), + BoxPoints: BoxPoints.ToOption(), + BoxMean: BoxMean.ToOption(), + Jitter: Jitter.ToOption(), + PointPos: PointPos.ToOption(), + Orientation: Orientation.ToOption(), + OutlineColor: OutlineColor.ToOption(), + OutlineWidth: OutlineWidth.ToOption(), + Outline: Outline.ToOption(), + AlignmentGroup: AlignmentGroup.ToOption(), + OffsetGroup: OffsetGroup.ToOption(), + Notched: Notched.ToOption(), + NotchWidth: NotchWidth.ToOption(), + QuartileMethod: QuartileMethod.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); + + /// + /// Visualizes the distribution of the input data as a violin plot. + /// + /// A violin plot is a method of plotting numeric data. It is similar to a box plot, except that they also show the probability density of the data at different values, usually smoothed by a kernel density estimator. + /// + /// In vertical (horizontal) violin plots, statistics are computed using `y` (`x`) values. By supplying an `x` (`y`) array, one violin per distinct x (y) value is drawn If no `x` (`y`) array is provided, a single violin is drawn. That violin position is then positioned with with `name` or with `x0` (`y0`) if provided. + /// + /// Sets the x sample data or coordinates. + /// Sets the y sample data or coordinates. + /// 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 a text associated with each datum + /// Sets individual text for each datum + /// Sets the fill color. Defaults to a half-transparent variant of the line color, marker color, or marker line color, whichever is available. + /// Sets the Opacity otf the trace. + /// If "outliers", only the sample points lying outside the whiskers are shown If "suspectedoutliers", the outlier points are shown and points either less than 4"Q1-3"Q3 or greater than 4"Q3-3"Q1 are highlighted (see `outliercolor`) If "all", all sample points are shown If "false", only the violins are shown with no sample points. Defaults to "suspectedoutliers" when `marker.outliercolor` or `marker.line.outliercolor` is set, otherwise defaults to "outliers". + /// Sets the amount of jitter in the sample points drawn. If "0", the sample points align along the distribution axis. If "1", the sample points are drawn in a random jitter of width equal to the width of the box(es). + /// Sets the position of the sample points in relation to the box(es). If "0", the sample points are places over the center of the box(es). Positive (negative) values correspond to positions to the right (left) for vertical boxes and above (below) for horizontal boxes + /// Sets the orientation of the violin(s). If "v" ("h"), the distribution is visualized along the vertical (horizontal). + /// Sets the width of the violin in data coordinates. If "0" (default value) the width is automatically selected based on the positions of other violin traces in the same subplot. + /// Sets the marker color. + /// Sets the marker for the violin (use this for more finegrained control than the other marker-associated arguments). + /// Sets the color of the box outline + /// Sets the width of the box outline + /// Sets the box outline (use this for more finegrained control than the other outline-associated arguments). + /// Set several traces linked to the same position axis or matching axes to the same alignmentgroup. This controls whether bars compute their positional range dependently or independently. + /// Set several traces linked to the same position axis or matching axes to the same offsetgroup where bars of the same position coordinate will line up. + /// Wether and how to draw a miniature box plot + /// Sets the width of the miniature box plot + /// Sets the fill color of the miniature box plot + /// Sets the styles of the miniature box plot (use this for more finegrained control than the other box-associated arguments) + /// Sets the bandwidth used to compute the kernel density estimate. By default, the bandwidth is determined by Silverman's rule of thumb. + /// Wether and how to draw the meanline + /// If there are multiple violins that should be sized according to to some metric (see `scalemode`), link them by providing a non-empty group id here shared by every trace in the same group. If a violin's `width` is undefined, `scalegroup` will default to the trace's name. In this case, violins with the same names will be linked together + /// Sets the metric by which the width of each violin is determined."width" means each violin has the same (max) width"count" means the violins are scaled by the number of sample points makingup each violin. + /// Determines on which side of the position value the density function making up one half of a violin is plotted. Useful when comparing two violin traces under "overlay" mode, where one trace has `side` set to "positive" and the other to "negative". + /// Sets the span in data space for which the density function will be computed. Has an effect only when `spanmode` is set to "manual". + /// Sets the method by which the span in data space where the density function will be computed. "soft" means the span goes from the sample's minimum value minus two bandwidths to the sample's maximum value plus two bandwidths. "hard" means the span goes from the sample's minimum to its maximum value. For custom span settings, use mode "manual" and fill in the `span` attribute. + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart Violin( + Optional> X = default, + Optional> Y = default, + Optional Name = default, + Optional ShowLegend = default, + Optional Text = default, + Optional> MultiText = default, + Optional FillColor = default, + Optional Opacity = default, + Optional Points = default, + Optional Jitter = default, + Optional PointPos = default, + Optional Orientation = default, + Optional Width = default, + Optional MarkerColor = default, + Optional Marker = default, + Optional OutlineColor = default, + Optional OutlineWidth = default, + Optional Outline = default, + Optional AlignmentGroup = default, + Optional OffsetGroup = default, + Optional ShowBox = default, + Optional BoxWidth = default, + Optional BoxFillColor = default, + Optional Box = default, + Optional BandWidth = default, + Optional MeanLine = default, + Optional ScaleGroup = default, + Optional ScaleMode = default, + Optional Side = default, + Optional Span = default, + Optional SpanMode = default, + Optional UseDefaults = default + ) + where XType : IConvertible + where YType : IConvertible + where TextType : IConvertible + => + Plotly.NET.Chart2D.Chart.Violin( + X: X.ToOption(), + Y: Y.ToOption(), + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + FillColor: FillColor.ToOption(), + Opacity: Opacity.ToOption(), + Points: Points.ToOption(), + Jitter: Jitter.ToOption(), + PointPos: PointPos.ToOption(), + Orientation: Orientation.ToOption(), + Width: Width.ToOption(), + MarkerColor: MarkerColor.ToOption(), + Marker: Marker.ToOption(), + OutlineColor: OutlineColor.ToOption(), + OutlineWidth: OutlineWidth.ToOption(), + Outline: Outline.ToOption(), + AlignmentGroup: AlignmentGroup.ToOption(), + OffsetGroup: OffsetGroup.ToOption(), + ShowBox: ShowBox.ToOption(), + BoxWidth: BoxWidth.ToOption(), + BoxFillColor: BoxFillColor.ToOption(), + Box: Box.ToOption(), + BandWidth: BandWidth.ToOption(), + MeanLine: MeanLine.ToOption(), + ScaleGroup: ScaleGroup.ToOption(), + ScaleMode: ScaleMode.ToOption(), + Side: Side.ToOption(), + Span: Span.ToOption(), + SpanMode: SpanMode.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); + + /// + /// Computes a 2D histogram contour plot, also known as a density contour plot, which is a 2-dimensional generalization of a histogram which resembles a contour plot but is computed by grouping a set of points specified by their x and y coordinates into bins, and applying an aggregation function such as count or sum (if z is provided) to compute the value to be used to compute contours. + /// + /// The sample data from which statistics are computed is set in `x` and `y` (where `x` and `y` represent marginal distributions, binning is set in `xbins` and `ybins` in this case) or `z` (where `z` represent the 2D distribution and binning set, binning is set by `x` and `y` in this case). The resulting distribution is visualized as a contour plot. + /// + /// Sets the sample data to be binned on the x axis. + /// Sets the sample data to be binned on the y axis. + /// 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 Opacity otf the trace. + /// Sets the aggregation data. + /// Specifies the binning function used for this histogram trace. If "count", the histogram values are computed by counting the number of values lying inside each bin. If "sum", "avg", "min", "max", the histogram values are computed using the sum, the average, the minimum or the maximum of the values lying inside each bin respectively. + /// Specifies the type of normalization used for this histogram trace. If "", the span of each bar corresponds to the number of occurrences (i.e. the number of data points lying inside the bins). If "percent" / "probability", the span of each bar corresponds to the percentage / fraction of occurrences with respect to the total number of sample points (here, the sum of all bin HEIGHTS equals 100% / 1). If "density", the span of each bar corresponds to the number of occurrences in a bin divided by the size of the bin interval (here, the sum of all bin AREAS equals the total number of sample points). If "probability density", the area of each bar corresponds to the probability that an event will fall into the corresponding bin (here, the sum of all bin AREAS equals 1). + /// Specifies the maximum number of desired bins. This value will be used in an algorithm that will decide the optimal bin size such that the histogram best visualizes the distribution of the data. Ignored if `xbins.size` is provided. + /// Specifies the maximum number of desired bins. This value will be used in an algorithm that will decide the optimal bin size such that the histogram best visualizes the distribution of the data. Ignored if `ybins.size` is provided. + /// Set the `xbingroup` and `ybingroup` default prefix For example, setting a `bingroup` of "1" on two histogram2d traces will make them their x-bins and y-bins match separately. + /// Set a group of histogram traces which will have compatible x-bin settings. Using `xbingroup`, histogram2d and histogram2dcontour traces (on axes of the same axis type) can have compatible x-bin settings. Note that the same `xbingroup` value can be used to set (1D) histogram `bingroup` + /// Sets the binning across the x dimension + /// Set a group of histogram traces which will have compatible y-bin settings. Using `ybingroup`, histogram2d and histogram2dcontour traces (on axes of the same axis type) can have compatible y-bin settings. Note that the same `ybingroup` value can be used to set (1D) histogram `bingroup` + /// Sets the binning across the y dimension + /// Sets the marker of this trace. + /// Sets the contour line dash style + /// Sets the contour line color + /// Sets the amount of smoothing for the contour lines, where "0" corresponds to no smoothing. + /// Sets the contour lines (use this for more finegrained control than the other contourline-associated arguments). + /// Sets the styles of the colorbar for this trace. + /// Sets the colorscale for this trace. + /// Wether or not to show the colorscale/colorbar + /// Reverses the color mapping if true. If true, `zmin` will correspond to the last color in the array and `zmax` will correspond to the first color. + /// Sets the style of the contours + /// Sets the maximum number of contour levels. The actual number of contours will be chosen automatically to be less than or equal to the value of `ncontours`. Has an effect only if `autocontour` is "true" or if `contours.size` is missing. + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart Histogram2DContour( + IEnumerable x, + IEnumerable y, + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional>> Z = default, + Optional HistFunc = default, + Optional HistNorm = default, + Optional NBinsX = default, + Optional NBinsY = default, + Optional BinGroup = default, + Optional XBinGroup = default, + Optional XBins = default, + Optional YBinGroup = default, + Optional YBins = default, + Optional Marker = default, + Optional ContourLineColor = default, + Optional ContourLineDash = default, + Optional ContourLineSmoothing = default, + Optional ContourLine = default, + Optional ColorBar = default, + Optional ColorScale = default, + Optional ShowScale = default, + Optional ReverseScale = default, + Optional Contours = default, + Optional NContours = default, + Optional UseDefaults = default + ) + where XType : IConvertible + where YType : IConvertible + where ZType : IConvertible + => + Plotly.NET.Chart2D.Chart.Histogram2DContour, ZType>( + x: x, + y: y, + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), + Z: Z.ToOption(), + HistFunc: HistFunc.ToOption(), + HistNorm: HistNorm.ToOption(), + NBinsX: NBinsX.ToOption(), + NBinsY: NBinsY.ToOption(), + BinGroup: BinGroup.ToOption(), + XBinGroup: XBinGroup.ToOption(), + XBins: XBins.ToOption(), + YBinGroup: YBinGroup.ToOption(), + YBins: YBins.ToOption(), + Marker: Marker.ToOption(), + ContourLineColor: ContourLineColor.ToOption(), + ContourLineDash: ContourLineDash.ToOption(), + ContourLineSmoothing: ContourLineSmoothing.ToOption(), + ContourLine: ContourLine.ToOption(), + ColorBar: ColorBar.ToOption(), + ColorScale: ColorScale.ToOption(), + ShowScale: ShowScale.ToOption(), + ReverseScale: ReverseScale.ToOption(), + Contours: Contours.ToOption(), + NContours: NContours.ToOption(), + UseDefaults: UseDefaults.ToOption() + ); + + /// + /// Creates a point density plot - a combination of a Scatter plot and Histogram2DContour. + /// + /// Additionally to plotting the (x,y) data as points on a 2D plane, a density contour plot is computed by grouping a set of points specified by their x and y coordinates into bins, and applying a count aggregation function to compute the value to be used to compute contours. + /// The sample data from which statistics are computed is set in `x` and `y` (where `x` and `y` represent marginal distributions, binning is set in `xbins` and `ybins` in this case). The resulting distribution is visualized as a contour plot. + /// + /// + /// Sets the x coordinates of the plotted data as well as the sample data to be binned on the x axis. + /// Sets the y coordinates of the plotted data as well as the sample data to be binned on the y axis. + /// Sets the opacity of the point trace. + /// Sets the marker color of the point trace. + /// Sets the marker symbol of the point trace. + /// Sets the marker size of the point trace. + /// Sets the color of the contour lines of the histogram2dcontour trace. + /// Sets the smoothing of the contour lines of the histogram2dcontour trace. + /// Sets the width of the contour lines of the histogram2dcontour trace. + /// Wether or not to show contour lines + /// Wether or not to show contour labels + /// Determines the coloring method showing the contour values. If "fill", coloring is done evenly between each contour level If "heatmap", a heatmap gradient coloring is applied between each contour level. If "lines", coloring is done on the contour lines. If "none", no coloring is applied on this trace. + /// Sets the maximum number of contour levels. The actual number of contours will be chosen automatically to be less than or equal to the value of `ncontours`. Has an effect only if `autocontour` is "true" or if `contours.size` is missing. + /// Specifies the type of normalization used for this histogram trace. If "", the span of each bar corresponds to the number of occurrences (i.e. the number of data points lying inside the bins). If "percent" / "probability", the span of each bar corresponds to the percentage / fraction of occurrences with respect to the total number of sample points (here, the sum of all bin HEIGHTS equals 100% / 1). If "density", the span of each bar corresponds to the number of occurrences in a bin divided by the size of the bin interval (here, the sum of all bin AREAS equals the total number of sample points). If "probability density", the area of each bar corresponds to the probability that an event will fall into the corresponding bin (here, the sum of all bin AREAS equals 1). + /// Sets the opacity of the histogram2dcontour trace. + /// Sets the color bar. + /// Sets the colorscale of the histogram2dcontour trace. + /// wether or not to show the colorbar + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart PointDensity( + IEnumerable x, + IEnumerable y, + Optional PointOpacity = default, + Optional PointMarkerColor = default, + Optional PointMarkerSymbol = default, + Optional PointMarkerSize = default, + Optional ContourLineColor = default, + Optional ContourLineSmoothing = default, + Optional ContourLineWidth = default, + Optional ShowContourLines = default, + Optional ShowContourLabels = default, + Optional ContourColoring = default, + Optional NContours = default, + Optional HistNorm = default, + Optional ContourOpacity = default, + Optional ColorBar = default, + Optional ColorScale = default, + Optional ShowScale = default, + Optional UseDefaults = default + ) + where XType : IConvertible + where YType : IConvertible + => + Plotly.NET.Chart2D.Chart.PointDensity( + x: x, + y: y, + PointOpacity: PointOpacity.ToOption(), + PointMarkerColor: PointMarkerColor.ToOption(), + PointMarkerSymbol: PointMarkerSymbol.ToOption(), + PointMarkerSize: PointMarkerSize.ToOption(), + ContourLineColor: ContourLineColor.ToOption(), + ContourLineSmoothing: ContourLineSmoothing.ToOption(), + ContourLineWidth: ContourLineWidth.ToOption(), + ShowContourLines: ShowContourLines.ToOption(), + ShowContourLabels: ShowContourLabels.ToOption(), + ContourColoring: ContourColoring.ToOption(), + NContours: NContours.ToOption(), + HistNorm: HistNorm.ToOption(), + ContourOpacity: ContourOpacity.ToOption(), + ColorBar: ColorBar.ToOption(), + ColorScale: ColorScale.ToOption(), + ShowScale: ShowScale.ToOption(), + UseDefaults: UseDefaults.ToOption() ); }; } diff --git a/src/Plotly.NET.CSharp/ChartAPI/Chart3D.cs b/src/Plotly.NET.CSharp/ChartAPI/Chart3D.cs index 608f81c28..a93cd4ae1 100644 --- a/src/Plotly.NET.CSharp/ChartAPI/Chart3D.cs +++ b/src/Plotly.NET.CSharp/ChartAPI/Chart3D.cs @@ -6,6 +6,8 @@ using Plotly.NET; using Plotly.NET.LayoutObjects; using Plotly.NET.TraceObjects; +using System.Runtime.InteropServices; + namespace Plotly.NET.CSharp { @@ -43,64 +45,64 @@ public static partial class Chart /// Sets the line (use this for more finegrained control than the other line-associated arguments) /// Sets the projection of this trace. /// If set to false, ignore the global default settings set in `Defaults` - public static GenericChart.GenericChart Scatter3D( - IEnumerable x, - IEnumerable y, - IEnumerable z, + public static GenericChart.GenericChart Scatter3D( + IEnumerable x, + IEnumerable y, + IEnumerable z, StyleParam.Mode mode, - string? Name = null, - bool? ShowLegend = null, - double? Opacity = null, - IEnumerable? MultiOpacity = null, - TextData? Text = null, - IEnumerable? MultiText = null, - StyleParam.TextPosition? TextPosition = null, - IEnumerable? MultiTextPosition = null, - Color? MarkerColor = null, - StyleParam.Colorscale? MarkerColorScale = null, - Line? MarkerOutline = null, - StyleParam.MarkerSymbol3D? MarkerSymbol = null, - IEnumerable? MultiMarkerSymbol = null, - Marker? Marker = null, - Color? LineColor = null, - StyleParam.Colorscale? LineColorScale = null, - double? LineWidth = null, - StyleParam.DrawingStyle? LineDash = null, - Line? Line = null, - Projection? Projection = null, - bool? UseDefaults = null + 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 Projection = default, + Optional UseDefaults = default ) - where XData: IConvertible - where YData: IConvertible - where ZData: IConvertible - where TextData: class, IConvertible + where XType: IConvertible + where YType: IConvertible + where ZType : IConvertible + where TextType : IConvertible - => Plotly.NET.Chart3D.Chart.Scatter3D( + => Plotly.NET.Chart3D.Chart.Scatter3D( x: x, y: y, z: z, mode: mode, - Name: Helpers.ToOption(Name), - ShowLegend: Helpers.ToOptionV(ShowLegend), - Opacity: Helpers.ToOptionV(Opacity), - MultiOpacity: Helpers.ToOption(MultiOpacity), - Text: Helpers.ToOption(Text), - MultiText: Helpers.ToOption(MultiText), - TextPosition: Helpers.ToOption(TextPosition), - MultiTextPosition: Helpers.ToOption(MultiTextPosition), - MarkerColor: Helpers.ToOption(MarkerColor), - MarkerColorScale: Helpers.ToOption(MarkerColorScale), - MarkerOutline: Helpers.ToOption(MarkerOutline), - MarkerSymbol: Helpers.ToOption(MarkerSymbol), - MultiMarkerSymbol: Helpers.ToOption(MultiMarkerSymbol), - Marker: Helpers.ToOption(Marker), - LineColor: Helpers.ToOption(LineColor), - LineColorScale: Helpers.ToOption(LineColorScale), - LineWidth: Helpers.ToOptionV(LineWidth), - LineDash: Helpers.ToOption(LineDash), - Line: Helpers.ToOption(Line), - Projection: Helpers.ToOption(Projection), - UseDefaults: Helpers.ToOptionV(UseDefaults) + 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(), + Projection: Projection.ToOption(), + UseDefaults: UseDefaults.ToOption() ); } } diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartCarpet.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartCarpet.cs index 613c9f2c8..d2d7df11b 100644 --- a/src/Plotly.NET.CSharp/ChartAPI/ChartCarpet.cs +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartCarpet.cs @@ -5,6 +5,7 @@ using System.Threading.Tasks; using Plotly.NET.LayoutObjects; using Plotly.NET.TraceObjects; +using System.Runtime.InteropServices; namespace Plotly.NET.CSharp { @@ -46,22 +47,22 @@ public static partial class Chart /// If set to false, ignore the global default settings set in `Defaults` public static GenericChart.GenericChart Carpet( string carpetId, - string? Name = null, - bool? ShowLegend = null, - double? Opacity = null, - IEnumerable? X = null, - IEnumerable>? MultiX = null, - IEnumerable? Y = null, - IEnumerable>? MultiY = null, - IEnumerable? A = null, - IEnumerable? B = null, - LinearAxis? AAxis = null, - LinearAxis? BAxis = null, - StyleParam.LinearAxisId? XAxis = null, - StyleParam.LinearAxisId? YAxis = null, - Color? Color = null, - double? CheaterSlope = null, - bool? UseDefaults = true + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional> X = default, + Optional>> MultiX = default, + Optional> Y = default, + Optional>> MultiY = default, + Optional> A = default, + Optional> B = default, + Optional AAxis = default, + Optional BAxis = default, + Optional XAxis = default, + Optional YAxis = default, + Optional Color = default, + Optional CheaterSlope = default, + Optional UseDefaults = default ) where XType : IConvertible where MultiXType : IConvertible @@ -73,8 +74,8 @@ public static GenericChart.GenericChart Carpet, MultiXType, YType, IEnumerable, MultiYType, AType, BType>( carpetId: carpetId, Name: Name.ToOption(), - ShowLegend: ShowLegend.ToOptionV(), - Opacity: Opacity.ToOptionV(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), X: X.ToOption(), MultiX: MultiX.ToOption(), Y: Y.ToOption(), @@ -86,8 +87,98 @@ public static GenericChart.GenericChart Carpet + /// Creates a contour chart that lies on a specified carpet. + /// + /// Plots contours on either the first carpet axis or the carpet axis with a matching `carpet` attribute. Data `z` is interpreted as matching that of the corresponding carpet axis. + /// + /// The identifier of the carpet that this trace will lie on. + /// Sets the z data. + /// 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 a coordinates. + /// Sets the b coordinates. + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the colorbar of this trace. + /// Sets the colorscale of this trace. + /// Determines whether or not a colorbar is displayed for this trace. + /// Reverses the color mapping if true. If true, `zmin` will correspond to the last color in the array and `zmax` will correspond to the first color. + /// Transposes the z data. + /// Sets the contour line dash style + /// Sets the contour line color + /// Sets the amount of smoothing for the contour lines, where "0" corresponds to no smoothing. + /// Sets the contour lines (use this for more finegrained control than the other contourline-associated arguments). + /// Determines the coloring method showing the contour values. If "fill", coloring is done evenly between each contour level If "heatmap", a heatmap gradient coloring is applied between each contour level. If "lines", coloring is done on the contour lines. If "none", no coloring is applied on this trace. + /// Sets the constraint operation. "=" keeps regions equal to `value` "<" and "<=" keep regions less than `value` ">" and ">=" keep regions greater than `value` "[]", "()", "[)", and "(]" keep regions inside `value[0]` to `value[1]` "][", ")(", "](", ")[" keep regions outside `value[0]` to value[1]` Open vs. closed intervals make no difference to constraint display, but all versions are allowed for consistency with filter transforms. + /// If `levels`, the data is represented as a contour plot with multiple levels displayed. If `constraint`, the data is represented as constraints with the invalid region shaded as specified by the `operation` and `value` parameters. + /// Determines whether to label the contour lines with their values. + /// Sets the font used for labeling the contour levels. The default color comes from the lines, if shown. The default family and size come from `layout.font`. + /// Sets the styles of the contours (use this for more finegrained control than the other contour-associated arguments). + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart ContourCarpet( + IEnumerable z, + string carpetAnchorId, + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional> A = default, + Optional> B = default, + Optional Text = default, + Optional> MultiText = default, + Optional ColorBar = default, + Optional ColorScale = default, + Optional ShowScale = default, + Optional ReverseScale = default, + Optional Transpose = default, + Optional ContourLineColor = default, + Optional ContourLineDash = default, + Optional ContourLineSmoothing = default, + Optional ContourLine = default, + Optional ContoursColoring = default, + Optional ContoursOperation = default, + Optional ContoursType = default, + Optional ShowContourLabels = default, + Optional ContourLabelFont = default, + Optional Contours = default, + Optional UseDefaults = default + ) + where ZType : IConvertible + where AType : IConvertible + where BType : IConvertible + where TextType : IConvertible + => + Plotly.NET.ChartCarpet.Chart.ContourCarpet( + z: z, + carpetAnchorId: carpetAnchorId, + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), + A: A.ToOption(), + B: B.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + ColorBar: ColorBar.ToOption(), + ColorScale: ColorScale.ToOption(), + ShowScale: ShowScale.ToOption(), + ReverseScale: ReverseScale.ToOption(), + Transpose: Transpose.ToOption(), + ContourLineColor: ContourLineColor.ToOption(), + ContourLineDash: ContourLineDash.ToOption(), + ContourLineSmoothing: ContourLineSmoothing.ToOption(), + ContourLine: ContourLine.ToOption(), + ContoursColoring: ContoursColoring.ToOption(), + ContoursOperation: ContoursOperation.ToOption(), + ContoursType: ContoursType.ToOption(), + ShowContourLabels: ShowContourLabels.ToOption(), + ContourLabelFont: ContourLabelFont.ToOption(), + Contours: Contours.ToOption(), + UseDefaults: UseDefaults.ToOption() ); } } diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartDomain.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartDomain.cs index 64eca5507..6dab41b58 100644 --- a/src/Plotly.NET.CSharp/ChartAPI/ChartDomain.cs +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartDomain.cs @@ -1,6 +1,7 @@ using Plotly.NET; using Plotly.NET.LayoutObjects; using Plotly.NET.TraceObjects; +using System.Runtime.InteropServices; namespace Plotly.NET.CSharp @@ -39,42 +40,42 @@ public static partial class Chart /// If set to false, ignore the global default settings set in `Defaults` public static GenericChart.GenericChart Pie( IEnumerable values, - string? Name = null, - bool? ShowLegend = null, - double? Opacity = null, - IEnumerable? MultiOpacity = null, - IEnumerable? Labels = null, - double? Pull = null, - IEnumerable? MultiPull = null, - TextType? Text = null, - IEnumerable? MultiText = null, - StyleParam.TextPosition? TextPosition = null, - IEnumerable? MultiTextPosition = null, - IEnumerable? SectionColors = null, - Color? SectionOutlineColor = null, - double? SectionOutlineWidth = null, - IEnumerable? SectionOutlineMultiWidth = null, - Line? SectionOutline = null, - Marker? Marker = null, - StyleParam.TextInfo? TextInfo = null, - StyleParam.Direction? Direction = null, - double? Hole = null, - double? Rotation = null, - bool? Sort = null, - bool? UseDefaults = null + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional> MultiOpacity = default, + Optional> Labels = default, + Optional Pull = default, + Optional> MultiPull = default, + Optional Text = default, + Optional> MultiText = default, + Optional TextPosition = default, + Optional> MultiTextPosition = default, + Optional> SectionColors = default, + Optional SectionOutlineColor = default, + Optional SectionOutlineWidth = default, + Optional> SectionOutlineMultiWidth = default, + Optional SectionOutline = default, + Optional Marker = default, + Optional TextInfo = default, + Optional Direction = default, + Optional Hole = default, + Optional Rotation = default, + Optional Sort = default, + Optional UseDefaults = default ) where ValuesType : IConvertible where LabelsType : IConvertible - where TextType : class, IConvertible + where TextType : IConvertible => Plotly.NET.ChartDomain.Chart.Pie( values: values, Name: Name.ToOption(), - ShowLegend: ShowLegend.ToOptionV(), - Opacity: Opacity.ToOptionV(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), MultiOpacity: MultiOpacity.ToOption(), Labels: Labels.ToOption(), - Pull: Pull.ToOptionV(), + Pull: Pull.ToOption(), MultiPull: MultiPull.ToOption(), Text: Text.ToOption(), MultiText: MultiText.ToOption(), @@ -82,16 +83,16 @@ public static GenericChart.GenericChart Pie( MultiTextPosition: MultiTextPosition.ToOption(), SectionColors: SectionColors.ToOption(), SectionOutlineColor: SectionOutlineColor.ToOption(), - SectionOutlineWidth: SectionOutlineWidth.ToOptionV(), + SectionOutlineWidth: SectionOutlineWidth.ToOption(), SectionOutlineMultiWidth: SectionOutlineMultiWidth.ToOption(), SectionOutline: SectionOutline.ToOption(), Marker: Marker.ToOption(), TextInfo: TextInfo.ToOption(), Direction: Direction.ToOption(), - Hole: Hole.ToOptionV(), - Rotation: Rotation.ToOptionV(), - Sort: Sort.ToOptionV(), - UseDefaults: UseDefaults.ToOptionV() + Hole: Hole.ToOption(), + Rotation: Rotation.ToOption(), + Sort: Sort.ToOption(), + UseDefaults: UseDefaults.ToOption() ); } diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs index 90ee010df..5319c6622 100644 --- a/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs @@ -6,6 +6,7 @@ using Plotly.NET; using Plotly.NET.LayoutObjects; using Plotly.NET.TraceObjects; +using System.Runtime.InteropServices; namespace Plotly.NET.CSharp { @@ -48,61 +49,123 @@ public static GenericChart.GenericChart ScatterGeo longitudes, IEnumerable latitudes, StyleParam.Mode mode, - string? Name = null, - bool? ShowLegend = null, - double? Opacity = null, - IEnumerable? MultiOpacity = null, - TextType? Text = null, - IEnumerable? MultiText = null, - StyleParam.TextPosition? TextPosition = null, - IEnumerable? MultiTextPosition = null, - Color? MarkerColor = null, - StyleParam.Colorscale? MarkerColorScale = null, - Line? MarkerOutline = null, - StyleParam.MarkerSymbol? MarkerSymbol = null, - IEnumerable? MultiMarkerSymbol = null, - Marker? Marker = null, - Color? LineColor = null, - StyleParam.Colorscale? LineColorScale = null, - double? LineWidth = null, - StyleParam.DrawingStyle? LineDash = null, - Line? Line = null, - StyleParam.LocationFormat? LocationMode = null, - Object? GeoJson = null, - string? FeatureIdKey = null, - bool? UseDefaults = null + 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 : class, IConvertible + where TextType : IConvertible => Plotly.NET.ChartMap.Chart.ScatterGeo( longitudes: longitudes, latitudes: latitudes, mode: mode, - Name: Helpers.ToOption(Name), - ShowLegend: Helpers.ToOptionV(ShowLegend), - Opacity: Helpers.ToOptionV(Opacity), - MultiOpacity: Helpers.ToOption(MultiOpacity), - Text: Helpers.ToOption(Text), - MultiText: Helpers.ToOption(MultiText), - TextPosition: Helpers.ToOption(TextPosition), - MultiTextPosition: Helpers.ToOption(MultiTextPosition), - MarkerColor: Helpers.ToOption(MarkerColor), - MarkerColorScale: Helpers.ToOption(MarkerColorScale), - MarkerOutline: Helpers.ToOption(MarkerOutline), - MarkerSymbol: Helpers.ToOption(MarkerSymbol), - MultiMarkerSymbol: Helpers.ToOption(MultiMarkerSymbol), - Marker: Helpers.ToOption(Marker), - LineColor: Helpers.ToOption(LineColor), - LineColorScale: Helpers.ToOption(LineColorScale), - LineWidth: Helpers.ToOptionV(LineWidth), - LineDash: Helpers.ToOption(LineDash), - Line: Helpers.ToOption(Line), - LocationMode: Helpers.ToOption(LocationMode), - GeoJson: Helpers.ToOption(GeoJson), - FeatureIdKey: Helpers.ToOption(FeatureIdKey), - UseDefaults: Helpers.ToOptionV(UseDefaults) + 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. + /// + /// 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 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 + /// Sets the radius of influence of one `lon` / `lat` point in pixels. Increasing the value makes the densitymapbox trace smoother, but less detailed. + /// 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 DensityMapbox( + IEnumerable longitudes, + IEnumerable latitudes, + Optional Name = default, + Optional ShowLegend = default, + Optional Opacity = default, + Optional> Z = default, + Optional Radius = 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 LongitudesType: IConvertible + where LatitudesType: IConvertible + where ZType: IConvertible + where TextType: IConvertible + => + Plotly.NET.ChartMap.Chart.DensityMapbox( + longitudes: longitudes, + latitudes: latitudes, + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), + Z: Z.ToOption(), + Radius: Radius.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() ); } } diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartPolar.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartPolar.cs index be5bd5a81..9b8efdd57 100644 --- a/src/Plotly.NET.CSharp/ChartAPI/ChartPolar.cs +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartPolar.cs @@ -6,6 +6,7 @@ using Plotly.NET; using Plotly.NET.LayoutObjects; using Plotly.NET.TraceObjects; +using System.Runtime.InteropServices; namespace Plotly.NET.CSharp { @@ -46,58 +47,58 @@ public static GenericChart.GenericChart ScatterPolar IEnumerable r, IEnumerable theta, StyleParam.Mode mode, - string? Name = null, - bool? ShowLegend = null, - double? Opacity = null, - IEnumerable? MultiOpacity = null, - TextType? Text = null, - IEnumerable? MultiText = null, - StyleParam.TextPosition? TextPosition = null, - IEnumerable? MultiTextPosition = null, - Color? MarkerColor = null, - StyleParam.Colorscale? MarkerColorScale = null, - Line? MarkerOutline = null, - StyleParam.MarkerSymbol3D? MarkerSymbol = null, - IEnumerable? MultiMarkerSymbol = null, - Marker? Marker = null, - Color? LineColor = null, - StyleParam.Colorscale? LineColorScale = null, - double? LineWidth = null, - StyleParam.DrawingStyle? LineDash = null, - Line? Line = null, - bool? UseWebGL = null, - bool? UseDefaults = null + 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 UseWebGL = default, + Optional UseDefaults = default ) where RType : IConvertible where ThetaType : IConvertible - where TextType : class, IConvertible + where TextType : IConvertible => Plotly.NET.ChartPolar.Chart.ScatterPolar( r: r, theta: theta, mode: mode, - Name: Helpers.ToOption(Name), - ShowLegend: Helpers.ToOptionV(ShowLegend), - Opacity: Helpers.ToOptionV(Opacity), - MultiOpacity: Helpers.ToOption(MultiOpacity), - Text: Helpers.ToOption(Text), - MultiText: Helpers.ToOption(MultiText), - TextPosition: Helpers.ToOption(TextPosition), - MultiTextPosition: Helpers.ToOption(MultiTextPosition), - MarkerColor: Helpers.ToOption(MarkerColor), - MarkerColorScale: Helpers.ToOption(MarkerColorScale), - MarkerOutline: Helpers.ToOption(MarkerOutline), - MarkerSymbol: Helpers.ToOption(MarkerSymbol), - MultiMarkerSymbol: Helpers.ToOption(MultiMarkerSymbol), - Marker: Helpers.ToOption(Marker), - LineColor: Helpers.ToOption(LineColor), - LineColorScale: Helpers.ToOption(LineColorScale), - LineWidth: Helpers.ToOptionV(LineWidth), - LineDash: Helpers.ToOption(LineDash), - Line: Helpers.ToOption(Line), - UseWebGL: Helpers.ToOptionV(UseWebGL), - UseDefaults: Helpers.ToOptionV(UseDefaults) + 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(), + UseWebGL: UseWebGL.ToOption(), + UseDefaults: UseDefaults.ToOption() ); } } diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartSmith.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartSmith.cs index f677fff2c..2a4dae2a8 100644 --- a/src/Plotly.NET.CSharp/ChartAPI/ChartSmith.cs +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartSmith.cs @@ -1,6 +1,7 @@ using Plotly.NET; using Plotly.NET.LayoutObjects; using Plotly.NET.TraceObjects; +using System.Runtime.InteropServices; namespace Plotly.NET.CSharp { @@ -42,40 +43,40 @@ public static GenericChart.GenericChart ScatterSmith real, IEnumerable imag, StyleParam.Mode mode, - string? Name = null, - bool? ShowLegend = null, - double? Opacity = null, - IEnumerable? MultiOpacity = null, - TextType? Text = null, - IEnumerable? MultiText = null, - StyleParam.TextPosition? TextPosition = null, - IEnumerable? MultiTextPosition = null, - Color? MarkerColor = null, - StyleParam.Colorscale? MarkerColorScale = null, - Line? MarkerOutline = null, - StyleParam.MarkerSymbol? MarkerSymbol = null, - IEnumerable? MultiMarkerSymbol = null, - Marker? Marker = null, - Color? LineColor = null, - StyleParam.Colorscale? LineColorScale = null, - double? LineWidth = null, - StyleParam.DrawingStyle? LineDash = null, - Line? Line = null, - StyleParam.Fill? Fill = null, - Color? FillColor = null, - bool? UseDefaults = true + 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 Fill = default, + Optional FillColor = default, + Optional UseDefaults = default ) where RealType : IConvertible where ImagType : IConvertible - where TextType : class, IConvertible + where TextType : IConvertible => Plotly.NET.ChartSmith.Chart.ScatterSmith( real: real, imag: imag, mode: mode, Name: Name.ToOption(), - ShowLegend: ShowLegend.ToOptionV(), - Opacity: Opacity.ToOptionV(), + ShowLegend: ShowLegend.ToOption(), + Opacity: Opacity.ToOption(), MultiOpacity: MultiOpacity.ToOption(), Text: Text.ToOption(), MultiText: MultiText.ToOption(), @@ -89,12 +90,12 @@ public static GenericChart.GenericChart ScatterSmithSets the line (use this for more finegrained control than the other line-associated arguments) /// If set to false, ignore the global default settings set in `Defaults` public static GenericChart.GenericChart ScatterTernary( - IEnumerable? A = null, - IEnumerable? B = null, - IEnumerable? C = null, - SumType? Sum = null, - StyleParam.Mode? Mode = null, - string? Name = null, - bool? ShowLegend = null, - double? Opacity = null, - IEnumerable? MultiOpacity = null, - TextType? Text = null, - IEnumerable? MultiText = null, - StyleParam.TextPosition? TextPosition = null, - IEnumerable? MultiTextPosition = null, - Color? MarkerColor = null, - StyleParam.Colorscale? MarkerColorScale = null, - Line? MarkerOutline = null, - StyleParam.MarkerSymbol? MarkerSymbol = null, - IEnumerable? MultiMarkerSymbol = null, - Marker? Marker = null, - Color? LineColor = null, - StyleParam.Colorscale? LineColorScale = null, - double? LineWidth = null, - StyleParam.DrawingStyle? LineDash = null, - Line? Line = null, - bool? UseDefaults = null + Optional> A = default, + Optional> B = default, + Optional> C = default, + Optional Sum = default, + Optional Mode = 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 UseDefaults = default ) where AType : IConvertible where BType : IConvertible where CType : IConvertible - where SumType : class, IConvertible - where TextType : class, IConvertible + where SumType : IConvertible + where TextType : IConvertible => Plotly.NET.ChartTernary.Chart.ScatterTernary( A: A.ToOption(), @@ -82,8 +83,8 @@ public static GenericChart.GenericChart ScatterTernary + /// Extension methods for fluid-style chart styling and creation API. + /// public static class GenericChartExtensions { + /// + /// Returns the layout of the given chart + /// + /// The chart of which to get the layout public static Layout GetLayout(this GenericChart.GenericChart gChart) => GenericChart.getLayout(gChart); + /// + /// Returns all traces of the given chart as an array + /// + /// The chart of which to get all traces public static Trace [] GetTraces(this GenericChart.GenericChart gChart) => GenericChart.getTraces(gChart).ToArray(); /// /// Saves the given Chart as html file at the given path (.html file extension is added if not present). /// Optionally opens the generated file in the browser. /// + /// The chart to save as html file. /// The path to save the chart html at. /// Wether or not to open the generated file in the browser (default: false) public static void SaveHtml( this GenericChart.GenericChart gChart, string path, - bool? OpenInBrowser = null + Optional OpenInBrowser = default ) => Plotly.NET.Chart.SaveHtml( path: path, - OpenInBrowser: OpenInBrowser.ToOptionV() + OpenInBrowser: OpenInBrowser.ToOption() ).Invoke(gChart); /// /// Saves the given chart as a temporary html file and opens it in the browser. /// - /// The chart to show in the browser + /// The chart to show in the browser public static void Show(this GenericChart.GenericChart gChart) => Plotly.NET.Chart.Show(gChart); /// /// Sets trace information on the given chart. /// + /// The chart in which to change the trace info /// Sets the name of the chart's trace(s). When the chart is a multichart (it contains multiple traces), the name is suffixed by '_%i' where %i is the index of the trace. /// Wether or not the chart's traces are visible /// Determines whether or not item(s) corresponding to this chart's trace(s) is/are shown in the legend. @@ -43,18 +57,18 @@ public static void SaveHtml( /// Sets the title for the chart's trace legend group public static GenericChart.GenericChart WithTraceInfo( this GenericChart.GenericChart gChart, - string? Name = null, - StyleParam.Visible? Visible = null, - bool? ShowLegend = null, - int? LegendRank = null, - string? LegendGroup = null, - Title? LegendGroupTitle = null + Optional Name = default, + Optional Visible = default, + Optional ShowLegend = default, + Optional LegendRank = default, + Optional LegendGroup = default, + Optional LegendGroupTitle = default ) => Plotly.NET.Chart.WithTraceInfo( Name: Name.ToOption(), Visible: Visible.ToOption(), - ShowLegend: ShowLegend.ToOptionV(), - LegendRank: LegendRank.ToOptionV(), + ShowLegend: ShowLegend.ToOption(), + LegendRank: LegendRank.ToOption(), LegendGroup: LegendGroup.ToOption(), LegendGroupTitle: LegendGroupTitle.ToOption() ).Invoke(gChart); @@ -62,16 +76,17 @@ public static GenericChart.GenericChart WithTraceInfo( /// Sets the size of a Chart (in pixels) public static GenericChart.GenericChart WithSize( this GenericChart.GenericChart gChart, - int? Width = null, - int? Height = null + Optional<int> Width = default, + Optional<int> Height = default ) => - Plotly.NET.Chart.WithSize(Width: Width.ToOptionV(), Height: Height.ToOptionV()).Invoke(gChart); + Plotly.NET.Chart.WithSize(Width: Width.ToOption(), Height: Height.ToOption()).Invoke(gChart); /// <summary> /// Sets the given x axis styles on the input chart's layout. /// /// If there is already an axis set at the given id, the styles are applied to it. If there is no axis present, a new LinearAxis object with the given styles will be set. /// </summary> + /// <param name="gChart">The chart in which to change the X axis style</param> /// <param name="TitleText">Sets the text of the axis title.</param> /// <param name="TitleFont">Sets the font of the axis title.</param> /// <param name="TitleStandoff">Sets the standoff distance (in px) between the axis labels and the title text.</param> @@ -103,69 +118,69 @@ public static GenericChart.GenericChart WithSize( /// <param name="Id">The target axis id on which the styles should be applied. Default is 1.</param> public static GenericChart.GenericChart WithXAxisStyle<MinType, MaxType, CategoryArrayType>( this GenericChart.GenericChart gChart, - string? TitleText = null, - Font? TitleFont = null, - int? TitleStandoff = null, - Title? Title = null, - Color? Color = null, - StyleParam.AxisType? AxisType = null, - Tuple<MinType, MaxType>? MinMax = null, - StyleParam.Mirror? Mirror = null, - bool? ShowSpikes = null, - Color? SpikeColor = null, - int? SpikeThickness = null, - bool? ShowLine = null, - Color? LineColor = null, - bool? ShowGrid = null, - Color? GridColor = null, - bool? ZeroLine = null, - Color? ZeroLineColor = null, - StyleParam.LinearAxisId? Anchor = null, - StyleParam.Side? Side = null, - StyleParam.LinearAxisId? Overlaying = null, - Tuple<double, double>? Domain = null, - double? Position = null, - StyleParam.CategoryOrder? CategoryOrder = null, - IEnumerable<CategoryArrayType>? CategoryArray = null, - RangeSlider? RangeSlider = null, - RangeSelector? RangeSelector = null, - Color? BackgroundColor = null, - bool? ShowBackground = null, - StyleParam.SubPlotId? Id = null + Optional<string> TitleText = default, + Optional<Font> TitleFont = default, + Optional<int> TitleStandoff = default, + Optional<Title> Title = default, + Optional<Color> Color = default, + Optional<StyleParam.AxisType> AxisType = default, + Optional<Tuple<MinType, MaxType>> MinMax = default, + Optional<StyleParam.Mirror> Mirror = default, + Optional<bool> ShowSpikes = default, + Optional<Color> SpikeColor = default, + Optional<int> SpikeThickness = default, + Optional<bool> ShowLine = default, + Optional<Color> LineColor = default, + Optional<bool> ShowGrid = default, + Optional<Color> GridColor = default, + Optional<bool> ZeroLine = default, + Optional<Color> ZeroLineColor = default, + Optional<StyleParam.LinearAxisId> Anchor = default, + Optional<StyleParam.Side> Side = default, + Optional<StyleParam.LinearAxisId> Overlaying = default, + Optional<Tuple<double, double>> Domain = default, + Optional<double> Position = default, + Optional<StyleParam.CategoryOrder> CategoryOrder = default, + Optional<IEnumerable<CategoryArrayType>> CategoryArray = default, + Optional<RangeSlider> RangeSlider = default, + Optional<RangeSelector> RangeSelector = default, + Optional<Color> BackgroundColor = default, + Optional<bool> ShowBackground = default, + Optional<StyleParam.SubPlotId> Id = default ) where MinType : IConvertible where MaxType : IConvertible - where CategoryArrayType : class, IConvertible + where CategoryArrayType : IConvertible => Plotly.NET.Chart.WithXAxisStyle<MinType, MaxType, CategoryArrayType>( TitleText: TitleText.ToOption(), TitleFont: TitleFont.ToOption(), - TitleStandoff: TitleStandoff.ToOptionV(), + TitleStandoff: TitleStandoff.ToOption(), Title: Title.ToOption(), Color: Color.ToOption(), AxisType: AxisType.ToOption(), MinMax: MinMax.ToOption(), Mirror: Mirror.ToOption(), - ShowSpikes: ShowSpikes.ToOptionV(), + ShowSpikes: ShowSpikes.ToOption(), SpikeColor: SpikeColor.ToOption(), - SpikeThickness: SpikeThickness.ToOptionV(), - ShowLine: ShowLine.ToOptionV(), + SpikeThickness: SpikeThickness.ToOption(), + ShowLine: ShowLine.ToOption(), LineColor: LineColor.ToOption(), - ShowGrid: ShowGrid.ToOptionV(), + ShowGrid: ShowGrid.ToOption(), GridColor: GridColor.ToOption(), - ZeroLine: ZeroLine.ToOptionV(), + ZeroLine: ZeroLine.ToOption(), ZeroLineColor: ZeroLineColor.ToOption(), Anchor: Anchor.ToOption(), Side: Side.ToOption(), Overlaying: Overlaying.ToOption(), Domain: Domain.ToOption(), - Position: Position.ToOptionV(), + Position: Position.ToOption(), CategoryOrder: CategoryOrder.ToOption(), CategoryArray: CategoryArray.ToOption(), RangeSlider: RangeSlider.ToOption(), RangeSelector: RangeSelector.ToOption(), BackgroundColor: BackgroundColor.ToOption(), - ShowBackground: ShowBackground.ToOptionV(), + ShowBackground: ShowBackground.ToOption(), Id: Id.ToOption() ).Invoke(gChart); @@ -175,6 +190,7 @@ public static GenericChart.GenericChart WithXAxisStyle<MinType, MaxType, Categor /// /// If there is already an axis set at the given id, the styles are applied to it. If there is no axis present, a new LinearAxis object with the given styles will be set. /// </summary> + /// <param name="gChart">The chart in which to change the Y axis style</param> /// <param name="TitleText">Sets the text of the axis title.</param> /// <param name="TitleFont">Sets the font of the axis title.</param> /// <param name="TitleStandoff">Sets the standoff distance (in px) between the axis labels and the title text.</param> @@ -206,72 +222,131 @@ public static GenericChart.GenericChart WithXAxisStyle<MinType, MaxType, Categor /// <param name="Id">The target axis id on which the styles should be applied. Default is 1.</param> public static GenericChart.GenericChart WithYAxisStyle<MinType, MaxType, CategoryArrayType>( this GenericChart.GenericChart gChart, - string? TitleText = null, - Font? TitleFont = null, - int? TitleStandoff = null, - Title? Title = null, - Color? Color = null, - StyleParam.AxisType? AxisType = null, - Tuple<MinType, MaxType>? MinMax = null, - StyleParam.Mirror? Mirror = null, - bool? ShowSpikes = null, - Color? SpikeColor = null, - int? SpikeThickness = null, - bool? ShowLine = null, - Color? LineColor = null, - bool? ShowGrid = null, - Color? GridColor = null, - bool? ZeroLine = null, - Color? ZeroLineColor = null, - StyleParam.LinearAxisId? Anchor = null, - StyleParam.Side? Side = null, - StyleParam.LinearAxisId? Overlaying = null, - Tuple<double, double>? Domain = null, - double? Position = null, - StyleParam.CategoryOrder? CategoryOrder = null, - IEnumerable<CategoryArrayType>? CategoryArray = null, - RangeSlider? RangeSlider = null, - RangeSelector? RangeSelector = null, - Color? BackgroundColor = null, - bool? ShowBackground = null, - StyleParam.SubPlotId? Id = null + Optional<string> TitleText = default, + Optional<Font> TitleFont = default, + Optional<int> TitleStandoff = default, + Optional<Title> Title = default, + Optional<Color> Color = default, + Optional<StyleParam.AxisType> AxisType = default, + Optional<Tuple<MinType, MaxType>> MinMax = default, + Optional<StyleParam.Mirror> Mirror = default, + Optional<bool> ShowSpikes = default, + Optional<Color> SpikeColor = default, + Optional<int> SpikeThickness = default, + Optional<bool> ShowLine = default, + Optional<Color> LineColor = default, + Optional<bool> ShowGrid = default, + Optional<Color> GridColor = default, + Optional<bool> ZeroLine = default, + Optional<Color> ZeroLineColor = default, + Optional<StyleParam.LinearAxisId> Anchor = default, + Optional<StyleParam.Side> Side = default, + Optional<StyleParam.LinearAxisId> Overlaying = default, + Optional<Tuple<double, double>> Domain = default, + Optional<double> Position = default, + Optional<StyleParam.CategoryOrder> CategoryOrder = default, + Optional<IEnumerable<CategoryArrayType>> CategoryArray = default, + Optional<RangeSlider> RangeSlider = default, + Optional<RangeSelector> RangeSelector = default, + Optional<Color> BackgroundColor = default, + Optional<bool> ShowBackground = default, + Optional<StyleParam.SubPlotId> Id = default ) where MinType : IConvertible where MaxType : IConvertible - where CategoryArrayType : class, IConvertible + where CategoryArrayType : IConvertible => Plotly.NET.Chart.WithYAxisStyle<MinType, MaxType, CategoryArrayType>( TitleText: TitleText.ToOption(), TitleFont: TitleFont.ToOption(), - TitleStandoff: TitleStandoff.ToOptionV(), + TitleStandoff: TitleStandoff.ToOption(), Title: Title.ToOption(), Color: Color.ToOption(), AxisType: AxisType.ToOption(), MinMax: MinMax.ToOption(), Mirror: Mirror.ToOption(), - ShowSpikes: ShowSpikes.ToOptionV(), + ShowSpikes: ShowSpikes.ToOption(), SpikeColor: SpikeColor.ToOption(), - SpikeThickness: SpikeThickness.ToOptionV(), - ShowLine: ShowLine.ToOptionV(), + SpikeThickness: SpikeThickness.ToOption(), + ShowLine: ShowLine.ToOption(), LineColor: LineColor.ToOption(), - ShowGrid: ShowGrid.ToOptionV(), + ShowGrid: ShowGrid.ToOption(), GridColor: GridColor.ToOption(), - ZeroLine: ZeroLine.ToOptionV(), + ZeroLine: ZeroLine.ToOption(), ZeroLineColor: ZeroLineColor.ToOption(), Anchor: Anchor.ToOption(), Side: Side.ToOption(), Overlaying: Overlaying.ToOption(), Domain: Domain.ToOption(), - Position: Position.ToOptionV(), + Position: Position.ToOption(), CategoryOrder: CategoryOrder.ToOption(), CategoryArray: CategoryArray.ToOption(), RangeSlider: RangeSlider.ToOption(), RangeSelector: RangeSelector.ToOption(), BackgroundColor: BackgroundColor.ToOption(), - ShowBackground: ShowBackground.ToOptionV(), + ShowBackground: ShowBackground.ToOption(), Id: Id.ToOption() ).Invoke(gChart); - } + + /// <summary> + /// Sets the Mapbox for the chart's layout + /// + /// If there is already a Mapbox set, the objects are combined. + /// </summary> + /// <param name="gChart">The chart in which to change the mapbox</param> + /// <param name="mapbox">The Mapbox to set on the chart's layout</param> + /// <param name="Id">The target mapbox id on which the Mapbox should be set. Default is 1.</param> + public static GenericChart.GenericChart WithMabox( + this GenericChart.GenericChart gChart, + Mapbox mapbox, + Optional<int> Id = default + ) + => + Plotly.NET.Chart.WithMapbox( + mapbox: mapbox, + Id: Id.ToOption() + ).Invoke(gChart); + + /// <summary> + /// Sets the given Mapbox styles on the target Mapbox object on the input chart's layout. + /// + /// If there is already a Mapbox set, the styles are applied to it. If there is no Mapbox present, a new Mapbox object with the given styles will be set. + /// </summary> + /// <param name="gChart">The chart in which to change the mapbox style</param> + /// <param name="Domain">Sets the domain of the Mapbox subplot</param> + /// <param name="AccessToken">Sets the mapbox access token to be used for this mapbox map. Alternatively, the mapbox access token can be set in the configuration options under `mapboxAccessToken`. Note that accessToken are only required when `style` (e.g with values : basic, streets, outdoors, light, dark, satellite, satellite-streets ) and/or a layout layer references the Mapbox server.</param> + /// <param name="Style">Defines the map layers that are rendered by default below the trace layers defined in `data`, which are themselves by default rendered below the layers defined in `layout.mapbox.layers`. These layers can be defined either explicitly as a Mapbox Style object which can contain multiple layer definitions that load data from any public or private Tile Map Service (TMS or XYZ) or Web Map Service (WMS) or implicitly by using one of the built-in style objects which use WMSes which do not require any access tokens, or by using a default Mapbox style or custom Mapbox style URL, both of which require a Mapbox access token Note that Mapbox access token can be set in the `accesstoken` attribute or in the `mapboxAccessToken` config option. Mapbox Style objects are of the form described in the Mapbox GL JS documentation available at https://docs.mapbox.com/mapbox-gl-js/style-spec The built-in plotly.js styles objects are: carto-darkmatter, carto-positron, open-street-map, stamen-terrain, stamen-toner, stamen-watercolor, white-bg The built-in Mapbox styles are: basic, streets, outdoors, light, dark, satellite, satellite-streets Mapbox style URLs are of the form: mapbox://mapbox.mapbox/name/version</param> + /// <param name="Center">Sets the (lon,lat) coordinates of the center of the map view</param> + /// <param name="Zoom">Sets the zoom level of the map (mapbox.zoom).</param> + /// <param name="Bearing">Sets the bearing angle of the map in degrees counter-clockwise from North (mapbox.bearing).</param> + /// <param name="Pitch">Sets the pitch angle of the map (in degrees, where "0" means perpendicular to the surface of the map) (mapbox.pitch).</param> + /// <param name="Layers">Sets the layers of this Mapbox</param> + /// <param name="Id">The target mapbox id</param> + public static GenericChart.GenericChart WithMaboxStyle( + this GenericChart.GenericChart gChart, + Optional<Domain> Domain = default, + Optional<string> AccessToken = default, + Optional<StyleParam.MapboxStyle> Style = default, + Optional<Tuple<double, double>> Center = default, + Optional<double> Zoom = default, + Optional<double> Bearing = default, + Optional<double> Pitch = default, + Optional<IEnumerable<MapboxLayer>> Layers = default, + Optional<int> Id = default + ) + => + Plotly.NET.Chart.withMapboxStyle( + Domain: Domain.ToOption(), + AccessToken: AccessToken.ToOption(), + Style: Style.ToOption(), + Center: Center.ToOption(), + Zoom: Zoom.ToOption(), + Bearing: Bearing.ToOption(), + Pitch: Pitch.ToOption(), + Layers: Layers.ToOption(), + Id: Id.ToOption() + ).Invoke(gChart); + } } \ No newline at end of file diff --git a/src/Plotly.NET.CSharp/Helpers.cs b/src/Plotly.NET.CSharp/Helpers.cs deleted file mode 100644 index 253baf0de..000000000 --- a/src/Plotly.NET.CSharp/Helpers.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Microsoft.FSharp; -using Microsoft.FSharp.Core; - -namespace Plotly.NET.CSharp -{ - static class Helpers { - /// <summary> - /// Helper extension method to convert any nullable reference type to a FSharpOption, to be used with F# optional parameters. - /// The resulting opton will be `None` when the value is null, and Some(value) otherwise - /// </summary> - /// <param name="thing">the thing to turn into a FSharpOption</param> - /// <returns>The original value wrapped as a FSharpOption</returns> - static internal Microsoft.FSharp.Core.FSharpOption<T> ToOption<T>(this T? thing) => thing is null ? Microsoft.FSharp.Core.FSharpOption<T>.None : new(thing); - /// <summary> - /// Helper extension method to convert any nullable value type to a FSharpOption, to be used with F# optional parameters. - /// The resulting opton will be `None` when the value is null, and Some(value) otherwise - /// </summary> - /// <param name="thing">the thing to turn into a FSharpOption</param> - /// <returns>The original value wrapped as a FSharpOption</returns> - static internal Microsoft.FSharp.Core.FSharpOption<T> ToOptionV<T>(this T? thing) where T : struct => thing is { } some ? new(some) : Microsoft.FSharp.Core.FSharpOption<T>.None; - } -} diff --git a/src/Plotly.NET.CSharp/Optional.cs b/src/Plotly.NET.CSharp/Optional.cs new file mode 100644 index 000000000..1dd64fdb2 --- /dev/null +++ b/src/Plotly.NET.CSharp/Optional.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Plotly.NET.CSharp +{ + /// <summary> + /// Helper type for handling the special way the Plotly.NET core API uses generics. + /// In short, the problem arises because many optional parameters of Plotly.NET's core API are generics + /// with a type constraint for `IConvertible`. This means that these parameters can be both value and reference types + /// (e.g. `double` and `System.DateTime` both implement IConvertible). + /// If we now have a optional parameter of type `T? where T: IConvertible` the compiler will not allow this + /// without further type constrainst to eithe reference or value type. + /// This is a problem because we want to 1. allow both, and 2. have a reliable way of determining if the value was not set + /// because the F# API expects to be passed `Option.None` in that case. + /// There exist other workarounds like checking if the value is default or null, but that changes valid default values actually set to null as well. + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="Value">The value to mark as optional</param> + /// <param name="IsSome">Wether or not the wrapped value is valid. This is used downstream to determine wether to wrap this value into `Option.Some` (if true) or `Option.None` (if false)</param> + public readonly record struct Optional<T>(T Value, bool IsSome) + { + /// <summary> + /// + /// </summary> + /// <param name="Value"></param> + public static implicit operator Optional<T>(T Value) => new(Value, true); + + } + /// <summary> + /// Extension methods for the `Optional` class + /// </summary> + public static class OptionalExtensions + { + /// <summary> + /// Converts the `Optional` value to `Some(value)` if the value is valid, or `None` if it is not. + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="opt">The `Optional` value to convert to a F# Option</param> + /// <returns>opt converted to `Option`</returns> + static internal Microsoft.FSharp.Core.FSharpOption<T> ToOption<T>(this Optional<T> opt) => opt.IsSome ? new(opt.Value) : Microsoft.FSharp.Core.FSharpOption<T>.None; + + } +} diff --git a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs index 9c4d5abd2..7798741b3 100644 --- a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs +++ b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs @@ -10,19 +10,22 @@ class Program static void Main(string[] args) { Chart.Grid( - nRows: 8, - nCols: 5, + nRows: 9, + nCols: 6, gCharts: new GenericChart[] { - Chart.Scatter<int,int,string>( + //2D basic traces + Chart.Scatter<int, int, int>( x: new int [] { 1, 2 }, y: new int [] { 3, 4 }, - mode: Mode.Markers + mode: Mode.Markers, + MultiText: new int [] { 3, 4 } ), Chart.Point<int,int,string>( x: new int [] { 5, 6 }, - y: new int [] { 7, 8 } + y: new int [] { 7, 8 }, + Text: "hi" ), Chart.Line<int,int,string>( x: new int [] { 9, 10 }, @@ -33,9 +36,39 @@ static void Main(string[] args) Keys: new string [] { "first", "second"} ), Chart.Column<int,string,string>( - values: new int [] { 1,2 }, + values: new int [] { 3,4 }, Keys: new string [] { "first", "second"} ), + Chart.Invisible(), + + //2D distributions + Chart.Histogram<int,int,int>( + X: new int [] { 1,2,2,2,3,4,5,5 }, + MultiText: new int [] { 1,2,3,4,5,6,7} + ), + Chart.Histogram2D<int,int,int>( + x: new int [] { 1,2,2,2,3,4,5,5 }, + y: new int [] { 1,2,2,2,3,4,5,5 }, + ShowScale: false + ), + Chart.BoxPlot<int,int,string>( + X: new int [] { 1,2,2,2,3,4,5,5 } + ), + Chart.Violin<int,int,string>( + X: new int [] { 1,2,2,2,3,4,5,5 } + ), + Chart.Histogram2DContour<int,int,int>( + x: new int [] { 1,2,2,2,3,4,5,5 }, + y: new int [] { 1,2,2,2,3,4,5,5 }, + ShowScale: false + ), + Chart.PointDensity<int,int>( + x: new int [] { 1,2,2,2,3,4,5,5 }, + y: new int [] { 1,2,2,2,3,4,5,5 }, + ShowScale: false + ), + + //3D traces Chart.Scatter3D<int,int,int,string>( x: new int[] { 12, 13 }, y: new int [] { 13, 14 }, @@ -46,6 +79,9 @@ static void Main(string[] args) Chart.Invisible(), Chart.Invisible(), Chart.Invisible(), + Chart.Invisible(), + + //polar traces Chart.ScatterPolar<int,int,string>( theta: new int [] { 1, 2 }, r: new int [] { 3, 4 }, @@ -55,6 +91,9 @@ static void Main(string[] args) Chart.Invisible(), Chart.Invisible(), Chart.Invisible(), + Chart.Invisible(), + + //geo/mapbox traces Chart.ScatterGeo<int,int,string>( longitudes: new int [] { 1, 2 }, latitudes: new int [] { 3, 4 }, @@ -64,6 +103,15 @@ static void Main(string[] args) Chart.Invisible(), Chart.Invisible(), Chart.Invisible(), + Chart.DensityMapbox<int,int,int,string>( + 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 + ), + + //ternary traces Chart.ScatterTernary<int,int,int,IConvertible,string>( A: new int [] { 1, 2 }, B: new int [] { 3, 4 }, @@ -73,6 +121,9 @@ static void Main(string[] args) Chart.Invisible(), Chart.Invisible(), Chart.Invisible(), + Chart.Invisible(), + + //carpet traces Chart.Carpet<double,double,double,double,double,double>( carpetId: "testCarpet", A: new double [] {4.0, 4.0, 4.0, 4.5, 4.5, 4.5, 5.0, 5.0, 5.0, 6.0, 6.0, 6.0}, @@ -83,6 +134,27 @@ static void Main(string[] args) Chart.Invisible(), Chart.Invisible(), Chart.Invisible(), + Chart.Combine( + new GenericChart [] + { + Chart.Carpet<double,double,double,double,double,double>( + carpetId: "contour", + A: new double [] { 0.0, 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 3.0, 0.0, 1.0, 2.0, 3.0}, + B: new double[] { 4.0, 4.0, 4.0, 4.0, 5.0, 5.0, 5.0, 5.0, 6.0, 6.0, 6.0, 6.0}, + X: new double[] { 2.0, 3.0, 4.0, 5.0, 2.2, 3.1, 4.1, 5.1, 1.5, 2.5, 3.5, 4.5}, + Y: new double [] { 1.0, 1.4, 1.6, 1.75, 2.0, 2.5, 2.7, 2.75, 3.0, 3.5, 3.7, 3.75} + ), + Chart.ContourCarpet<double,int,int,string>( + z: new double [] { 1.0, 1.96, 2.56, 3.0625, 4.0, 5.0625, 1.0, 7.5625, 9.0, 12.25, 15.21, 14.0625 }, + carpetAnchorId: "contour", + A: new int [] { 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3}, + B: new int[] { 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6}, + ShowScale: false + ) + } + ), + + //domain traces Chart.Pie<double,string,string>( values: new double [] {1,2,3,4}, Labels: new string [] {"soos", "saas", "fiif", "leel"} @@ -91,6 +163,9 @@ static void Main(string[] args) Chart.Invisible(), Chart.Invisible(), Chart.Invisible(), + Chart.Invisible(), + + //smith traces Chart.ScatterSmith<double,double,string>( real: new double [] {1,2,3,4}, imag: new double [] {1,2,3,4}, @@ -100,19 +175,17 @@ static void Main(string[] args) Chart.Invisible(), Chart.Invisible(), Chart.Invisible(), + Chart.Invisible(), } ) - .WithSize(1250,2000) + .WithSize(1000, 1800) .Show(); - - Chart.Point<int, int, string>( - x: new int[] { 1, 2 }, - y: new int[] { 3, 4 } - ) - .WithTraceInfo("Hello from C#", ShowLegend: true) - .WithXAxisStyle<int, int, string>(TitleText: "x axis") - .WithYAxisStyle<int, int, string>(TitleText: "y axis") - .Show(); + Chart.Column<int, string, string>( + values: new int[] { 3, 4 }, + Keys: new string[] { "first", "second" }, + Width: 1, + Base: 4 + ).Show(); } } }