diff --git a/Plotly.NET.sln b/Plotly.NET.sln index 6bf5d8b13..71e035ef3 100644 --- a/Plotly.NET.sln +++ b/Plotly.NET.sln @@ -150,6 +150,10 @@ Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Plotly.NET.ImageExport.Test EndProject Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "build", "build\build.fsproj", "{403785C9-B5B1-4BA4-9944-A0F9D5D1B3CD}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Plotly.NET.CSharp", "src\Plotly.NET.CSharp\Plotly.NET.CSharp.csproj", "{F944FE69-F4A5-4B48-8E4D-BE4B61E92B26}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Plotly.NET.CSharp.Tests", "tests\Plotly.NET.CSharp.Tests\Plotly.NET.CSharp.Tests.csproj", "{4C24BA53-F41C-4110-AD7A-28143DCF671E}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -211,6 +215,18 @@ Global {403785C9-B5B1-4BA4-9944-A0F9D5D1B3CD}.Dotnet|Any CPU.Build.0 = Debug|Any CPU {403785C9-B5B1-4BA4-9944-A0F9D5D1B3CD}.Release|Any CPU.ActiveCfg = Release|Any CPU {403785C9-B5B1-4BA4-9944-A0F9D5D1B3CD}.Release|Any CPU.Build.0 = Release|Any CPU + {F944FE69-F4A5-4B48-8E4D-BE4B61E92B26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F944FE69-F4A5-4B48-8E4D-BE4B61E92B26}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F944FE69-F4A5-4B48-8E4D-BE4B61E92B26}.Dotnet|Any CPU.ActiveCfg = Debug|Any CPU + {F944FE69-F4A5-4B48-8E4D-BE4B61E92B26}.Dotnet|Any CPU.Build.0 = Debug|Any CPU + {F944FE69-F4A5-4B48-8E4D-BE4B61E92B26}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F944FE69-F4A5-4B48-8E4D-BE4B61E92B26}.Release|Any CPU.Build.0 = Release|Any CPU + {4C24BA53-F41C-4110-AD7A-28143DCF671E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4C24BA53-F41C-4110-AD7A-28143DCF671E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4C24BA53-F41C-4110-AD7A-28143DCF671E}.Dotnet|Any CPU.ActiveCfg = Debug|Any CPU + {4C24BA53-F41C-4110-AD7A-28143DCF671E}.Dotnet|Any CPU.Build.0 = Debug|Any CPU + {4C24BA53-F41C-4110-AD7A-28143DCF671E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4C24BA53-F41C-4110-AD7A-28143DCF671E}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -228,6 +244,8 @@ Global {26539796-0C9D-4856-8584-B58BE32CC495} = {EAE25A1F-86FC-426B-803F-1006D1AD06A8} {55A461C3-8018-4020-B16E-D6005BDFCAED} = {EAE25A1F-86FC-426B-803F-1006D1AD06A8} {403785C9-B5B1-4BA4-9944-A0F9D5D1B3CD} = {7C6D08E7-3EAC-4335-8F4B-252C193C27C9} + {F944FE69-F4A5-4B48-8E4D-BE4B61E92B26} = {0E87E47E-9EDC-4525-AF72-F0E139D54236} + {4C24BA53-F41C-4110-AD7A-28143DCF671E} = {EAE25A1F-86FC-426B-803F-1006D1AD06A8} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {7177F1E1-341C-48AB-9864-6B525FFF7633} diff --git a/src/Plotly.NET.CSharp/ChartAPI/Chart.cs b/src/Plotly.NET.CSharp/ChartAPI/Chart.cs new file mode 100644 index 000000000..73f0dfeb4 --- /dev/null +++ b/src/Plotly.NET.CSharp/ChartAPI/Chart.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Plotly.NET; +using Plotly.NET.LayoutObjects; +using Plotly.NET.TraceObjects; + +namespace Plotly.NET.CSharp +{ + public static partial class Chart + { + public static GenericChart.GenericChart Combine(IEnumerable gCharts) => Plotly.NET.Chart.Combine(gCharts); + + + public static GenericChart.GenericChart Invisible() => Plotly.NET.Chart.Invisible(); + + /// + /// Creates a subplot grid with the given dimensions (nRows x nCols) for the input charts. + /// + /// The charts to display on the grid. + /// The number of rows in the grid. If you provide a 2D `subplots` array or a `yaxes` array, its length is used as the default. But it's also possible to have a different length, if you want to leave a row at the end for non-cartesian subplots. + /// The number of columns in the grid. If you provide a 2D `subplots` array, the length of its longest row is used as the default. If you give an `xaxes` array, its length is used as the default. But it's also possible to have a different length, if you want to leave a row at the end for non-cartesian subplots. + /// Used for freeform grids, where some axes may be shared across subplots but others are not. Each entry should be a cartesian subplot id, like "xy" or "x3y2", or "" to leave that cell empty. You may reuse x axes within the same column, and y axes within the same row. Non-cartesian subplots and traces that support `domain` can place themselves in this grid separately using the `gridcell` attribute. + /// Used with `yaxes` when the x and y axes are shared across columns and rows. Each entry should be an y axis id like "y", "y2", etc., or "" to not put a y axis in that row. Entries other than "" must be unique. Ignored if `subplots` is present. If missing but `xaxes` is present, will generate consecutive IDs. + /// Used with `yaxes` when the x and y axes are shared across columns and rows. Each entry should be an x axis id like "x", "x2", etc., or "" to not put an x axis in that column. Entries other than "" must be unique. Ignored if `subplots` is present. If missing but `yaxes` is present, will generate consecutive IDs. + /// Is the first row the top or the bottom? Note that columns are always enumerated from left to right. + /// If no `subplots`, `xaxes`, or `yaxes` are given but we do have `rows` and `columns`, we can generate defaults using consecutive axis IDs, in two ways: "coupled" gives one x axis per column and one y axis per row. "independent" uses a new xy pair for each cell, left-to-right across each row then iterating rows according to `roworder`. + /// Horizontal space between grid cells, expressed as a fraction of the total width available to one cell. Defaults to 0.1 for coupled-axes grids and 0.2 for independent grids. + /// Vertical space between grid cells, expressed as a fraction of the total height available to one cell. Defaults to 0.1 for coupled-axes grids and 0.3 for independent grids. + /// Sets the domains of this grid subplot (in plot fraction). The first and last cells end exactly at the domain edges, with no grout around the edges. + /// Sets where the x axis labels and titles go. "bottom" means the very bottom of the grid. "bottom plot" is the lowest plot that each x axis is used in. "top" and "top plot" are similar. + /// Sets where the y axis labels and titles go. "left" means the very left edge of the grid. "left plot" is the leftmost plot that each y axis is used in. "right" and "right plot" are similar. + 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 + ) => + 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) + ).Invoke(gCharts); + } +} diff --git a/src/Plotly.NET.CSharp/ChartAPI/Chart2D.cs b/src/Plotly.NET.CSharp/ChartAPI/Chart2D.cs new file mode 100644 index 000000000..ead50d7d4 --- /dev/null +++ b/src/Plotly.NET.CSharp/ChartAPI/Chart2D.cs @@ -0,0 +1,440 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Plotly.NET; +using Plotly.NET.LayoutObjects; +using Plotly.NET.TraceObjects; + +namespace Plotly.NET.CSharp +{ + public static partial class Chart + { + /// + /// Creates a Scatter plot. + /// + /// Scatter charts are the basis of Point, Line, and Bubble Charts, and can be customized as such. We also provide abstractions for those Chart.Line, Chart.Point, Chart.Bubble + /// + /// Sets the x coordinates of the plotted data. + /// Sets the y coordinates of the plotted data. + /// Determines the drawing mode for this scatter trace. + /// Sets the trace name. The trace name appear as the legend item and on hover + /// Determines whether or not an item corresponding to this trace is shown in the legend. + /// Sets the opactity of the trace + /// Sets the opactity of individual datum markers + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the position of text associated with each datum + /// Sets the position of text associated with individual datum + /// Sets the color of the marker + /// Sets the colorscale of the marker + /// Sets the outline of the marker + /// Sets the marker symbol for each datum + /// Sets the marker symbol for each individual datum + /// Sets the marker (use this for more finegrained control than the other marker-associated arguments) + /// Sets the color of the line + /// Sets the colorscale of the line + /// Sets the width of the line + /// sets the drawing style of the line + /// Sets the line (use this for more finegrained control than the other line-associated arguments) + /// Set several traces (on the same subplot) to the same stackgroup in order to add their y values (or their x values if `Orientation` is Horizontal). Stacking also turns `fill` on by default and sets the default `mode` to "lines" irrespective of point count. ou can only stack on a numeric (linear or log) axis. Traces in a `stackgroup` will only fill to (or be filled to) other traces in the same group. With multiple `stackgroup`s or some traces stacked and some not, if fill-linked traces are not already consecutive, the later ones will be pushed down in the drawing order + /// Sets the stacking direction. Only relevant when `stackgroup` is used, and only the first `orientation` found in the `stackgroup` will be used. + /// Sets the normalization for the sum of this `stackgroup. Only relevant when `stackgroup` is used, and only the first `groupnorm` found in the `stackgroup` will be used + /// Sets the area to fill with a solid color. Defaults to "none" unless this trace is stacked, then it gets "tonexty" ("tonextx") if `orientation` is "v" ("h") Use with `FillColor` if not "none". "tozerox" and "tozeroy" fill to x=0 and y=0 respectively. "tonextx" and "tonexty" fill between the endpoints of this trace and the endpoints of the trace before it, connecting those endpoints with straight lines (to make a stacked area graph); if there is no trace before it, they behave like "tozerox" and "tozeroy". "toself" connects the endpoints of the trace (or each segment of the trace if it has gaps) into a closed shape. "tonext" fills the space between two traces if one completely encloses the other (eg consecutive contour lines), and behaves like "toself" if there is no trace before it. "tonext" should not be used if one trace does not enclose the other. Traces in a `stackgroup` will only fill to (or be filled to) other traces in the same group. With multiple `stackgroup`s or some traces stacked and some not, if fill-linked traces are not already consecutive, the later ones will be pushed down in the drawing order. + /// ets the fill color. Defaults to a half-transparent variant of the line color, marker color, or marker line color, whichever is available. + /// If true, plotly.js will use the WebGL engine to render this chart. use this when you want to render many objects at once. + /// If set to false, ignore the global default settings set in `Defaults` + 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 + ) + where XType : IConvertible + where YType : IConvertible + where TextType : class, 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) + ); + + /// + /// Creates a Point chart, which uses Points in a 2D space to visualize data. + /// + /// Sets the x coordinates of the plotted data. + /// Sets the y coordinates of the plotted 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 opactity of individual datum markers + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the position of text associated with each datum + /// Sets the position of text associated with individual datum + /// Sets the color of the marker + /// Sets the colorscale of the marker + /// Sets the outline of the marker + /// Sets the marker symbol for each datum + /// Sets the marker symbol for each individual datum + /// Sets the marker (use this for more finegrained control than the other marker-associated arguments) + /// Set several traces (on the same subplot) to the same stackgroup in order to add their y values (or their x values if `Orientation` is Horizontal). Stacking also turns `fill` on by default and sets the default `mode` to "lines" irrespective of point count. ou can only stack on a numeric (linear or log) axis. Traces in a `stackgroup` will only fill to (or be filled to) other traces in the same group. With multiple `stackgroup`s or some traces stacked and some not, if fill-linked traces are not already consecutive, the later ones will be pushed down in the drawing order + /// Sets the stacking direction. Only relevant when `stackgroup` is used, and only the first `orientation` found in the `stackgroup` will be used. + /// Sets the normalization for the sum of this `stackgroup. Only relevant when `stackgroup` is used, and only the first `groupnorm` found in the `stackgroup` will be used + /// If true, plotly.js will use the WebGL engine to render this chart. use this when you want to render many objects at once. + /// If set to false, ignore the global default settings set in `Defaults` + 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 + ) + where XType : IConvertible + where YType : IConvertible + where TextType : class, 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) + ); + + /// 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. + /// Sets the x coordinates of the plotted data. + /// Sets the y coordinates of the plotted data. + /// Wether to show markers for the individual data points + /// Sets the trace name. The trace name appear as the legend item and on hover + /// Determines whether or not an item corresponding to this trace is shown in the legend. + /// Sets the opactity of the trace + /// Sets the opactity of individual datum markers + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the position of text associated with each datum + /// Sets the position of text associated with individual datum + /// Sets the color of the marker + /// Sets the colorscale of the marker + /// Sets the outline of the marker + /// Sets the marker symbol for each datum + /// Sets the marker symbol for each individual datum + /// Sets the marker (use this for more finegrained control than the other marker-associated arguments) + /// Sets the color of the line + /// Sets the colorscale of the line + /// Sets the width of the line + /// sets the drawing style of the line + /// Sets the line (use this for more finegrained control than the other line-associated arguments) + /// Set several traces (on the same subplot) to the same stackgroup in order to add their y values (or their x values if `Orientation` is Horizontal). Stacking also turns `fill` on by default and sets the default `mode` to "lines" irrespective of point count. ou can only stack on a numeric (linear or log) axis. Traces in a `stackgroup` will only fill to (or be filled to) other traces in the same group. With multiple `stackgroup`s or some traces stacked and some not, if fill-linked traces are not already consecutive, the later ones will be pushed down in the drawing order + /// Sets the stacking direction. Only relevant when `stackgroup` is used, and only the first `orientation` found in the `stackgroup` will be used. + /// Sets the normalization for the sum of this `stackgroup. Only relevant when `stackgroup` is used, and only the first `groupnorm` found in the `stackgroup` will be used + /// Sets the area to fill with a solid color. Defaults to "none" unless this trace is stacked, then it gets "tonexty" ("tonextx") if `orientation` is "v" ("h") Use with `FillColor` if not "none". "tozerox" and "tozeroy" fill to x=0 and y=0 respectively. "tonextx" and "tonexty" fill between the endpoints of this trace and the endpoints of the trace before it, connecting those endpoints with straight lines (to make a stacked area graph); if there is no trace before it, they behave like "tozerox" and "tozeroy". "toself" connects the endpoints of the trace (or each segment of the trace if it has gaps) into a closed shape. "tonext" fills the space between two traces if one completely encloses the other (eg consecutive contour lines), and behaves like "toself" if there is no trace before it. "tonext" should not be used if one trace does not enclose the other. Traces in a `stackgroup` will only fill to (or be filled to) other traces in the same group. With multiple `stackgroup`s or some traces stacked and some not, if fill-linked traces are not already consecutive, the later ones will be pushed down in the drawing order. + /// ets the fill color. Defaults to a half-transparent variant of the line color, marker color, or marker line color, whichever is available. + /// If true, plotly.js will use the WebGL engine to render this chart. use this when you want to render many objects at once. + /// If set to false, ignore the global default settings set in `Defaults` + 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 + ) + where XType : IConvertible + where YType : IConvertible + where TextType : class, 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) + ); + + /// + /// Creates a bar chart, with bars plotted horizontally + /// + /// A bar chart is a chart that presents categorical data with rectangular bars with heights or lengths proportional to the values that they represent. + /// + /// Sets the values that are plotted as the size of each bar. + /// Sets the keys associated with each bar. + /// 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 Opacity of each individual bar. + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the color of the bars + /// Sets the colorscale for the bars. To have an effect, `MarkerColor` must map to color scale values. + /// Sets the color of the bar outlines + /// Sets a pattern shape for all bars + /// Sets an individual pattern shape for each bar + /// Sets the marker pattern (use this for more finegrained control than the other pattern-associated arguments). + /// Sets the marker for the bars (use this for more finegrained control than the other marker-associated arguments). + /// Sets where the bar base is drawn (in position axis units). + /// Sets the bar width (in position axis units) of all bars. + /// Sets the individual bar width (in position axis units) for each bar. + /// Sets the position of text associated with each datum + /// 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 + ) + where ValuesType : IConvertible + where KeysType : IConvertible + where TextType: class, IConvertible + => + Plotly.NET.Chart2D.Chart.Bar( + values: values, + Keys: Keys.ToOption(), + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOptionV(), + Opacity: Opacity.ToOptionV(), + MultiOpacity: MultiOpacity.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + MarkerColor: MarkerColor.ToOption(), + MarkerColorScale: MarkerColorScale.ToOption(), + MarkerOutline: MarkerOutline.ToOption(), + MarkerPatternShape: MarkerPatternShape.ToOption(), + MultiMarkerPatternShape: MultiMarkerPatternShape.ToOption(), + MarkerPattern: MarkerPattern.ToOption(), + Marker: Marker.ToOption(), + Base: Base.ToOption(), + Width: Width.ToOption(), + MultiWidth: MultiWidth.ToOption(), + TextPosition: TextPosition.ToOption(), + MultiTextPosition: MultiTextPosition.ToOption(), + UseDefaults: UseDefaults.ToOptionV() + ); + /// + /// Creates a column chart, with bars plotted vertically + /// + /// A column chart is a chart that presents categorical data with rectangular bars with heights or lengths proportional to the values that they represent. + /// + /// Sets the values that are plotted as the size of each bar. + /// Sets the keys associated with each bar. + /// 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 Opacity of each individual bar. + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the color of the bars + /// Sets the colorscale for the bars. To have an effect, `MarkerColor` must map to color scale values. + /// Sets the color of the bar outlines + /// Sets a pattern shape for all bars + /// Sets an individual pattern shape for each bar + /// Sets the marker pattern (use this for more finegrained control than the other pattern-associated arguments). + /// Sets the marker for the bars (use this for more finegrained control than the other marker-associated arguments). + /// Sets where the bar base is drawn (in position axis units). + /// Sets the bar width (in position axis units) of all bars. + /// Sets the individual bar width (in position axis units) for each bar. + /// Sets the position of text associated with each datum + /// 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 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 + ) + where ValuesType : IConvertible + where KeysType : IConvertible + where TextType : class, IConvertible + => + Plotly.NET.Chart2D.Chart.Column( + values: values, + Keys: Keys.ToOption(), + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOptionV(), + Opacity: Opacity.ToOptionV(), + MultiOpacity: MultiOpacity.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + MarkerColor: MarkerColor.ToOption(), + MarkerColorScale: MarkerColorScale.ToOption(), + MarkerOutline: MarkerOutline.ToOption(), + MarkerPatternShape: MarkerPatternShape.ToOption(), + MultiMarkerPatternShape: MultiMarkerPatternShape.ToOption(), + MarkerPattern: MarkerPattern.ToOption(), + Marker: Marker.ToOption(), + Base: Base.ToOption(), + Width: Width.ToOption(), + MultiWidth: MultiWidth.ToOption(), + TextPosition: TextPosition.ToOption(), + MultiTextPosition: MultiTextPosition.ToOption(), + UseDefaults: UseDefaults.ToOptionV() + ); + }; +} diff --git a/src/Plotly.NET.CSharp/ChartAPI/Chart3D.cs b/src/Plotly.NET.CSharp/ChartAPI/Chart3D.cs new file mode 100644 index 000000000..608f81c28 --- /dev/null +++ b/src/Plotly.NET.CSharp/ChartAPI/Chart3D.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Plotly.NET; +using Plotly.NET.LayoutObjects; +using Plotly.NET.TraceObjects; + +namespace Plotly.NET.CSharp +{ + public static partial class Chart + { + /// + /// Creates a Scatter3D plot. + /// + /// In general, Scatter3D Plots plot three-dimensional data on 3 cartesian position scales in the X, Y, and Z dimension. + /// + /// Scatter3D charts are the basis of Point3D, Line3D, and Bubble3D Charts, and can be customized as such. We also provide abstractions for those: Chart.Line3D, Chart.Point3D, Chart.Bubble3D + /// + /// Sets the x coordinates of the plotted data. + /// Sets the y coordinates of the plotted data. + /// Sets the z coordinates of the plotted data. + /// Determines the drawing mode for this scatter trace. + /// Sets the trace name. The trace name appear as the legend item and on hover + /// Determines whether or not an item corresponding to this trace is shown in the legend. + /// Sets the opactity of the trace + /// Sets the opactity of individual datum markers + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the position of text associated with each datum + /// Sets the position of text associated with individual datum + /// Sets the color of the marker + /// Sets the colorscale of the marker + /// Sets the outline of the marker + /// Sets the marker symbol for each datum + /// Sets the marker symbol for each individual datum + /// Sets the marker (use this for more finegrained control than the other marker-associated arguments) + /// Sets the color of the line + /// Sets the colorscale of the line + /// Sets the width of the line + /// sets the drawing style of the line + /// Sets the line (use this for more finegrained control than the other line-associated arguments) + /// 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, + 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 + ) + where XData: IConvertible + where YData: IConvertible + where ZData: IConvertible + where TextData: class, IConvertible + + => 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) + ); + } +} diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartCarpet.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartCarpet.cs new file mode 100644 index 000000000..613c9f2c8 --- /dev/null +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartCarpet.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Plotly.NET.LayoutObjects; +using Plotly.NET.TraceObjects; + +namespace Plotly.NET.CSharp +{ + public static partial class Chart + { + /// + /// Creates a carpet in a 2D coordinate system to be used as additional coordinate system in a carpet plot. + /// + /// A carpet plot illustrates the interaction between two or more independent variables and one or more dependent variables in a two-dimensional plot. + /// Besides the ability to incorporate more variables, another feature that distinguishes a carpet plot from an equivalent contour plot or 3D surface plot is that a carpet plot can be used to more accurately interpolate data points. + /// A conventional carpet plot can capture the interaction of up to three independent variables and three dependent variables and still be easily read and interpolated. + /// + /// Three-variable carpet plot (cheater plot): + /// + /// A carpet plot with two independent variables and one dependent variable is often called a cheater plot for the use of a phantom "cheater" axis instead of the horizontal axis. As a result of this missing axis, the values can be shifted horizontally such that the intersections line up vertically. This allows easy interpolation by having fixed horizontal intervals correspond to fixed intervals in both independent variables. + /// + /// Four-variable carpet plot (true carpet plot) + /// + /// Instead of using the horizontal axis to adjust the plot perspective and align carpet intersections vertically, the horizontal axis can be used to show the effects on an additional dependent variable.[5] In this case the perspective is fixed, and any overlapping cannot be adjusted. Because a true carpet plot represents two independent variables and two dependent variables simultaneously, there is no corresponding way to show the information on a conventional contour plot or 3D surface plot. + /// + /// (from https://en.wikipedia.org/wiki/Carpet_plot @ 1/11/2021) + /// + /// An identifier for this carpet, so that `scattercarpet` and `contourcarpet` traces can specify a carpet plot on which they lie. + /// 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 + /// A one dimensional array of x coordinates matching the dimensions of `a` and `b`. + /// A two dimensional array of x coordinates at each carpet point. If omitted, the plot is a cheater plot and the xaxis is hidden by default. + /// A one dimensional array of y coordinates matching the dimensions of `a` and `b`. + /// A two dimensional array of y coordinates at each carpet point. + /// An array containing values of the first parameter value + /// An array containing values of the second parameter value + /// Sets this carpet's a axis. + /// Sets this carpet's b axis. + /// Sets a reference between this trace's x coordinates and a 2D cartesian x axis. If "x" (the default value), the x coordinates refer to `layout.xaxis`. If "x2", the x coordinates refer to `layout.xaxis2`, and so on. + /// Sets a reference between this trace's y coordinates and a 2D cartesian y axis. If "y" (the default value), the y coordinates refer to `layout.yaxis`. If "y2", the y coordinates refer to `layout.yaxis2`, and so on. + /// Sets default for all colors associated with this axis all at once: line, font, tick, and grid colors. Grid color is lightened by blending this with the plot background Individual pieces can override this. + /// The shift applied to each successive row of data in creating a cheater plot. Only used if `x` is been omitted. + /// 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 + ) + where XType : IConvertible + where MultiXType : IConvertible + where YType : IConvertible + where MultiYType : IConvertible + where AType : IConvertible + where BType : IConvertible + => + Plotly.NET.ChartCarpet.Chart.Carpet, MultiXType, YType, IEnumerable, MultiYType, AType, BType>( + carpetId: carpetId, + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOptionV(), + Opacity: Opacity.ToOptionV(), + X: X.ToOption(), + MultiX: MultiX.ToOption(), + Y: Y.ToOption(), + MultiY: MultiY.ToOption(), + A: A.ToOption(), + B: B.ToOption(), + AAxis: AAxis.ToOption(), + BAxis: BAxis.ToOption(), + XAxis: XAxis.ToOption(), + YAxis: YAxis.ToOption(), + Color: Color.ToOption(), + CheaterSlope: CheaterSlope.ToOptionV(), + UseDefaults: UseDefaults.ToOptionV() + ); + } +} diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartDomain.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartDomain.cs new file mode 100644 index 000000000..64eca5507 --- /dev/null +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartDomain.cs @@ -0,0 +1,98 @@ +using Plotly.NET; +using Plotly.NET.LayoutObjects; +using Plotly.NET.TraceObjects; + + +namespace Plotly.NET.CSharp +{ + public static partial class Chart + { + /// + /// Creates a pie chart. + /// + /// A pie chart (or a circle chart) is a circular statistical graphic, which is divided into slices to illustrate numerical proportion. + /// In a pie chart, the arc length of each slice (and consequently its central angle and area), is proportional to the quantity it represents. + /// + /// Sets the values of the sectors + /// Sets the trace name. The trace name appear as the legend item and on hover + /// Determines whether or not an item corresponding to this trace is shown in the legend. + /// Sets the opactity of the trace + /// Sets the opactity of individual datum markers + /// Sets the sector labels. If `labels` entries are duplicated, the associated `values` are summed. + /// Sets the fraction of larger radius to pull the sectors out from the center. This can be a constant to pull all slices apart from each other equally or an array to highlight one or more slices. + /// Sets the fraction of larger radius to pull the sectors out from the center. This can be a constant to pull all slices apart from each other equally or an array to highlight one or more slices. + /// Sets text elements associated with each (x,y) pair. If a single string, the same string appears over all the data points. If an array of string, the items are mapped in order to the this trace's (x,y) coordinates. If trace `hoverinfo` contains a "text" flag and "hovertext" is not set, these elements will be seen in the hover labels. + /// Sets text elements associated with each (x,y) pair. If a single string, the same string appears over all the data points. If an array of string, the items are mapped in order to the this trace's (x,y) coordinates. If trace `hoverinfo` contains a "text" flag and "hovertext" is not set, these elements will be seen in the hover labels. + /// Sets the positions of the `text` elements with respects to the (x,y) coordinates. + /// Sets the positions of the `text` elements with respects to the (x,y) coordinates. + /// Sets the colors associated with each section. + /// Sets the color of the section outline. + /// Sets the width of the section outline. + /// Sets the width of each individual section outline. + /// Sets the section outline (use this for more finegrained control than the other section outline-associated arguments). + /// Sets the marker of this trace. + /// Determines which trace information appear on the graph. + /// Specifies the direction at which succeeding sectors follow one another. + /// Sets the fraction of the radius to cut out of the pie. Use this to make a donut chart. + /// Instead of the first slice starting at 12 o'clock, rotate to some other angle. + /// Determines whether or not the sectors are reordered from largest to smallest. + /// 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 + ) + where ValuesType : IConvertible + where LabelsType : IConvertible + where TextType : class, IConvertible + => + Plotly.NET.ChartDomain.Chart.Pie( + values: values, + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOptionV(), + Opacity: Opacity.ToOptionV(), + MultiOpacity: MultiOpacity.ToOption(), + Labels: Labels.ToOption(), + Pull: Pull.ToOptionV(), + MultiPull: MultiPull.ToOption(), + Text: Text.ToOption(), + MultiText: MultiText.ToOption(), + TextPosition: TextPosition.ToOption(), + MultiTextPosition: MultiTextPosition.ToOption(), + SectionColors: SectionColors.ToOption(), + SectionOutlineColor: SectionOutlineColor.ToOption(), + SectionOutlineWidth: SectionOutlineWidth.ToOptionV(), + 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() + ); + + } +} diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs new file mode 100644 index 000000000..90ee010df --- /dev/null +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartMap.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Plotly.NET; +using Plotly.NET.LayoutObjects; +using Plotly.NET.TraceObjects; + +namespace Plotly.NET.CSharp +{ + public static partial class Chart + { + /// + /// Creates a ScatterGeo chart, where data is visualized using plotly's base geo map. + /// + /// In general, ScatterGeo Plots plot two-dimensional data on a geo map via (lat,lon) coordinates. + /// + /// ScatterGeo charts are the basis of PointGeo, LineGeo, and BubbleGeo Charts, and can be customized as such. We also provide abstractions for those: Chart.PointGeo, Chart.LineGeo, Chart.BubbleGeo + /// + /// Sets the longitude coordinates (in degrees East). + /// Sets the latitude coordinates (in degrees North). + /// Determines the drawing mode for this scatter trace. + /// Sets the trace name. The trace name appear as the legend item and on hover + /// Determines whether or not an item corresponding to this trace is shown in the legend. + /// Sets the opactity of the trace + /// Sets the opactity of individual datum markers + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the position of text associated with each datum + /// Sets the position of text associated with individual datum + /// Sets the color of the marker + /// Sets the colorscale of the marker + /// Sets the outline of the marker + /// Sets the marker symbol for each datum + /// Sets the marker symbol for each individual datum + /// Sets the marker (use this for more finegrained control than the other marker-associated arguments) + /// Sets the color of the line + /// Sets the colorscale of the line + /// Sets the width of the line + /// sets the drawing style of the line + /// Sets the line (use this for more finegrained control than the other line-associated arguments) + /// Determines the set of locations used to match entries in `locations` to regions on the map. Values "ISO-3", "USA-states", "country names" correspond to features on the base map and value "geojson-id" corresponds to features from a custom GeoJSON linked to the `geojson` attribute. + /// Sets optional GeoJSON data associated with this trace. If not given, the features on the base map are used. It can be set as a valid GeoJSON object or as a URL string. Note that we only accept GeoJSONs of type "FeatureCollection" or "Feature" with geometries of type "Polygon" or "MultiPolygon". + /// Sets the key in GeoJSON features which is used as id to match the items included in the `locations` array. Only has an effect when `geojson` is set. Support nested property, for example "properties.name". + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart ScatterGeo( + IEnumerable 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 + ) + where LongitudesType : IConvertible + where LatitudesType : IConvertible + where TextType : class, 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) + ); + } +} diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartPolar.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartPolar.cs new file mode 100644 index 000000000..be5bd5a81 --- /dev/null +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartPolar.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Plotly.NET; +using Plotly.NET.LayoutObjects; +using Plotly.NET.TraceObjects; + +namespace Plotly.NET.CSharp +{ + public static partial class Chart + { + /// + /// Creates a polar scatter plot. + /// + /// In general, ScatterPolar plots plot two-dimensional data on a polar coordinate system comprised of angular and radial position scales. + /// + /// ScatterPolar charts are the basis of PointPolar, LinePolar, SplinePolar, and BubblePolar Charts, and can be customized as such. We also provide abstractions for those: Chart.PointPolar, Chart.LinePolar, Chart.SplinePolar , Chart.BubblePolar + /// + /// Sets the radial coordinates of the plotted data + /// Sets the angular coordinates of the plotted data (in degrees) + /// Determines the drawing mode for this scatter trace. + /// Sets the trace name. The trace name appear as the legend item and on hover + /// Determines whether or not an item corresponding to this trace is shown in the legend. + /// Sets the opactity of the trace + /// Sets the opactity of individual datum markers + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the position of text associated with each datum + /// Sets the position of text associated with individual datum + /// Sets the color of the marker + /// Sets the colorscale of the marker + /// Sets the outline of the marker + /// Sets the marker symbol for each datum + /// Sets the marker symbol for each individual datum + /// Sets the marker (use this for more finegrained control than the other marker-associated arguments) + /// Sets the color of the line + /// Sets the colorscale of the line + /// Sets the width of the line + /// sets the drawing style of the line + /// Sets the line (use this for more finegrained control than the other line-associated arguments) + /// If true, plotly.js will use the WebGL engine to render this chart. use this when you want to render many objects at once. + /// If set to false, ignore the global default settings set in `Defaults` + 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 + ) + where RType : IConvertible + where ThetaType : IConvertible + where TextType : class, 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) + ); + } +} diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartSmith.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartSmith.cs new file mode 100644 index 000000000..f677fff2c --- /dev/null +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartSmith.cs @@ -0,0 +1,100 @@ +using Plotly.NET; +using Plotly.NET.LayoutObjects; +using Plotly.NET.TraceObjects; + +namespace Plotly.NET.CSharp +{ + public static partial class Chart + { + /// + /// Creates a Scatter plot on a smith coordinate system. + /// + /// In general, ScatterSmith charts plot complex numbers on a transformed two-dimensional Cartesian complex plane. Complex numbers with positive real parts map inside the circle. Those with negative real parts map outside the circle. + /// + /// ScatterSmith charts are the basis of PointSmith, LineSmith, and BubbleSmith Charts, and can be customized as such. We also provide abstractions for those: Chart.LineSmith, Chart.PointSmith, Chart.BubbleSmith + /// + /// Sets the real component of the data, in units of normalized impedance such that real=1, imag=0 is the center of the chart. + /// Sets the imaginary component of the data, in units of normalized impedance such that real=1, imag=0 is the center of the chart. + /// Determines the drawing mode for this scatter trace. + /// Sets the trace name. The trace name appear as the legend item and on hover + /// Determines whether or not an item corresponding to this trace is shown in the legend. + /// Sets the opactity of the trace + /// Sets the opactity of individual datum markers + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the position of text associated with each datum + /// Sets the position of text associated with individual datum + /// Sets the color of the marker + /// Sets the colorscale of the marker + /// Sets the outline of the marker + /// Sets the marker symbol for each datum + /// Sets the marker symbol for each individual datum + /// Sets the marker (use this for more finegrained control than the other marker-associated arguments) + /// Sets the color of the line + /// Sets the colorscale of the line + /// Sets the width of the line + /// sets the drawing style of the line + /// Sets the line (use this for more finegrained control than the other line-associated arguments) + /// Sets the area to fill with a solid color. Defaults to "none" unless this trace is stacked, then it gets "tonexty" ("tonextx") if `orientation` is "v" ("h") Use with `FillColor` if not "none". "tozerox" and "tozeroy" fill to x=0 and y=0 respectively. "tonextx" and "tonexty" fill between the endpoints of this trace and the endpoints of the trace before it, connecting those endpoints with straight lines (to make a stacked area graph); if there is no trace before it, they behave like "tozerox" and "tozeroy". "toself" connects the endpoints of the trace (or each segment of the trace if it has gaps) into a closed shape. "tonext" fills the space between two traces if one completely encloses the other (eg consecutive contour lines), and behaves like "toself" if there is no trace before it. "tonext" should not be used if one trace does not enclose the other. Traces in a `stackgroup` will only fill to (or be filled to) other traces in the same group. With multiple `stackgroup`s or some traces stacked and some not, if fill-linked traces are not already consecutive, the later ones will be pushed down in the drawing order. + /// ets the fill color. Defaults to a half-transparent variant of the line color, marker color, or marker line color, whichever is available. + /// If set to false, ignore the global default settings set in `Defaults` + public static GenericChart.GenericChart ScatterSmith( + IEnumerable 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 + ) + where RealType : IConvertible + where ImagType : IConvertible + where TextType : class, IConvertible + => + Plotly.NET.ChartSmith.Chart.ScatterSmith( + real: real, + imag: imag, + mode: mode, + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOptionV(), + Opacity: Opacity.ToOptionV(), + 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.ToOptionV(), + LineDash: LineDash.ToOption(), + Line: Line.ToOption(), + Fill: Fill.ToOption(), + FillColor: FillColor.ToOption(), + UseDefaults: UseDefaults.ToOptionV() + ); + } +} diff --git a/src/Plotly.NET.CSharp/ChartAPI/ChartTernary.cs b/src/Plotly.NET.CSharp/ChartAPI/ChartTernary.cs new file mode 100644 index 000000000..9828d5601 --- /dev/null +++ b/src/Plotly.NET.CSharp/ChartAPI/ChartTernary.cs @@ -0,0 +1,106 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Plotly.NET.LayoutObjects; +using Plotly.NET.TraceObjects; + +namespace Plotly.NET.CSharp +{ + public static partial class Chart + { + /// + /// Creates a Scatter plot on a ternary coordinate system + /// + /// In general, ScatterTernary creates a barycentric plot on three variables which sum to a constant, graphically depicting the ratios of the three variables as positions in an equilateral triangle. + /// + /// ScatterTernary charts are the basis of PointTernary, LineTernary, and BubbleTernary Charts, and can be customized as such. We also provide abstractions for those: Chart.LineTernary, Chart.PointTernary, Chart.BubbleTernary + /// + /// Sets the quantity of component `a` in each data point. If `a`, `b`, and `c` are all provided, they need not be normalized, only the relative values matter. If only two arrays are provided they must be normalized to match `ternary<i>.sum`. + /// Sets the quantity of component `b` in each data point. If `a`, `b`, and `c` are all provided, they need not be normalized, only the relative values matter. If only two arrays are provided they must be normalized to match `ternary<i>.sum`. + /// Sets the quantity of component `c` in each data point. If `a`, `b`, and `c` are all provided, they need not be normalized, only the relative values matter. If only two arrays are provided they must be normalized to match `ternary<i>.sum`. + /// The number each triplet should sum to, if only two of `a`, `b`, and `c` are provided. This overrides `ternary<i>.sum` to normalize this specific trace, but does not affect the values displayed on the axes. 0 (or missing) means to use `ternary<i>.sum` + /// Determines the drawing mode for this scatter trace. + /// Sets the trace name. The trace name appear as the legend item and on hover + /// Determines whether or not an item corresponding to this trace is shown in the legend. + /// Sets the opactity of the trace + /// Sets the opactity of individual datum markers + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the position of text associated with each datum + /// Sets the position of text associated with individual datum + /// Sets the color of the marker + /// Sets the colorscale of the marker + /// Sets the outline of the marker + /// Sets the marker symbol for each datum + /// Sets the marker symbol for each individual datum + /// Sets the marker (use this for more finegrained control than the other marker-associated arguments) + /// Sets the color of the line + /// Sets the colorscale of the line + /// Sets the width of the line + /// sets the drawing style of the line + /// Sets the line (use this for more finegrained control than the other line-associated arguments) + /// 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 + ) + where AType : IConvertible + where BType : IConvertible + where CType : IConvertible + where SumType : class, IConvertible + where TextType : class, IConvertible + => + Plotly.NET.ChartTernary.Chart.ScatterTernary( + A: A.ToOption(), + B: B.ToOption(), + C: C.ToOption(), + Sum: Sum.ToOption(), + Mode: Mode.ToOption(), + Name: Name.ToOption(), + ShowLegend: ShowLegend.ToOptionV(), + Opacity: Opacity.ToOptionV(), + 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.ToOptionV(), + LineDash: LineDash.ToOption(), + Line: Line.ToOption(), + UseDefaults: UseDefaults.ToOptionV() + ); + } +} diff --git a/src/Plotly.NET.CSharp/GenericChartExtensions.cs b/src/Plotly.NET.CSharp/GenericChartExtensions.cs new file mode 100644 index 000000000..a8d6e52b0 --- /dev/null +++ b/src/Plotly.NET.CSharp/GenericChartExtensions.cs @@ -0,0 +1,277 @@ +using Plotly.NET; +using Plotly.NET.LayoutObjects; +using Plotly.NET.TraceObjects; + +namespace Plotly.NET.CSharp +{ + public static class GenericChartExtensions + { + public static Layout GetLayout(this GenericChart.GenericChart gChart) => GenericChart.getLayout(gChart); + + 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 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 + ) => + Plotly.NET.Chart.SaveHtml( + path: path, + OpenInBrowser: OpenInBrowser.ToOptionV() + ).Invoke(gChart); + + /// + /// Saves the given chart as a temporary html file and opens it 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. + /// + /// 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. + /// Sets the legend rank for the chart's trace(s). Items and groups with smaller ranks are presented on top/left side while with `"reversed" `legend.traceorder` they are on bottom/right side. The default legendrank is 1000, so that you can use ranks less than 1000 to place certain items before all unranked items, and ranks greater than 1000 to go after all unranked items. + /// Sets the legend group for the chart's trace(s). Traces part of the same legend group hide/show at the same time when toggling legend items. + /// 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 + ) => + Plotly.NET.Chart.WithTraceInfo( + Name: Name.ToOption(), + Visible: Visible.ToOption(), + ShowLegend: ShowLegend.ToOptionV(), + LegendRank: LegendRank.ToOptionV(), + LegendGroup: LegendGroup.ToOption(), + LegendGroupTitle: LegendGroupTitle.ToOption() + ).Invoke(gChart); + + /// Sets the size of a Chart (in pixels) + public static GenericChart.GenericChart WithSize( + this GenericChart.GenericChart gChart, + int? Width = null, + int? Height = null + ) => + Plotly.NET.Chart.WithSize(Width: Width.ToOptionV(), Height: Height.ToOptionV()).Invoke(gChart); + + /// + /// 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. + /// + /// Sets the text of the axis title. + /// Sets the font of the axis title. + /// Sets the standoff distance (in px) between the axis labels and the title text. + /// Sets the Title (use this for more finegrained control than the other title-associated arguments) + /// Sets default for all colors associated with this axis all at once: line, font, tick, and grid colors. + /// Sets the axis type. By default, plotly attempts to determined the axis type by looking into the data of the traces that referenced the axis in question. + /// Tuple of (Min*Max value). Sets the range of this axis (the axis will go from Min to Max). If the axis `type` is "log", then you must take the log of your desired range (e.g. to set the range from 1 to 100, set the range from 0 to 2). + /// Determines if and how the axis lines or/and ticks are mirrored to the opposite side of the plotting area. + /// Determines whether or not spikes (aka droplines) are drawn for this axis. + /// Sets the spike color. If not set, will use the series color + /// Sets the width (in px) of the zero line. + /// Determines whether or not a line bounding this axis is drawn. + /// Sets the axis line color. + /// Determines whether or not grid lines are drawn. If "true", the grid lines are drawn at every tick mark. + /// Sets the color of the grid lines. + /// Determines whether or not a line is drawn at along the 0 value of this axis. If "true", the zero line is drawn on top of the grid lines. + /// Sets the line color of the zero line. + /// If set to an opposite-letter axis id (e.g. `x2`, `y`), this axis is bound to the corresponding opposite-letter axis. If set to "free", this axis' position is determined by `position`. + /// Determines whether a x (y) axis is positioned at the "bottom" ("left") or "top" ("right") of the plotting area. + /// If set a same-letter axis id, this axis is overlaid on top of the corresponding same-letter axis, with traces and axes visible for both axes. If "false", this axis does not overlay any same-letter axes. In this case, for axes with overlapping domains only the highest-numbered axis will be visible. + /// Tuple of (X*Y fractions). Sets the domain of this axis (in plot fraction). + /// Sets the position of this axis in the plotting space (in normalized coordinates). Only has an effect if `anchor` is set to "free". + /// Specifies the ordering logic for the case of categorical variables. By default, plotly uses "trace", which specifies the order that is present in the data supplied. Set `categoryorder` to "category ascending" or "category descending" if order should be determined by the alphanumerical order of the category names. Set `categoryorder` to "array" to derive the ordering from the attribute `categoryarray`. If a category is not found in the `categoryarray` array, the sorting behavior for that attribute will be identical to the "trace" mode. The unspecified categories will follow the categories in `categoryarray`. Set `categoryorder` to "total ascending" or "total descending" if order should be determined by the numerical order of the values. Similarly, the order can be determined by the min, max, sum, mean or median of all the values. + /// Sets the order in which categories on this axis appear. Only has an effect if `categoryorder` is set to "array". Used with `categoryorder`. + /// Sets a range slider for this axis + /// Sets a range selector for this axis. This object contains toggable presets for the rangeslider. + /// Sets the background color of this axis' wall. (Only has an effect on 3D scenes) + /// Sets whether or not this axis' wall has a background color. (Only has an effect on 3D scenes) + /// The target axis id on which the styles should be applied. Default is 1. + public static GenericChart.GenericChart WithXAxisStyle( + this GenericChart.GenericChart gChart, + string? TitleText = null, + Font? TitleFont = null, + int? TitleStandoff = null, + Title? Title = null, + Color? Color = null, + StyleParam.AxisType? AxisType = null, + Tuple? 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? Domain = null, + double? Position = null, + StyleParam.CategoryOrder? CategoryOrder = null, + IEnumerable? CategoryArray = null, + RangeSlider? RangeSlider = null, + RangeSelector? RangeSelector = null, + Color? BackgroundColor = null, + bool? ShowBackground = null, + StyleParam.SubPlotId? Id = null + ) + where MinType : IConvertible + where MaxType : IConvertible + where CategoryArrayType : class, IConvertible + => + Plotly.NET.Chart.WithXAxisStyle( + TitleText: TitleText.ToOption(), + TitleFont: TitleFont.ToOption(), + TitleStandoff: TitleStandoff.ToOptionV(), + Title: Title.ToOption(), + Color: Color.ToOption(), + AxisType: AxisType.ToOption(), + MinMax: MinMax.ToOption(), + Mirror: Mirror.ToOption(), + ShowSpikes: ShowSpikes.ToOptionV(), + SpikeColor: SpikeColor.ToOption(), + SpikeThickness: SpikeThickness.ToOptionV(), + ShowLine: ShowLine.ToOptionV(), + LineColor: LineColor.ToOption(), + ShowGrid: ShowGrid.ToOptionV(), + GridColor: GridColor.ToOption(), + ZeroLine: ZeroLine.ToOptionV(), + ZeroLineColor: ZeroLineColor.ToOption(), + Anchor: Anchor.ToOption(), + Side: Side.ToOption(), + Overlaying: Overlaying.ToOption(), + Domain: Domain.ToOption(), + Position: Position.ToOptionV(), + CategoryOrder: CategoryOrder.ToOption(), + CategoryArray: CategoryArray.ToOption(), + RangeSlider: RangeSlider.ToOption(), + RangeSelector: RangeSelector.ToOption(), + BackgroundColor: BackgroundColor.ToOption(), + ShowBackground: ShowBackground.ToOptionV(), + Id: Id.ToOption() + + ).Invoke(gChart); + + /// + /// Sets the given y 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. + /// + /// Sets the text of the axis title. + /// Sets the font of the axis title. + /// Sets the standoff distance (in px) between the axis labels and the title text. + /// Sets the Title (use this for more finegrained control than the other title-associated arguments) + /// Sets default for all colors associated with this axis all at once: line, font, tick, and grid colors. + /// Sets the axis type. By default, plotly attempts to determined the axis type by looking into the data of the traces that referenced the axis in question. + /// Tuple of (Min*Max value). Sets the range of this axis (the axis will go from Min to Max). If the axis `type` is "log", then you must take the log of your desired range (e.g. to set the range from 1 to 100, set the range from 0 to 2). + /// Determines if and how the axis lines or/and ticks are mirrored to the opposite side of the plotting area. + /// Determines whether or not spikes (aka droplines) are drawn for this axis. + /// Sets the spike color. If not set, will use the series color + /// Sets the width (in px) of the zero line. + /// Determines whether or not a line bounding this axis is drawn. + /// Sets the axis line color. + /// Determines whether or not grid lines are drawn. If "true", the grid lines are drawn at every tick mark. + /// Sets the color of the grid lines. + /// Determines whether or not a line is drawn at along the 0 value of this axis. If "true", the zero line is drawn on top of the grid lines. + /// Sets the line color of the zero line. + /// If set to an opposite-letter axis id (e.g. `x2`, `y`), this axis is bound to the corresponding opposite-letter axis. If set to "free", this axis' position is determined by `position`. + /// Determines whether a x (y) axis is positioned at the "bottom" ("left") or "top" ("right") of the plotting area. + /// If set a same-letter axis id, this axis is overlaid on top of the corresponding same-letter axis, with traces and axes visible for both axes. If "false", this axis does not overlay any same-letter axes. In this case, for axes with overlapping domains only the highest-numbered axis will be visible. + /// Tuple of (X*Y fractions). Sets the domain of this axis (in plot fraction). + /// Sets the position of this axis in the plotting space (in normalized coordinates). Only has an effect if `anchor` is set to "free". + /// Specifies the ordering logic for the case of categorical variables. By default, plotly uses "trace", which specifies the order that is present in the data supplied. Set `categoryorder` to "category ascending" or "category descending" if order should be determined by the alphanumerical order of the category names. Set `categoryorder` to "array" to derive the ordering from the attribute `categoryarray`. If a category is not found in the `categoryarray` array, the sorting behavior for that attribute will be identical to the "trace" mode. The unspecified categories will follow the categories in `categoryarray`. Set `categoryorder` to "total ascending" or "total descending" if order should be determined by the numerical order of the values. Similarly, the order can be determined by the min, max, sum, mean or median of all the values. + /// Sets the order in which categories on this axis appear. Only has an effect if `categoryorder` is set to "array". Used with `categoryorder`. + /// Sets a range slider for this axis + /// Sets a range selector for this axis. This object contains toggable presets for the rangeslider. + /// Sets the background color of this axis' wall. (Only has an effect on 3D scenes) + /// Sets whether or not this axis' wall has a background color. (Only has an effect on 3D scenes) + /// The target axis id on which the styles should be applied. Default is 1. + public static GenericChart.GenericChart WithYAxisStyle( + this GenericChart.GenericChart gChart, + string? TitleText = null, + Font? TitleFont = null, + int? TitleStandoff = null, + Title? Title = null, + Color? Color = null, + StyleParam.AxisType? AxisType = null, + Tuple? 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? Domain = null, + double? Position = null, + StyleParam.CategoryOrder? CategoryOrder = null, + IEnumerable? CategoryArray = null, + RangeSlider? RangeSlider = null, + RangeSelector? RangeSelector = null, + Color? BackgroundColor = null, + bool? ShowBackground = null, + StyleParam.SubPlotId? Id = null + ) + where MinType : IConvertible + where MaxType : IConvertible + where CategoryArrayType : class, IConvertible + => + Plotly.NET.Chart.WithYAxisStyle( + TitleText: TitleText.ToOption(), + TitleFont: TitleFont.ToOption(), + TitleStandoff: TitleStandoff.ToOptionV(), + Title: Title.ToOption(), + Color: Color.ToOption(), + AxisType: AxisType.ToOption(), + MinMax: MinMax.ToOption(), + Mirror: Mirror.ToOption(), + ShowSpikes: ShowSpikes.ToOptionV(), + SpikeColor: SpikeColor.ToOption(), + SpikeThickness: SpikeThickness.ToOptionV(), + ShowLine: ShowLine.ToOptionV(), + LineColor: LineColor.ToOption(), + ShowGrid: ShowGrid.ToOptionV(), + GridColor: GridColor.ToOption(), + ZeroLine: ZeroLine.ToOptionV(), + ZeroLineColor: ZeroLineColor.ToOption(), + Anchor: Anchor.ToOption(), + Side: Side.ToOption(), + Overlaying: Overlaying.ToOption(), + Domain: Domain.ToOption(), + Position: Position.ToOptionV(), + CategoryOrder: CategoryOrder.ToOption(), + CategoryArray: CategoryArray.ToOption(), + RangeSlider: RangeSlider.ToOption(), + RangeSelector: RangeSelector.ToOption(), + BackgroundColor: BackgroundColor.ToOption(), + ShowBackground: ShowBackground.ToOptionV(), + 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 new file mode 100644 index 000000000..253baf0de --- /dev/null +++ b/src/Plotly.NET.CSharp/Helpers.cs @@ -0,0 +1,27 @@ +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 { + /// + /// 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 + /// + /// the thing to turn into a FSharpOption + /// The original value wrapped as a FSharpOption + static internal Microsoft.FSharp.Core.FSharpOption ToOption(this T? thing) => thing is null ? Microsoft.FSharp.Core.FSharpOption.None : new(thing); + /// + /// 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 + /// + /// the thing to turn into a FSharpOption + /// The original value wrapped as a FSharpOption + static internal Microsoft.FSharp.Core.FSharpOption ToOptionV(this T? thing) where T : struct => thing is { } some ? new(some) : Microsoft.FSharp.Core.FSharpOption.None; + } +} diff --git a/src/Plotly.NET.CSharp/Plotly.NET.CSharp.csproj b/src/Plotly.NET.CSharp/Plotly.NET.CSharp.csproj new file mode 100644 index 000000000..132d856c4 --- /dev/null +++ b/src/Plotly.NET.CSharp/Plotly.NET.CSharp.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/src/Plotly.NET/ChartAPI/Chart.fs b/src/Plotly.NET/ChartAPI/Chart.fs index c78e3f049..61290d59d 100644 --- a/src/Plotly.NET/ChartAPI/Chart.fs +++ b/src/Plotly.NET/ChartAPI/Chart.fs @@ -2638,7 +2638,7 @@ type Chart = GenericChart.addLayout layout ch) - // Set the size of a Chart + /// Sets the size of a Chart (in pixels) [] static member withSize ( diff --git a/src/Plotly.NET/ChartAPI/Chart2D.fs b/src/Plotly.NET/ChartAPI/Chart2D.fs index 322535668..a7177638d 100644 --- a/src/Plotly.NET/ChartAPI/Chart2D.fs +++ b/src/Plotly.NET/ChartAPI/Chart2D.fs @@ -29,8 +29,6 @@ module Chart2D = else Trace2D.initHeatmap style |> GenericChart.ofTraceObject useDefaults - - /// /// Creates a Scatter plot. /// diff --git a/tests/Plotly.NET.CSharp.Tests/ExtensionMethodsTests.cs b/tests/Plotly.NET.CSharp.Tests/ExtensionMethodsTests.cs new file mode 100644 index 000000000..21340e7df --- /dev/null +++ b/tests/Plotly.NET.CSharp.Tests/ExtensionMethodsTests.cs @@ -0,0 +1,24 @@ +using System; +using Xunit; +using Plotly.NET.CSharp; + + +namespace Plotly.NET.CSharp.Tests +{ + public class ExtensionMethodsTests + { + internal GenericChart.GenericChart chart = Chart2D.Chart.Point(x: new double[] { 1, 2 }, y: new double[] { 5, 10 }); + + [Fact] + public void CanUseCSharpExtensionMethod() + { + Trace actual = + chart + .WithTraceInfo(Name: "Trace Name") + .GetTraces() + [0]; + + Assert.Equal("Trace Name", DynamicObj.DynamicObj.GetValue(actual,"name")); + } + } +} diff --git a/tests/Plotly.NET.CSharp.Tests/Plotly.NET.CSharp.Tests.csproj b/tests/Plotly.NET.CSharp.Tests/Plotly.NET.CSharp.Tests.csproj new file mode 100644 index 000000000..5806e6da5 --- /dev/null +++ b/tests/Plotly.NET.CSharp.Tests/Plotly.NET.CSharp.Tests.csproj @@ -0,0 +1,26 @@ + + + + net6.0 + + false + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + diff --git a/tests/Plotly.NET.Tests.CSharpConsole/Plotly.NET.Tests.CSharpConsole.csproj b/tests/Plotly.NET.Tests.CSharpConsole/Plotly.NET.Tests.CSharpConsole.csproj index 715eef03c..8412d1dfa 100644 --- a/tests/Plotly.NET.Tests.CSharpConsole/Plotly.NET.Tests.CSharpConsole.csproj +++ b/tests/Plotly.NET.Tests.CSharpConsole/Plotly.NET.Tests.CSharpConsole.csproj @@ -1,7 +1,7 @@ - + diff --git a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs index 0dc7514aa..9c4d5abd2 100644 --- a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs +++ b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs @@ -1,53 +1,118 @@ using System; -using Plotly.NET; -using Microsoft.FSharp.Core; // use this for less verbose and more helpful intellisense -using Plotly.NET.LayoutObjects; +using Plotly.NET.CSharp; +using static Plotly.NET.StyleParam; +using static Plotly.NET.GenericChart; -namespace Plotly.NET.Tests.CSharpConsole +namespace TestConsoleApp { class Program { static void Main(string[] args) { - double[] x = new double[] { 1, 2 }; - double[] y = new double[] { 5, 10 }; - - LinearAxis xAxis = new LinearAxis(); - xAxis.SetValue("title", "xAxis"); - xAxis.SetValue("showgrid", false); - xAxis.SetValue("showline", true); - - LinearAxis yAxis = new LinearAxis(); - yAxis.SetValue("title", "yAxis"); - yAxis.SetValue("showgrid", false); - yAxis.SetValue("showline", true); - - Layout layout = new Layout(); - layout.SetValue("xaxis", xAxis); - layout.SetValue("yaxis", yAxis); - layout.SetValue("showlegend", true); - - Trace trace = new Trace("scatter"); - trace.SetValue("x", x); - trace.SetValue("y", y); - trace.SetValue("mode", "markers"); - trace.SetValue("name", "Hello from C#"); - - GenericChart - .ofTraceObject(true, trace) - .WithLayout(layout) - .Show(); - } - static void Main2(string[] args) - { - double[] x = new double[] { 1, 2 }; - double[] y = new double[] { 5, 10 }; - GenericChart.GenericChart chart = Chart2D.Chart.Point(x: x, y: y); - chart - .WithTraceInfo("Hello from C#", ShowLegend: true) - .WithXAxisStyle(title: Title.init("xAxis")) - .WithYAxisStyle(title: Title.init("yAxis")) + Chart.Grid( + nRows: 8, + nCols: 5, + gCharts: + new GenericChart[] + { + Chart.Scatter( + x: new int [] { 1, 2 }, + y: new int [] { 3, 4 }, + mode: Mode.Markers + ), + Chart.Point( + x: new int [] { 5, 6 }, + y: new int [] { 7, 8 } + ), + Chart.Line( + x: new int [] { 9, 10 }, + y: new int [] { 11, 12 } + ), + Chart.Bar( + values: new int [] { 1,2 }, + Keys: new string [] { "first", "second"} + ), + Chart.Column( + values: new int [] { 1,2 }, + Keys: new string [] { "first", "second"} + ), + Chart.Scatter3D( + x: new int[] { 12, 13 }, + y: new int [] { 13, 14 }, + z: new int [] { 14, 15 }, + mode: Mode.Markers + ), + Chart.Invisible(), + Chart.Invisible(), + Chart.Invisible(), + Chart.Invisible(), + Chart.ScatterPolar( + theta: new int [] { 1, 2 }, + r: new int [] { 3, 4 }, + mode: Mode.Markers + ), + Chart.Invisible(), + Chart.Invisible(), + Chart.Invisible(), + Chart.Invisible(), + Chart.ScatterGeo( + longitudes: new int [] { 1, 2 }, + latitudes: new int [] { 3, 4 }, + mode: Mode.Markers + ), + Chart.Invisible(), + Chart.Invisible(), + Chart.Invisible(), + Chart.Invisible(), + Chart.ScatterTernary( + A: new int [] { 1, 2 }, + B: new int [] { 3, 4 }, + C: new int [] { 5, 6 } + ), + Chart.Invisible(), + Chart.Invisible(), + Chart.Invisible(), + Chart.Invisible(), + Chart.Carpet( + 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}, + B: new double [] {1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 1.0, 2.0, 3.0, 1.0, 2.0, 3.0}, + Y: new double [] {2.0, 3.5, 4.0, 3.0, 4.5, 5.0, 5.5, 6.5, 7.5, 8.0, 8.5, 10.0} + ), + Chart.Invisible(), + Chart.Invisible(), + Chart.Invisible(), + Chart.Invisible(), + Chart.Pie( + values: new double [] {1,2,3,4}, + Labels: new string [] {"soos", "saas", "fiif", "leel"} + ), + Chart.Invisible(), + Chart.Invisible(), + Chart.Invisible(), + Chart.Invisible(), + Chart.ScatterSmith( + real: new double [] {1,2,3,4}, + imag: new double [] {1,2,3,4}, + mode: Mode.Markers + ), + Chart.Invisible(), + Chart.Invisible(), + Chart.Invisible(), + Chart.Invisible(), + } + ) + .WithSize(1250,2000) .Show(); + + Chart.Point( + x: new int[] { 1, 2 }, + y: new int[] { 3, 4 } + ) + .WithTraceInfo("Hello from C#", ShowLegend: true) + .WithXAxisStyle(TitleText: "x axis") + .WithYAxisStyle(TitleText: "y axis") + .Show(); } } }