diff --git a/Plotly.NET.sln b/Plotly.NET.sln index f44672d13..a02a7574e 100644 --- a/Plotly.NET.sln +++ b/Plotly.NET.sln @@ -107,6 +107,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{7B09CC0A-F docs\10_1_styling_ternary_layouts.fsx = docs\10_1_styling_ternary_layouts.fsx docs\11_1_carpet_line_scatter_plots.fsx = docs\11_1_carpet_line_scatter_plots.fsx docs\11_2_contourcarpet_plots.fsx = docs\11_2_contourcarpet_plots.fsx + docs\12_1_smith_line_scatter_plots.fsx = docs\12_1_smith_line_scatter_plots.fsx docs\_template.fsx = docs\_template.fsx docs\_template.html = docs\_template.html docs\_template.ipynb = docs\_template.ipynb diff --git a/docs/01_2_multiple-charts.fsx b/docs/01_2_multiple-charts.fsx index 3033eb66b..8b94cf830 100644 --- a/docs/01_2_multiple-charts.fsx +++ b/docs/01_2_multiple-charts.fsx @@ -252,20 +252,62 @@ open Plotly.NET.LayoutObjects let multipleTraceTypesGrid = [ - Chart.Point([1,2; 2,3]) - Chart.PointTernary([1,2,3; 2,3,4]) - Chart.Heatmap([[1; 2];[3; 4]], ShowScale=false) - Chart.Point3D([1,3,2]) - Chart.PointMapbox([1,2]) |> Chart.withMapbox(Mapbox.init(Style = StyleParam.MapboxStyle.OpenStreetMap)) + Chart.Point([1,2; 2,3], Name = "2D Cartesian") + Chart.Point3D([1,3,2], Name = "3D Cartesian") + Chart.PointPolar([10,20], Name = "Polar") + Chart.PointGeo([1,2], Name = "Geo") + Chart.PointMapbox([1,2], Name = "MapBox") |> Chart.withMapbox(Mapbox.init(Style = StyleParam.MapboxStyle.OpenStreetMap)) + Chart.PointTernary([1,2,3; 2,3,4], Name = "Ternary") + [ + Chart.Carpet( + "contour", + A = [0.; 1.; 2.; 3.; 0.; 1.; 2.; 3.; 0.; 1.; 2.; 3.], + B = [4.; 4.; 4.; 4.; 5.; 5.; 5.; 5.; 6.; 6.; 6.; 6.], + X = [2.; 3.; 4.; 5.; 2.2; 3.1; 4.1; 5.1; 1.5; 2.5; 3.5; 4.5], + Y = [1.; 1.4; 1.6; 1.75; 2.; 2.5; 2.7; 2.75; 3.; 3.5; 3.7; 3.75], + AAxis = LinearAxis.initCarpet( + TickPrefix = "a = ", + Smoothing = 0., + MinorGridCount = 9, + AxisType = StyleParam.AxisType.Linear + ), + BAxis = LinearAxis.initCarpet( + TickPrefix = "b = ", + Smoothing = 0., + MinorGridCount = 9, + AxisType = StyleParam.AxisType.Linear + ), + Opacity = 0.75 + ) + Chart.ContourCarpet( + [1.; 1.96; 2.56; 3.0625; 4.; 5.0625; 1.; 7.5625; 9.; 12.25; 15.21; 14.0625], + "contour", + A = [0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3], + B = [4; 4; 4; 4; 5; 5; 5; 5; 6; 6; 6; 6], + ContourLineColor = Color.fromKeyword White, + ShowContourLabels = true, + ShowScale = false + ) + ] + |> Chart.combine + Chart.Pie([10;40;50;], Name = "Domain") + Chart.BubbleSmith( + [0.5; 1.; 2.; 3.], + [0.5; 1.; 2.; 3.], + sizes = [10;20;30;40], + MultiText=["one";"two";"three";"four";"five";"six";"seven"], + TextPosition=StyleParam.TextPosition.TopCenter, + Name = "Smith" + ) [ // you can use nested combined charts, but they have to have the same trace type (Cartesian2D in this case) let y = [2.; 1.5; 5.; 1.5; 2.; 2.5; 2.1; 2.5; 1.5; 1.;2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.] - Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All); - Chart.BoxPlot("y'",y,Name="bin2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All); + Chart.BoxPlot("y" ,y,Name="Combined 1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All); + Chart.BoxPlot("y'",y,Name="Combined 2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All); ] |> Chart.combine ] - |> Chart.Grid(2,3) + |> Chart.Grid(4,3) |> Chart.withSize(1000,1000) (*** condition: ipynb ***) diff --git a/docs/12_1_smith_line_scatter_plots.fsx b/docs/12_1_smith_line_scatter_plots.fsx new file mode 100644 index 000000000..e786018dd --- /dev/null +++ b/docs/12_1_smith_line_scatter_plots.fsx @@ -0,0 +1,118 @@ +(** +--- +title: Smith line and scatter plots +category: Smith Plots +categoryindex: 13 +index: 1 +--- +*) + +(*** hide ***) + +(*** condition: prepare ***) +#r "nuget: Newtonsoft.JSON, 13.0.1" +#r "nuget: DynamicObj, 1.0.1" +#r "../bin/Plotly.NET/netstandard2.0/Plotly.NET.dll" + +(*** condition: ipynb ***) +#if IPYNB +#r "nuget: Plotly.NET, {{fsdocs-package-version}}" +#r "nuget: Plotly.NET.Interactive, {{fsdocs-package-version}}" +#endif // IPYNB + +(** +# Smith charts + +[![Binder]({{root}}img/badge-binder.svg)](https://mybinder.org/v2/gh/plotly/Plotly.NET/gh-pages?filepath={{fsdocs-source-basename}}.ipynb)  +[![Script]({{root}}img/badge-script.svg)]({{root}}{{fsdocs-source-basename}}.fsx)  +[![Notebook]({{root}}img/badge-notebook.svg)]({{root}}{{fsdocs-source-basename}}.ipynb) + +*Summary:* This example shows how to create smith charts in F#. + +let's first create some data for the purpose of creating example charts: + +*) + +open Plotly.NET + +// real coordinates +let real = [0.5; 1.; 2.; 3.] + +// imaginary coordinates +let imaginary = [0.5; 1.; 2.; 3.] + +(** +The Smith chart, invented by Phillip H. Smith (1905�1987) and independently by Mizuhashi Tosaku, is a graphical calculator or nomogram designed for electrical and electronics engineers specializing in radio frequency (RF) engineering to assist in solving problems with transmission lines and matching circuits + +The Smith chart is a mathematical transformation of the two-dimensional Cartesian complex plane. Complex numbers with positive real parts map inside the circle. Those with negative real parts map outside the circle. If we are dealing only with impedances with non-negative resistive components, our interest is focused on the area inside the circle. + +([Wikipedia](https://en.wikipedia.org/wiki/Smith_chart)). + +Still, you can plot any kind of imaginary numbers on this plane. + +## point smith charts + +use `Chart.PointSmith` to create a chart that displays points on a smith subplot: +*) + +let pointSmith = Chart.PointSmith(real,imaginary) +(*** condition: ipynb ***) +#if IPYNB +pointSmith +#endif // IPYNB + +(***hide***) +pointSmith |> GenericChart.toChartHTML +(***include-it-raw***) + +(** +## line smith charts + +use `Chart.LineSmith` to create a plot that displays a line connecting the data on a smith subplot. + +This example also changes the styles of the line. +*) + +let lineSmith = + Chart.LineSmith( + real, + imaginary, + LineDash = StyleParam.DrawingStyle.DashDot, + LineColor = Color.fromKeyword Purple + ) + + +(*** condition: ipynb ***) +#if IPYNB +lineSmith +#endif // IPYNB + +(***hide***) +lineSmith |> GenericChart.toChartHTML +(***include-it-raw***) + +(** +## bubble smith charts + +use `Chart.BubbleSmith` to create a plot that displays datums on a smith subplot, with an additional 3rd dimension set as the marker size. + +As for all other plots above, You can for example add labels to each datum: +*) + +let bubbleSmith = + Chart.BubbleSmith( + real, + imaginary, + sizes = [10;20;30;40], + MultiText=["one";"two";"three";"four";"five";"six";"seven"], + TextPosition=StyleParam.TextPosition.TopCenter + ) + +(*** condition: ipynb ***) +#if IPYNB +bubbleSmith +#endif // IPYNB + +(***hide***) +bubbleSmith |> GenericChart.toChartHTML +(***include-it-raw***) diff --git a/src/Plotly.NET/ChartAPI/Chart.fs b/src/Plotly.NET/ChartAPI/Chart.fs index 8e9122e82..b6caa9902 100644 --- a/src/Plotly.NET/ChartAPI/Chart.fs +++ b/src/Plotly.NET/ChartAPI/Chart.fs @@ -1723,6 +1723,180 @@ type Chart = (fun (ch: GenericChart) -> ch |> Chart.setRadialAxis (radialAxis, id, true)) + /// + /// Sets the given Smith object with the given id on the input chart's layout. + /// + /// The Smith object to set on the chart's layout + /// The target smith id with which the Smith object should be set. + /// Wether or not to combine the objects if there is already an Smith set (default is false) + [] + static member setSmith + ( + smith: Smith, + id: StyleParam.SubPlotId, + [] ?Combine: bool + ) = + + let combine = defaultArg Combine false + + (fun (ch: GenericChart) -> + if combine then + ch |> GenericChart.mapLayout (Layout.updateSmithById (id, smith)) + else + ch |> GenericChart.mapLayout (Layout.setSmith (id, smith))) + + /// + /// Sets the Smith for the chart's layout + /// + /// If there is already a Smith set, the objects are combined. + /// + /// The new Smith for the chart's layout + /// The target smith id on which the smith object should be set. Default is 1. + [] + static member withSmith(smith: Smith, [] ?Id: int) = + let id = + Id |> Option.defaultValue 1 |> StyleParam.SubPlotId.Smith + + (fun (ch: GenericChart) -> ch |> Chart.setSmith (smith, id, true)) + + /// + /// Sets the given Smith styles on the target Smith object on the input chart's layout. + /// + /// If there is already a Smith set, the styles are applied to it. If there is no Smith present, a new Smith object with the given styles will be set. + /// + + [] + static member withSmithStyle + ( + [] ?BGColor: Color, + [] ?Domain: Domain, + [] ?ImaginaryAxis: ImaginaryAxis, + [] ?RealAxis: RealAxis, + [] ?Id: int + ) = + (fun (ch: GenericChart) -> + let smith = + Smith.init (?BGColor = BGColor, ?Domain = Domain, ?ImaginaryAxis = ImaginaryAxis, ?RealAxis = RealAxis) + + ch |> Chart.withSmith (smith, ?Id = Id)) + + /// + /// Sets the imaginary Axis on the polar object with the given id on the input chart's layout. + /// + /// The ImaginaryAxis to set on the target polar object on the chart's layout + /// The target polar id with which the ImaginaryAxis should be set.(default is 1) + /// Wether or not to combine the objects if there is already an axis set (default is false) + [] + static member setImaginaryAxis + ( + imaginaryAxis: ImaginaryAxis, + id: StyleParam.SubPlotId, + [] ?Combine: bool + ) = + + fun (ch: GenericChart) -> + + let combine = defaultArg Combine false + + match id with + | StyleParam.SubPlotId.Smith _ -> + + ch + |> GenericChart.mapLayout + (fun layout -> + let smith = layout |> Layout.getSmithById id + + if combine then + let currentAxis = smith |> Smith.getImaginaryAxis + + let updatedAxis = + (DynObj.combine currentAxis imaginaryAxis) :?> ImaginaryAxis + + let updatedSmith = + smith |> Smith.setImaginaryAxis updatedAxis + + layout |> Layout.updateSmithById (id, updatedSmith) + + else + let updatedSmith = + layout |> Layout.getSmithById id |> Smith.setImaginaryAxis imaginaryAxis + + layout |> Layout.updateSmithById (id, updatedSmith)) + + | _ -> failwith $"{StyleParam.SubPlotId.toString id} is an invalid subplot id for setting an imaginary Axis" + + /// + /// Sets the ImaginaryAxis on the smith object with the given id on the input chart's layout. + /// + /// If there is already a ImaginaryAxis set on the smith object, the ImaginaryAxis objects are combined. + /// + /// The new ImaginaryAxis for the chart layout's smith object + /// The target smith id on which the ImaginaryAxis should be set. Default is 1. + [] + static member withImaginaryAxis(imaginaryAxis: ImaginaryAxis, [] ?Id: int) = + let id = + Id |> Option.defaultValue 1 |> StyleParam.SubPlotId.Smith + + (fun (ch: GenericChart) -> ch |> Chart.setImaginaryAxis (imaginaryAxis, id, true)) + + /// + /// Sets the RealAxis on the smith object with the given id on the input chart's layout. + /// + /// The RealAxis to set on the target smith object on the chart's layout + /// The target smith id with which the RealAxis should be set.(default is 1) + /// Wether or not to combine the objects if there is already an axis set (default is false) + [] + static member setRealAxis + ( + realAxis: RealAxis, + id: StyleParam.SubPlotId, + [] ?Combine: bool + ) = + + fun (ch: GenericChart) -> + + let combine = defaultArg Combine false + + match id with + | StyleParam.SubPlotId.Smith _ -> + + ch + |> GenericChart.mapLayout + (fun layout -> + let smith = layout |> Layout.getSmithById id + + if combine then + let currentAxis = smith |> Smith.getRealAxis + + let updatedAxis = + (DynObj.combine currentAxis realAxis) :?> RealAxis + + let updatedSmith = smith |> Smith.setRealAxis updatedAxis + + layout |> Layout.updateSmithById (id, updatedSmith) + + else + let updatedSmith = + layout |> Layout.getSmithById id |> Smith.setRealAxis realAxis + + layout |> Layout.updateSmithById (id, updatedSmith)) + + | _ -> failwith $"{StyleParam.SubPlotId.toString id} is an invalid subplot id for setting an real axis" + + /// + /// Sets the RealAxis on the smith object with the given id on the input chart's layout. + /// + /// If there is already a RealAxis set on the smith object, the RealAxis objects are combined. + /// + /// The new RealAxis for the chart layout's smith object + /// The target smith id on which the RealAxis should be set. Default is 1. + [] + static member withRealAxis(realAxis: RealAxis, [] ?Id: int) = + let id = + Id |> Option.defaultValue 1 |> StyleParam.SubPlotId.Smith + + (fun (ch: GenericChart) -> ch |> Chart.setRealAxis (realAxis, id, true)) + /// /// Sets the given Geo object with the given id on the input chart's layout. /// @@ -2070,15 +2244,15 @@ type Chart = ch |> GenericChart.mapLayout (fun layout -> - let polar = layout |> Layout.getTernaryById id + let ternary = layout |> Layout.getTernaryById id if combine then - let currentAxis = polar |> Ternary.getAAxis + let currentAxis = ternary |> Ternary.getAAxis let updatedAxis = (DynObj.combine currentAxis aAxis) :?> LinearAxis - let updatedTernary = polar |> Ternary.setAAxis updatedAxis + let updatedTernary = ternary |> Ternary.setAAxis updatedAxis layout |> Layout.updateTernaryById (id, updatedTernary) @@ -2128,15 +2302,15 @@ type Chart = ch |> GenericChart.mapLayout (fun layout -> - let polar = layout |> Layout.getTernaryById id + let ternary = layout |> Layout.getTernaryById id if combine then - let currentAxis = polar |> Ternary.getBAxis + let currentAxis = ternary |> Ternary.getBAxis let updatedAxis = (DynObj.combine currentAxis bAxis) :?> LinearAxis - let updatedTernary = polar |> Ternary.setBAxis updatedAxis + let updatedTernary = ternary |> Ternary.setBAxis updatedAxis layout |> Layout.updateTernaryById (id, updatedTernary) @@ -2186,15 +2360,15 @@ type Chart = ch |> GenericChart.mapLayout (fun layout -> - let polar = layout |> Layout.getTernaryById id + let ternary = layout |> Layout.getTernaryById id if combine then - let currentAxis = polar |> Ternary.getCAxis + let currentAxis = ternary |> Ternary.getCAxis let updatedAxis = (DynObj.combine currentAxis cAxis) :?> LinearAxis - let updatedTernary = polar |> Ternary.setCAxis updatedAxis + let updatedTernary = ternary |> Ternary.setCAxis updatedAxis layout |> Layout.updateTernaryById (id, updatedTernary) @@ -2737,6 +2911,23 @@ type Chart = |> GenericChart.mapTrace (fun t -> t :?> TracePolar |> TracePolarStyle.SetPolar polarAnchor :> Trace) |> Chart.withPolar (polar, (i + 1)) + + | TraceID.Smith -> + + let smith = + layout.TryGetTypedValue "smith" + |> Option.defaultValue (Smith.init ()) + |> Smith.style ( + Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1) + ) + + let polarAnchor = StyleParam.SubPlotId.Smith(i + 1) + + gChart + |> GenericChart.mapTrace + (fun t -> t :?> TraceSmith |> TraceSmithStyle.SetSmith polarAnchor :> Trace) + |> Chart.withSmith (smith, (i + 1)) + | TraceID.Geo -> let geo = layout.TryGetTypedValue "geo" diff --git a/src/Plotly.NET/ChartAPI/ChartSmith.fs b/src/Plotly.NET/ChartAPI/ChartSmith.fs new file mode 100644 index 000000000..51b16d3e2 --- /dev/null +++ b/src/Plotly.NET/ChartAPI/ChartSmith.fs @@ -0,0 +1,706 @@ +namespace Plotly.NET + +open Plotly.NET.LayoutObjects +open Plotly.NET.TraceObjects + +open DynamicObj +open System +open System.IO + +open GenericChart +open StyleParam +open System.Runtime.InteropServices +open System.Runtime.CompilerServices + +[] +module ChartSmith = + + [] + type 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` + [] + static member ScatterSmith + ( + real: seq<#IConvertible>, + imag: seq<#IConvertible>, + mode: StyleParam.Mode, + [] ?Name: string, + [] ?ShowLegend: bool, + [] ?Opacity: float, + [] ?MultiOpacity: seq, + [] ?Text: #IConvertible, + [] ?MultiText: seq<#IConvertible>, + [] ?TextPosition: StyleParam.TextPosition, + [] ?MultiTextPosition: seq, + [] ?MarkerColor: Color, + [] ?MarkerColorScale: StyleParam.Colorscale, + [] ?MarkerOutline: Line, + [] ?MarkerSymbol: StyleParam.MarkerSymbol, + [] ?MultiMarkerSymbol: seq, + [] ?Marker: Marker, + [] ?LineColor: Color, + [] ?LineColorScale: StyleParam.Colorscale, + [] ?LineWidth: float, + [] ?LineDash: StyleParam.DrawingStyle, + [] ?Line: Line, + [] ?Fill: StyleParam.Fill, + [] ?FillColor: Color, + [] ?UseDefaults: bool + ) = + let useDefaults = defaultArg UseDefaults true + + let marker = + Marker + |> Option.defaultValue (TraceObjects.Marker.init ()) + |> TraceObjects.Marker.style ( + ?Color = MarkerColor, + ?Outline = MarkerOutline, + ?Symbol = MarkerSymbol, + ?MultiSymbol = MultiMarkerSymbol, + ?Colorscale = MarkerColorScale, + ?MultiOpacity = MultiOpacity + ) + + let line = + Line + |> Option.defaultValue (Plotly.NET.Line.init ()) + |> Plotly.NET.Line.style ( + ?Color = LineColor, + ?Dash = LineDash, + ?Colorscale = LineColorScale, + ?Width = LineWidth + ) + + TraceSmith.initScatterSmith ( + TraceSmithStyle.ScatterSmith( + Imag = imag, + Real = real, + Mode = mode, + Marker = marker, + Line = line, + ?Name = Name, + ?ShowLegend = ShowLegend, + ?Opacity = Opacity, + ?Text = Text, + ?MultiText = MultiText, + ?TextPosition = TextPosition, + ?MultiTextPosition = MultiTextPosition, + ?Fill = Fill, + ?FillColor = FillColor + ) + ) + |> GenericChart.ofTraceObject useDefaults + + /// + /// 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 and imaginary components 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` + [] + static member ScatterSmith + ( + realImag: seq<#IConvertible * #IConvertible>, + mode: StyleParam.Mode, + [] ?Name: string, + [] ?ShowLegend: bool, + [] ?Opacity: float, + [] ?MultiOpacity: seq, + [] ?Text: #IConvertible, + [] ?MultiText: seq<#IConvertible>, + [] ?TextPosition: StyleParam.TextPosition, + [] ?MultiTextPosition: seq, + [] ?MarkerColor: Color, + [] ?MarkerColorScale: StyleParam.Colorscale, + [] ?MarkerOutline: Line, + [] ?MarkerSymbol: StyleParam.MarkerSymbol, + [] ?MultiMarkerSymbol: seq, + [] ?Marker: Marker, + [] ?LineColor: Color, + [] ?LineColorScale: StyleParam.Colorscale, + [] ?LineWidth: float, + [] ?LineDash: StyleParam.DrawingStyle, + [] ?Line: Line, + [] ?Fill: StyleParam.Fill, + [] ?FillColor: Color, + [] ?UseDefaults: bool + ) = + + let real, imag = Seq.unzip realImag + + Chart.ScatterSmith( + real, + imag, + mode, + ?Name = Name, + ?ShowLegend = ShowLegend, + ?Opacity = Opacity, + ?MultiOpacity = MultiOpacity, + ?Text = Text, + ?MultiText = MultiText, + ?TextPosition = TextPosition, + ?MultiTextPosition = MultiTextPosition, + ?MarkerColor = MarkerColor, + ?MarkerColorScale = MarkerColorScale, + ?MarkerOutline = MarkerOutline, + ?MarkerSymbol = MarkerSymbol, + ?MultiMarkerSymbol = MultiMarkerSymbol, + ?Marker = Marker, + ?LineColor = LineColor, + ?LineColorScale = LineColorScale, + ?LineWidth = LineWidth, + ?LineDash = LineDash, + ?Line = Line, + ?Fill = Fill, + ?FillColor = FillColor, + ?UseDefaults = UseDefaults + ) + + /// + /// Creates a Point plot on a smith coordinate system. + /// + /// In general, ScatterPoint charts plot complex numbers on a transformed two-dimensional Cartesian complex plane as points. Complex numbers with positive real parts map inside the circle. Those with negative real parts map outside the circle. + /// + /// 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. + /// 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) + /// If set to false, ignore the global default settings set in `Defaults` + [] + static member PointSmith + ( + real: seq<#IConvertible>, + imag: seq<#IConvertible>, + [] ?Name: string, + [] ?ShowLegend: bool, + [] ?Opacity: float, + [] ?MultiOpacity: seq, + [] ?Text: #IConvertible, + [] ?MultiText: seq<#IConvertible>, + [] ?TextPosition: StyleParam.TextPosition, + [] ?MultiTextPosition: seq, + [] ?MarkerColor: Color, + [] ?MarkerColorScale: StyleParam.Colorscale, + [] ?MarkerOutline: Line, + [] ?MarkerSymbol: StyleParam.MarkerSymbol, + [] ?MultiMarkerSymbol: seq, + [] ?Marker: Marker, + [] ?UseDefaults: bool + ) = + // if text position or font is set, then show labels (not only when hovering) + let changeMode = + StyleParam.ModeUtils.showText (TextPosition.IsSome || MultiTextPosition.IsSome) + + Chart.ScatterSmith( + real, + imag, + mode = changeMode StyleParam.Mode.Markers, + ?Name = Name, + ?ShowLegend = ShowLegend, + ?Opacity = Opacity, + ?MultiOpacity = MultiOpacity, + ?Text = Text, + ?MultiText = MultiText, + ?TextPosition = TextPosition, + ?MultiTextPosition = MultiTextPosition, + ?MarkerColor = MarkerColor, + ?MarkerColorScale = MarkerColorScale, + ?MarkerOutline = MarkerOutline, + ?MarkerSymbol = MarkerSymbol, + ?MultiMarkerSymbol = MultiMarkerSymbol, + ?Marker = Marker, + ?UseDefaults = UseDefaults + ) + + /// + /// Creates a Point plot on a smith coordinate system. + /// + /// In general, ScatterPoint charts plot complex numbers on a transformed two-dimensional Cartesian complex plane as points. Complex numbers with positive real parts map inside the circle. Those with negative real parts map outside the circle. + /// + /// Sets the real and imaginary components of the data, in units of normalized impedance such that real=1, imag=0 is the center of the chart. + /// 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) + /// If set to false, ignore the global default settings set in `Defaults` + [] + static member PointSmith + ( + realImag: seq<#IConvertible * #IConvertible>, + [] ?Name: string, + [] ?ShowLegend: bool, + [] ?Opacity: float, + [] ?MultiOpacity: seq, + [] ?Text: #IConvertible, + [] ?MultiText: seq<#IConvertible>, + [] ?TextPosition: StyleParam.TextPosition, + [] ?MultiTextPosition: seq, + [] ?MarkerColor: Color, + [] ?MarkerColorScale: StyleParam.Colorscale, + [] ?MarkerOutline: Line, + [] ?MarkerSymbol: StyleParam.MarkerSymbol, + [] ?MultiMarkerSymbol: seq, + [] ?Marker: Marker, + [] ?UseDefaults: bool + ) = + let real, imag = Seq.unzip realImag + + Chart.PointSmith( + real, + imag, + ?Name = Name, + ?ShowLegend = ShowLegend, + ?Opacity = Opacity, + ?MultiOpacity = MultiOpacity, + ?Text = Text, + ?MultiText = MultiText, + ?TextPosition = TextPosition, + ?MultiTextPosition = MultiTextPosition, + ?MarkerColor = MarkerColor, + ?MarkerColorScale = MarkerColorScale, + ?MarkerOutline = MarkerOutline, + ?MarkerSymbol = MarkerSymbol, + ?MultiMarkerSymbol = MultiMarkerSymbol, + ?Marker = Marker, + ?UseDefaults = UseDefaults + ) + + /// + /// Creates a Line plot on a smith coordinate system. + /// + /// In general, LineSmith charts plot complex numbers on a transformed two-dimensional Cartesian complex plane as datums connected by a line. Complex numbers with positive real parts map inside the circle. Those with negative real parts map outside the circle. + /// + /// 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. + /// 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` + [] + static member LineSmith + ( + real: seq<#IConvertible>, + imag: seq<#IConvertible>, + [] ?ShowMarkers: bool, + [] ?Name: string, + [] ?ShowLegend: bool, + [] ?Opacity: float, + [] ?MultiOpacity: seq, + [] ?Text: #IConvertible, + [] ?MultiText: seq<#IConvertible>, + [] ?TextPosition: StyleParam.TextPosition, + [] ?MultiTextPosition: seq, + [] ?MarkerColor: Color, + [] ?MarkerColorScale: StyleParam.Colorscale, + [] ?MarkerOutline: Line, + [] ?MarkerSymbol: StyleParam.MarkerSymbol, + [] ?MultiMarkerSymbol: seq, + [] ?Marker: Marker, + [] ?LineColor: Color, + [] ?LineColorScale: StyleParam.Colorscale, + [] ?LineWidth: float, + [] ?LineDash: StyleParam.DrawingStyle, + [] ?Line: Line, + [] ?Fill: StyleParam.Fill, + [] ?FillColor: Color, + [] ?UseDefaults: bool + ) = + // if text position or font is set than show labels (not only when hovering) + let changeMode = + let isShowMarker = + match ShowMarkers with + | Some isShow -> isShow + | Option.None -> false + + StyleParam.ModeUtils.showText (TextPosition.IsSome || MultiTextPosition.IsSome) + >> StyleParam.ModeUtils.showMarker (isShowMarker) + + Chart.ScatterSmith( + real, + imag, + mode = changeMode StyleParam.Mode.Lines, + ?Name = Name, + ?ShowLegend = ShowLegend, + ?Opacity = Opacity, + ?MultiOpacity = MultiOpacity, + ?Text = Text, + ?MultiText = MultiText, + ?TextPosition = TextPosition, + ?MultiTextPosition = MultiTextPosition, + ?MarkerColor = MarkerColor, + ?MarkerColorScale = MarkerColorScale, + ?MarkerOutline = MarkerOutline, + ?MarkerSymbol = MarkerSymbol, + ?MultiMarkerSymbol = MultiMarkerSymbol, + ?Marker = Marker, + ?LineColor = LineColor, + ?LineColorScale = LineColorScale, + ?LineWidth = LineWidth, + ?LineDash = LineDash, + ?Line = Line, + ?Fill = Fill, + ?FillColor = FillColor, + ?UseDefaults = UseDefaults + ) + + /// + /// Creates a Line plot on a smith coordinate system. + /// + /// In general, LineSmith charts plot complex numbers on a transformed two-dimensional Cartesian complex plane as datums connected by a line. Complex numbers with positive real parts map inside the circle. Those with negative real parts map outside the circle. + /// + /// Sets the real and imaginary components of the data, in units of normalized impedance such that real=1, imag=0 is the center of the chart. + /// 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` + [] + static member LineSmith + ( + realImag: seq<#IConvertible * #IConvertible>, + [] ?ShowMarkers: bool, + [] ?Name: string, + [] ?ShowLegend: bool, + [] ?Opacity: float, + [] ?MultiOpacity: seq, + [] ?Text: #IConvertible, + [] ?MultiText: seq<#IConvertible>, + [] ?TextPosition: StyleParam.TextPosition, + [] ?MultiTextPosition: seq, + [] ?MarkerColor: Color, + [] ?MarkerColorScale: StyleParam.Colorscale, + [] ?MarkerOutline: Line, + [] ?MarkerSymbol: StyleParam.MarkerSymbol, + [] ?MultiMarkerSymbol: seq, + [] ?Marker: Marker, + [] ?LineColor: Color, + [] ?LineColorScale: StyleParam.Colorscale, + [] ?LineWidth: float, + [] ?LineDash: StyleParam.DrawingStyle, + [] ?Line: Line, + [] ?Fill: StyleParam.Fill, + [] ?FillColor: Color, + [] ?UseDefaults: bool + ) = + let real, imag = Seq.unzip realImag + + Chart.LineSmith( + real, + imag, + ?ShowMarkers = ShowMarkers, + ?Name = Name, + ?ShowLegend = ShowLegend, + ?Opacity = Opacity, + ?MultiOpacity = MultiOpacity, + ?Text = Text, + ?MultiText = MultiText, + ?TextPosition = TextPosition, + ?MultiTextPosition = MultiTextPosition, + ?MarkerColor = MarkerColor, + ?MarkerColorScale = MarkerColorScale, + ?MarkerOutline = MarkerOutline, + ?MarkerSymbol = MarkerSymbol, + ?MultiMarkerSymbol = MultiMarkerSymbol, + ?Marker = Marker, + ?LineColor = LineColor, + ?LineColorScale = LineColorScale, + ?LineWidth = LineWidth, + ?LineDash = LineDash, + ?Line = Line, + ?Fill = Fill, + ?FillColor = FillColor, + ?UseDefaults = UseDefaults + ) + + /// + /// Creates a Bubble plot on a smith coordinate system. A bubble chart is a variation of the Point chart, where the data points get an additional scale by being rendered as bubbles of different sizes. + /// + /// In general, BubbleSmith charts plot complex numbers on a transformed two-dimensional Cartesian complex plane as points of varying sizes. Complex numbers with positive real parts map inside the circle. Those with negative real parts map outside the circle. + /// + /// 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. + /// Sets the size of the points + /// Sets the trace name. The trace name appear as the legend item and on hover + /// Determines whether or not an item corresponding to this trace is shown in the legend. + /// Sets the opactity of the trace + /// Sets the opactity of individual datum markers + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the position of text associated with each datum + /// Sets the position of text associated with individual datum + /// Sets the color of the marker + /// Sets the colorscale of the marker + /// Sets the outline of the marker + /// Sets the marker symbol for each datum + /// Sets the marker symbol for each individual datum + /// Sets the marker (use this for more finegrained control than the other marker-associated arguments) + /// 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` + [] + static member BubbleSmith + ( + real: seq<#IConvertible>, + imag: seq<#IConvertible>, + sizes: seq, + [] ?Name: string, + [] ?ShowLegend: bool, + [] ?Opacity: float, + [] ?MultiOpacity: seq, + [] ?Text: #IConvertible, + [] ?MultiText: seq<#IConvertible>, + [] ?TextPosition: StyleParam.TextPosition, + [] ?MultiTextPosition: seq, + [] ?MarkerColor: Color, + [] ?MarkerColorScale: StyleParam.Colorscale, + [] ?MarkerOutline: Line, + [] ?MarkerSymbol: StyleParam.MarkerSymbol, + [] ?MultiMarkerSymbol: seq, + [] ?Marker: Marker, + [] ?LineColor: Color, + [] ?LineColorScale: StyleParam.Colorscale, + [] ?LineWidth: float, + [] ?LineDash: StyleParam.DrawingStyle, + [] ?Line: Line, + [] ?UseDefaults: bool + ) = + + // if text position or font is set than show labels (not only when hovering) + let changeMode = + StyleParam.ModeUtils.showText (TextPosition.IsSome || MultiTextPosition.IsSome) + + let marker = + Marker + |> Option.defaultValue (TraceObjects.Marker.init ()) + |> TraceObjects.Marker.style ( + ?Color = MarkerColor, + ?Outline = MarkerOutline, + ?Symbol = MarkerSymbol, + ?MultiSymbol = MultiMarkerSymbol, + ?Colorscale = MarkerColorScale, + ?MultiOpacity = MultiOpacity, + MultiSize = sizes + ) + + let line = + Line + |> Option.defaultValue (Plotly.NET.Line.init ()) + |> Plotly.NET.Line.style ( + ?Color = LineColor, + ?Dash = LineDash, + ?Colorscale = LineColorScale, + ?Width = LineWidth + ) + + Chart.ScatterSmith( + real, + imag, + mode = changeMode StyleParam.Mode.Markers, + Marker = marker, + Line = line, + ?Name = Name, + ?ShowLegend = ShowLegend, + ?Opacity = Opacity, + ?Text = Text, + ?MultiText = MultiText, + ?TextPosition = TextPosition, + ?MultiTextPosition = MultiTextPosition, + ?UseDefaults = UseDefaults + ) + + /// + /// Creates a Bubble plot on a smith coordinate system. A bubble chart is a variation of the Point chart, where the data points get an additional scale by being rendered as bubbles of different sizes. + /// + /// In general, BubbleSmith charts plot complex numbers on a transformed two-dimensional Cartesian complex plane as points of varying sizes. Complex numbers with positive real parts map inside the circle. Those with negative real parts map outside the circle. + /// + /// Sets the real components of the data, in units of normalized impedance such that real=1, imag=0 is the center of the chart, as well as the size of the points. + /// Sets the trace name. The trace name appear as the legend item and on hover + /// Determines whether or not an item corresponding to this trace is shown in the legend. + /// Sets the opactity of the trace + /// Sets the opactity of individual datum markers + /// Sets a text associated with each datum + /// Sets individual text for each datum + /// Sets the position of text associated with each datum + /// Sets the position of text associated with individual datum + /// Sets the color of the marker + /// Sets the colorscale of the marker + /// Sets the outline of the marker + /// Sets the marker symbol for each datum + /// Sets the marker symbol for each individual datum + /// Sets the marker (use this for more finegrained control than the other marker-associated arguments) + /// 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` + [] + static member BubbleSmith + ( + realImagSizes: seq<#IConvertible * #IConvertible * int>, + [] ?Name: string, + [] ?ShowLegend: bool, + [] ?Opacity: float, + [] ?MultiOpacity: seq, + [] ?Text: #IConvertible, + [] ?MultiText: seq<#IConvertible>, + [] ?TextPosition: StyleParam.TextPosition, + [] ?MultiTextPosition: seq, + [] ?MarkerColor: Color, + [] ?MarkerColorScale: StyleParam.Colorscale, + [] ?MarkerOutline: Line, + [] ?MarkerSymbol: StyleParam.MarkerSymbol, + [] ?MultiMarkerSymbol: seq, + [] ?Marker: Marker, + [] ?LineColor: Color, + [] ?LineColorScale: StyleParam.Colorscale, + [] ?LineWidth: float, + [] ?LineDash: StyleParam.DrawingStyle, + [] ?Line: Line, + [] ?UseDefaults: bool + ) = + + let real, imag, sizes = Seq.unzip3 realImagSizes + + Chart.BubbleSmith( + real, + imag, + sizes, + ?Name = Name, + ?ShowLegend = ShowLegend, + ?Opacity = Opacity, + ?MultiOpacity = MultiOpacity, + ?Text = Text, + ?MultiText = MultiText, + ?TextPosition = TextPosition, + ?MultiTextPosition = MultiTextPosition, + ?MarkerColor = MarkerColor, + ?MarkerColorScale = MarkerColorScale, + ?MarkerOutline = MarkerOutline, + ?MarkerSymbol = MarkerSymbol, + ?MultiMarkerSymbol = MultiMarkerSymbol, + ?Marker = Marker, + ?LineColor = LineColor, + ?LineColorScale = LineColorScale, + ?LineWidth = LineWidth, + ?LineDash = LineDash, + ?Line = Line, + ?UseDefaults = UseDefaults + ) diff --git a/src/Plotly.NET/CommonAbstractions/StyleParams.fs b/src/Plotly.NET/CommonAbstractions/StyleParams.fs index fd09d6121..b3f4eab5d 100644 --- a/src/Plotly.NET/CommonAbstractions/StyleParams.fs +++ b/src/Plotly.NET/CommonAbstractions/StyleParams.fs @@ -172,6 +172,7 @@ module StyleParam = | Ternary of int | Scene of int | Carpet of string + | Smith of int static member toString = function @@ -216,6 +217,11 @@ module StyleParam = "scene" else sprintf "scene%i" id + | Smith id -> + if id < 2 then + "smith" + else + sprintf "smith%i" id | Carpet id -> id static member convert = SubPlotId.toString >> box diff --git a/src/Plotly.NET/Layout/Layout.fs b/src/Plotly.NET/Layout/Layout.fs index 234e4166a..e8a625d48 100644 --- a/src/Plotly.NET/Layout/Layout.fs +++ b/src/Plotly.NET/Layout/Layout.fs @@ -676,6 +676,51 @@ type Layout() = layout) + /// + /// Returns Some(smith) if there is a smith object set on the layout with the given id, and None otherwise. + /// + /// the target Smith id + static member tryGetSmithById(id: StyleParam.SubPlotId) = + (fun (layout: Layout) -> layout.TryGetTypedValue(StyleParam.SubPlotId.toString id)) + + /// + /// Combines the given Smith object with the one already present on the layout. + /// + /// The target smith id + /// The updated smith object. + static member updateSmithById(id: StyleParam.SubPlotId, smith: Smith) = + (fun (layout: Layout) -> + + let smith' = + match layout |> Layout.tryGetPolarById (id) with + | Some a -> (DynObj.combine a smith) :?> Smith + | None -> smith + + smith' |> DynObj.setValue layout (StyleParam.SubPlotId.toString id) + + layout) + + /// + /// Returns the Smith object of the layout with the given id. + /// + /// If there is no smith set, returns an empty Smith object. + /// + /// The target smith id + static member getSmithById(id: StyleParam.SubPlotId) = + (fun (layout: Layout) -> layout |> Layout.tryGetSmithById id |> Option.defaultValue (Smith.init ())) + + /// + /// Sets a smith object on the layout as a dynamic property with the given smith id. + /// + /// The scene id of the new geo + /// The smith to add to the layout. + static member setSmith(id: StyleParam.SubPlotId, smith: Smith) = + (fun (layout: Layout) -> + + smith |> DynObj.setValue layout (StyleParam.SubPlotId.toString id) + + layout) + /// /// Returns Some(ColorAxis) if there is a ColorAxis object set on the layout with the given id, and None otherwise. /// diff --git a/src/Plotly.NET/Layout/ObjectAbstractions/Smith/ImaginaryAxis.fs b/src/Plotly.NET/Layout/ObjectAbstractions/Smith/ImaginaryAxis.fs new file mode 100644 index 000000000..470957f3a --- /dev/null +++ b/src/Plotly.NET/Layout/ObjectAbstractions/Smith/ImaginaryAxis.fs @@ -0,0 +1,165 @@ +namespace Plotly.NET.LayoutObjects + +open Plotly.NET +open DynamicObj +open System +open System.Runtime.InteropServices + + +/// Angular axes can be used as a scale for the angular coordinates in polar plots. +type ImaginaryAxis() = + inherit DynamicObj() + + /// + /// Initialize an ImaginaryAxis object that can be used as a imaginary scale for smith coordinates. + /// + /// 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. + /// Sets the color of the grid lines. + /// Sets the width (in px) of the grid lines. + /// Sets the hover text formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: "%h" for half of the year as a decimal number as well as "%{n}f" for fractional seconds with n digits. For example, "2016-10-13 09:15:23.456" with tickformat "%H~%M~%S.%2f" would display "09~15~23.46" + /// Sets the layer on which this axis is displayed. If "above traces", this axis is displayed above all the subplot's traces If "below traces", this axis is displayed below all the subplot's traces, but above the grid lines. Useful when used together with scatter-like traces with `cliponaxis` set to "false" to show markers and/or text nodes above this axis. + /// Sets the axis line color. + /// Sets the width (in px) of the axis line. + /// Determines whether or not grid lines are drawn. If "true", the grid lines are drawn at every tick mark. + /// Determines whether or not a line bounding this axis is drawn. + /// Determines whether or not the tick labels are drawn. + /// If "all", all tick labels are displayed with a prefix. If "first", only the first tick is displayed with a prefix. If "last", only the last tick is displayed with a suffix. If "none", tick prefixes are hidden. + /// Same as `showtickprefix` but for tick suffixes. + /// Sets the tick color. + /// Sets the tick font. + /// Sets the tick label formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: "%h" for half of the year as a decimal number as well as "%{n}f" for fractional seconds with n digits. For example, "2016-10-13 09:15:23.456" with tickformat "%H~%M~%S.%2f" would display "09~15~23.46" + /// Sets the tick length (in px). + /// Sets a tick label prefix. + /// Determines whether ticks are drawn or not. If "", this axis' ticks are not drawn. If "outside" ("inside"), this axis' are drawn outside (inside) the axis lines. + /// Sets a tick label suffix. + /// Sets the values at which ticks on this axis appear. Defaults to `realaxis.tickvals` plus the same as negatives and zero. + /// Sets the tick width (in px). + /// A single toggle to hide the axis while preserving interaction like dragging. Default is true when a cheater plot is present on the axis, otherwise false + static member init + ( + [] ?Color: Color, + [] ?GridColor: Color, + [] ?GridWidth: int, + [] ?HoverFormat: string, + [] ?Layer: StyleParam.Layer, + [] ?LineColor: Color, + [] ?LineWidth: int, + [] ?ShowGrid: bool, + [] ?ShowLine: bool, + [] ?ShowTickLabels: bool, + [] ?ShowTickSuffix: StyleParam.ShowTickOption, + [] ?ShowTickPrefix: StyleParam.ShowTickOption, + [] ?TickColor: Color, + [] ?TickFont: Font, + [] ?TickFormat: string, + [] ?TickLen: int, + [] ?TickPrefix: string, + [] ?Ticks: StyleParam.TickLabelPosition, + [] ?TickSuffix: string, + [] ?TickVals: seq<#IConvertible>, + [] ?TickWidth: int, + [] ?Visible: bool + ) = + ImaginaryAxis() + |> ImaginaryAxis.style ( + ?Color = Color, + ?GridColor = GridColor, + ?GridWidth = GridWidth, + ?HoverFormat = HoverFormat, + ?Layer = Layer, + ?LineColor = LineColor, + ?LineWidth = LineWidth, + ?ShowGrid = ShowGrid, + ?ShowLine = ShowLine, + ?ShowTickLabels = ShowTickLabels, + ?ShowTickSuffix = ShowTickSuffix, + ?ShowTickPrefix = ShowTickPrefix, + ?TickColor = TickColor, + ?TickFont = TickFont, + ?TickFormat = TickFormat, + ?TickLen = TickLen, + ?TickPrefix = TickPrefix, + ?Ticks = Ticks, + ?TickSuffix = TickSuffix, + ?TickVals = TickVals, + ?TickWidth = TickWidth, + ?Visible = Visible + + ) + + /// + /// Creates a function that applies the given style parameters to a ImaginaryAxis object + /// + /// 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. + /// Sets the color of the grid lines. + /// Sets the width (in px) of the grid lines. + /// Sets the hover text formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: "%h" for half of the year as a decimal number as well as "%{n}f" for fractional seconds with n digits. For example, "2016-10-13 09:15:23.456" with tickformat "%H~%M~%S.%2f" would display "09~15~23.46" + /// Sets the layer on which this axis is displayed. If "above traces", this axis is displayed above all the subplot's traces If "below traces", this axis is displayed below all the subplot's traces, but above the grid lines. Useful when used together with scatter-like traces with `cliponaxis` set to "false" to show markers and/or text nodes above this axis. + /// Sets the axis line color. + /// Sets the width (in px) of the axis line. + /// Determines whether or not grid lines are drawn. If "true", the grid lines are drawn at every tick mark. + /// Determines whether or not a line bounding this axis is drawn. + /// Determines whether or not the tick labels are drawn. + /// If "all", all tick labels are displayed with a prefix. If "first", only the first tick is displayed with a prefix. If "last", only the last tick is displayed with a suffix. If "none", tick prefixes are hidden. + /// Same as `showtickprefix` but for tick suffixes. + /// Sets the tick color. + /// Sets the tick font. + /// Sets the tick label formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: "%h" for half of the year as a decimal number as well as "%{n}f" for fractional seconds with n digits. For example, "2016-10-13 09:15:23.456" with tickformat "%H~%M~%S.%2f" would display "09~15~23.46" + /// Sets the tick length (in px). + /// Sets a tick label prefix. + /// Determines whether ticks are drawn or not. If "", this axis' ticks are not drawn. If "outside" ("inside"), this axis' are drawn outside (inside) the axis lines. + /// Sets a tick label suffix. + /// Sets the values at which ticks on this axis appear. Defaults to `realaxis.tickvals` plus the same as negatives and zero. + /// Sets the tick width (in px). + /// A single toggle to hide the axis while preserving interaction like dragging. Default is true when a cheater plot is present on the axis, otherwise false + static member style + ( + [] ?Color: Color, + [] ?GridColor: Color, + [] ?GridWidth: int, + [] ?HoverFormat: string, + [] ?Layer: StyleParam.Layer, + [] ?LineColor: Color, + [] ?LineWidth: int, + [] ?ShowGrid: bool, + [] ?ShowLine: bool, + [] ?ShowTickLabels: bool, + [] ?ShowTickSuffix: StyleParam.ShowTickOption, + [] ?ShowTickPrefix: StyleParam.ShowTickOption, + [] ?TickColor: Color, + [] ?TickFont: Font, + [] ?TickFormat: string, + [] ?TickLen: int, + [] ?TickPrefix: string, + [] ?Ticks: StyleParam.TickLabelPosition, + [] ?TickSuffix: string, + [] ?TickVals: seq<#IConvertible>, + [] ?TickWidth: int, + [] ?Visible: bool + ) = + fun (imaginaryAxis: ImaginaryAxis) -> + + Color |> DynObj.setValueOpt imaginaryAxis "color" + GridColor |> DynObj.setValueOpt imaginaryAxis "gridcolor" + GridWidth |> DynObj.setValueOpt imaginaryAxis "gridwidth" + HoverFormat |> DynObj.setValueOpt imaginaryAxis "hoverformat" + Layer |> DynObj.setValueOptBy imaginaryAxis "layer" StyleParam.Layer.convert + LineColor |> DynObj.setValueOpt imaginaryAxis "linecolor" + LineWidth |> DynObj.setValueOpt imaginaryAxis "linewidth" + ShowGrid |> DynObj.setValueOpt imaginaryAxis "showgrid" + ShowLine |> DynObj.setValueOpt imaginaryAxis "showline" + ShowTickLabels |> DynObj.setValueOpt imaginaryAxis "showticklabels" + ShowTickSuffix |> DynObj.setValueOptBy imaginaryAxis "showticksuffix" StyleParam.ShowTickOption.convert + ShowTickPrefix |> DynObj.setValueOptBy imaginaryAxis "showtickprefix" StyleParam.ShowTickOption.convert + TickColor |> DynObj.setValueOpt imaginaryAxis "tickcolor" + TickFont |> DynObj.setValueOpt imaginaryAxis "tickfont" + TickFormat |> DynObj.setValueOpt imaginaryAxis "tickformat" + TickLen |> DynObj.setValueOpt imaginaryAxis "ticklen" + TickPrefix |> DynObj.setValueOpt imaginaryAxis "tickprefix" + Ticks |> DynObj.setValueOptBy imaginaryAxis "ticks" StyleParam.TickLabelPosition.convert + TickSuffix |> DynObj.setValueOpt imaginaryAxis "ticksuffix" + TickVals |> DynObj.setValueOpt imaginaryAxis "tickvals" + TickWidth |> DynObj.setValueOpt imaginaryAxis "tickwidth" + Visible |> DynObj.setValueOpt imaginaryAxis "visible" + + imaginaryAxis diff --git a/src/Plotly.NET/Layout/ObjectAbstractions/Smith/RealAxis.fs b/src/Plotly.NET/Layout/ObjectAbstractions/Smith/RealAxis.fs new file mode 100644 index 000000000..d32788836 --- /dev/null +++ b/src/Plotly.NET/Layout/ObjectAbstractions/Smith/RealAxis.fs @@ -0,0 +1,176 @@ +namespace Plotly.NET.LayoutObjects + +open Plotly.NET +open DynamicObj +open System +open System.Runtime.InteropServices + + +/// Angular axes can be used as a scale for the angular coordinates in polar plots. +type RealAxis() = + inherit DynamicObj() + + /// + /// Initialize an RealAxis object that can be used as a real scale for smith coordinates. + /// + /// 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. + /// Sets the color of the grid lines. + /// Sets the width (in px) of the grid lines. + /// Sets the hover text formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: "%h" for half of the year as a decimal number as well as "%{n}f" for fractional seconds with n digits. For example, "2016-10-13 09:15:23.456" with tickformat "%H~%M~%S.%2f" would display "09~15~23.46" + /// Sets the layer on which this axis is displayed. If "above traces", this axis is displayed above all the subplot's traces If "below traces", this axis is displayed below all the subplot's traces, but above the grid lines. Useful when used together with scatter-like traces with `cliponaxis` set to "false" to show markers and/or text nodes above this axis. + /// Sets the axis line color. + /// Sets the width (in px) of the axis line. + /// Determines whether or not grid lines are drawn. If "true", the grid lines are drawn at every tick mark. + /// Determines whether or not a line bounding this axis is drawn. + /// Determines whether or not the tick labels are drawn. + /// If "all", all tick labels are displayed with a prefix. If "first", only the first tick is displayed with a prefix. If "last", only the last tick is displayed with a suffix. If "none", tick prefixes are hidden. + /// Same as `showtickprefix` but for tick suffixes. + /// Determines on which side of real axis line the tick and tick labels appear. + /// Sets the angle of the tick labels with respect to the horizontal. For example, a `tickangle` of -90 draws the tick labels vertically. + /// Sets the tick color. + /// Sets the tick font. + /// Sets the tick label formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: "%h" for half of the year as a decimal number as well as "%{n}f" for fractional seconds with n digits. For example, "2016-10-13 09:15:23.456" with tickformat "%H~%M~%S.%2f" would display "09~15~23.46" + /// Sets the tick length (in px). + /// Sets a tick label prefix. + /// Determines whether ticks are drawn or not. If "", this axis' ticks are not drawn. If "outside" ("inside"), this axis' are drawn outside (inside) the axis lines. + /// Sets a tick label suffix. + /// Sets the values at which ticks on this axis appear. Defaults to `realaxis.tickvals` plus the same as negatives and zero. + /// Sets the tick width (in px). + /// A single toggle to hide the axis while preserving interaction like dragging. Default is true when a cheater plot is present on the axis, otherwise false + static member init + ( + [] ?Color: Color, + [] ?GridColor: Color, + [] ?GridWidth: int, + [] ?HoverFormat: string, + [] ?Layer: StyleParam.Layer, + [] ?LineColor: Color, + [] ?LineWidth: int, + [] ?ShowGrid: bool, + [] ?ShowLine: bool, + [] ?ShowTickLabels: bool, + [] ?ShowTickSuffix: StyleParam.ShowTickOption, + [] ?ShowTickPrefix: StyleParam.ShowTickOption, + [] ?Side: StyleParam.Side, + [] ?TickAngle: int, + [] ?TickColor: Color, + [] ?TickFont: Font, + [] ?TickFormat: string, + [] ?TickLen: int, + [] ?TickPrefix: string, + [] ?Ticks: StyleParam.TickLabelPosition, + [] ?TickSuffix: string, + [] ?TickVals: seq<#IConvertible>, + [] ?TickWidth: int, + [] ?Visible: bool + ) = + RealAxis() + |> RealAxis.style ( + ?Color = Color, + ?GridColor = GridColor, + ?GridWidth = GridWidth, + ?HoverFormat = HoverFormat, + ?Layer = Layer, + ?LineColor = LineColor, + ?LineWidth = LineWidth, + ?ShowGrid = ShowGrid, + ?ShowLine = ShowLine, + ?ShowTickLabels = ShowTickLabels, + ?ShowTickSuffix = ShowTickSuffix, + ?ShowTickPrefix = ShowTickPrefix, + ?Side = Side, + ?TickAngle = TickAngle, + ?TickColor = TickColor, + ?TickFont = TickFont, + ?TickFormat = TickFormat, + ?TickLen = TickLen, + ?TickPrefix = TickPrefix, + ?Ticks = Ticks, + ?TickSuffix = TickSuffix, + ?TickVals = TickVals, + ?TickWidth = TickWidth, + ?Visible = Visible + ) + + /// + /// Creates a function that applies the given style parameters to a RealAxis object + /// + /// 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. + /// Sets the color of the grid lines. + /// Sets the width (in px) of the grid lines. + /// Sets the hover text formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: "%h" for half of the year as a decimal number as well as "%{n}f" for fractional seconds with n digits. For example, "2016-10-13 09:15:23.456" with tickformat "%H~%M~%S.%2f" would display "09~15~23.46" + /// Sets the layer on which this axis is displayed. If "above traces", this axis is displayed above all the subplot's traces If "below traces", this axis is displayed below all the subplot's traces, but above the grid lines. Useful when used together with scatter-like traces with `cliponaxis` set to "false" to show markers and/or text nodes above this axis. + /// Sets the axis line color. + /// Sets the width (in px) of the axis line. + /// Determines whether or not grid lines are drawn. If "true", the grid lines are drawn at every tick mark. + /// Determines whether or not a line bounding this axis is drawn. + /// Determines whether or not the tick labels are drawn. + /// If "all", all tick labels are displayed with a prefix. If "first", only the first tick is displayed with a prefix. If "last", only the last tick is displayed with a suffix. If "none", tick prefixes are hidden. + /// Same as `showtickprefix` but for tick suffixes. + /// Determines on which side of real axis line the tick and tick labels appear. + /// Sets the angle of the tick labels with respect to the horizontal. For example, a `tickangle` of -90 draws the tick labels vertically. + /// Sets the tick color. + /// Sets the tick font. + /// Sets the tick label formatting rule using d3 formatting mini-languages which are very similar to those in Python. For numbers, see: https://github.com/d3/d3-format/tree/v1.4.5#d3-format. And for dates see: https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format. We add two items to d3's date formatter: "%h" for half of the year as a decimal number as well as "%{n}f" for fractional seconds with n digits. For example, "2016-10-13 09:15:23.456" with tickformat "%H~%M~%S.%2f" would display "09~15~23.46" + /// Sets the tick length (in px). + /// Sets a tick label prefix. + /// Determines whether ticks are drawn or not. If "", this axis' ticks are not drawn. If "outside" ("inside"), this axis' are drawn outside (inside) the axis lines. + /// Sets a tick label suffix. + /// Sets the values at which ticks on this axis appear. Defaults to `realaxis.tickvals` plus the same as negatives and zero. + /// Sets the tick width (in px). + /// A single toggle to hide the axis while preserving interaction like dragging. Default is true when a cheater plot is present on the axis, otherwise false + static member style + ( + [] ?Color: Color, + [] ?GridColor: Color, + [] ?GridWidth: int, + [] ?HoverFormat: string, + [] ?Layer: StyleParam.Layer, + [] ?LineColor: Color, + [] ?LineWidth: int, + [] ?ShowGrid: bool, + [] ?ShowLine: bool, + [] ?ShowTickLabels: bool, + [] ?ShowTickSuffix: StyleParam.ShowTickOption, + [] ?ShowTickPrefix: StyleParam.ShowTickOption, + [] ?Side: StyleParam.Side, + [] ?TickAngle: int, + [] ?TickColor: Color, + [] ?TickFont: Font, + [] ?TickFormat: string, + [] ?TickLen: int, + [] ?TickPrefix: string, + [] ?Ticks: StyleParam.TickLabelPosition, + [] ?TickSuffix: string, + [] ?TickVals: seq<#IConvertible>, + [] ?TickWidth: int, + [] ?Visible: bool + ) = + fun (realAxis: RealAxis) -> + + Color |> DynObj.setValueOpt realAxis "color" + GridColor |> DynObj.setValueOpt realAxis "gridcolor" + GridWidth |> DynObj.setValueOpt realAxis "gridwidth" + HoverFormat |> DynObj.setValueOpt realAxis "hoverformat" + Layer |> DynObj.setValueOptBy realAxis "layer" StyleParam.Layer.convert + LineColor |> DynObj.setValueOpt realAxis "linecolor" + LineWidth |> DynObj.setValueOpt realAxis "linewidth" + ShowGrid |> DynObj.setValueOpt realAxis "showgrid" + ShowLine |> DynObj.setValueOpt realAxis "showline" + ShowTickLabels |> DynObj.setValueOpt realAxis "showticklabels" + ShowTickSuffix |> DynObj.setValueOptBy realAxis "showticksuffix" StyleParam.ShowTickOption.convert + ShowTickPrefix |> DynObj.setValueOptBy realAxis "showtickprefix" StyleParam.ShowTickOption.convert + Side |> DynObj.setValueOptBy realAxis "side" StyleParam.Side.convert + TickAngle |> DynObj.setValueOpt realAxis "tickangle" + TickColor |> DynObj.setValueOpt realAxis "tickcolor" + TickFont |> DynObj.setValueOpt realAxis "tickfont" + TickFormat |> DynObj.setValueOpt realAxis "tickformat" + TickLen |> DynObj.setValueOpt realAxis "ticklen" + TickPrefix |> DynObj.setValueOpt realAxis "tickprefix" + Ticks |> DynObj.setValueOptBy realAxis "ticks" StyleParam.TickLabelPosition.convert + TickSuffix |> DynObj.setValueOpt realAxis "ticksuffix" + TickVals |> DynObj.setValueOpt realAxis "tickvals" + TickWidth |> DynObj.setValueOpt realAxis "tickwidth" + Visible |> DynObj.setValueOpt realAxis "visible" + + realAxis diff --git a/src/Plotly.NET/Layout/ObjectAbstractions/Smith/Smith.fs b/src/Plotly.NET/Layout/ObjectAbstractions/Smith/Smith.fs new file mode 100644 index 000000000..f9a469d38 --- /dev/null +++ b/src/Plotly.NET/Layout/ObjectAbstractions/Smith/Smith.fs @@ -0,0 +1,99 @@ +namespace Plotly.NET.LayoutObjects + +open Plotly.NET +open DynamicObj +open System +open System.Runtime.InteropServices + +/// The smith subplot is used by TraceSmith traces. +type Smith() = + inherit DynamicObj() + + /// + /// Initialize a Smith object that contains layout options concerned with smith plots. + /// + /// Set the background color of the subplot + /// Sets the domain of this smith subplot + /// Sets the imaginary axis of this smith subplot + /// Sets the real axis of this smith subplot + static member init + ( + [] ?BGColor: Color, + [] ?Domain: Domain, + [] ?ImaginaryAxis: ImaginaryAxis, + [] ?RealAxis: RealAxis + ) = + Smith() + |> Smith.style ( + ?BGColor = BGColor, + ?Domain = Domain, + ?ImaginaryAxis = ImaginaryAxis, + ?RealAxis = RealAxis + + ) + + /// + /// Create a function that applies the given style parameters to a Smith object + /// + /// Set the background color of the subplot + /// Sets the domain of this smith subplot + /// Sets the imaginary axis of this smith subplot + /// Sets the real axis of this smith subplot + static member style + ( + [] ?BGColor: Color, + [] ?Domain: Domain, + [] ?ImaginaryAxis: ImaginaryAxis, + [] ?RealAxis: RealAxis + ) = + fun (smith: Smith) -> + + BGColor |> DynObj.setValueOpt smith "bgcolor" + Domain |> DynObj.setValueOpt smith "domain" + ImaginaryAxis |> DynObj.setValueOpt smith "imaginaryaxis" + RealAxis |> DynObj.setValueOpt smith "realaxis" + + smith + + /// + /// Returns Some(dynamic member value) of the object's underlying DynamicObj when a dynamic member eith the given name exists, and None otherwise. + /// + /// The name of the dynamic member to get the value of + /// The object to get the dynamic member value from + static member tryGetTypedMember<'T> (propName: string) (smith: Smith) = smith.TryGetTypedValue<'T>(propName) + + /// + /// Returns the ImaginaryAxis object of the given smith object. + /// + /// If there is no ImaginaryAxis set, returns an empty ImaginaryAxis object. + /// + /// The smith object to get the ImaginaryAxis from + static member getImaginaryAxis(smith: Smith) = + smith |> Smith.tryGetTypedMember "imaginaryaxis" |> Option.defaultValue (ImaginaryAxis.init ()) + + /// + /// Returns a function that sets the ImaginaryAxis object of the given smith object. + /// + /// The new ImaginaryAxis object + static member setImaginaryAxis(imaginaryAxis: ImaginaryAxis) = + (fun (smith: Smith) -> + smith.SetValue("imaginaryaxis", imaginaryAxis) + smith) + + /// + /// Returns the RealAxis object of the given smith object. + /// + /// If there is no RealAxis set, returns an empty RealAxis object. + /// + /// The smith object to get the RealAxis from + static member getRealAxis(smith: Smith) = + smith |> Smith.tryGetTypedMember "realaxis" |> Option.defaultValue (RealAxis.init ()) + + /// + /// Returns a function that sets the RealAxis object of the given smith object. + /// + /// The new RealAxis object + static member setRealAxis(realAxis: RealAxis) = + (fun (smith: Smith) -> + smith.SetValue("realaxis", realAxis) + smith) diff --git a/src/Plotly.NET/Playground.fsx b/src/Plotly.NET/Playground.fsx index 1d9d8da3b..f9936c695 100644 --- a/src/Plotly.NET/Playground.fsx +++ b/src/Plotly.NET/Playground.fsx @@ -62,6 +62,12 @@ #load "RadialAxis.fs" #load "Polar.fs" +#I "Layout/ObjectAbstractions/Smith" + +#load "ImaginaryAxis.fs" +#load "RealAxis.fs" +#load "Smith.fs" + #I "Layout/ObjectAbstractions/Ternary" #load "Ternary.fs" @@ -118,6 +124,7 @@ #load "TraceTernary.fs" #load "TraceCarpet.fs" #load "TraceDomain.fs" +#load "TraceSmith.fs" #load "TraceID.fs" #I "Config/ObjectAbstractions" @@ -150,6 +157,7 @@ #load "ChartTernary.fs" #load "ChartCarpet.fs" #load "ChartDomain.fs" +#load "ChartSmith.fs" #I "CSharpLayer" @@ -176,159 +184,3 @@ open Plotly.NET open System open Plotly.NET - - -let y = [2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.] -let x = ["bin1";"bin2";"bin1";"bin2";"bin1";"bin2";"bin1";"bin1";"bin2";"bin1"] - -let y2 = [2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.] -let x2 = ["bin3";"bin4";"bin3";"bin4";"bin3";"bin4";"bin3";"bin3";"bin4";"bin3"] - -let violin1 = - Chart.Violin ( - x,y, - ShowBox = true, - BoxFillColor = Color.fromKeyword ColorKeyword.Red - ) - |> Chart.withConfigStyle( - StaticPlot = false, - Editable= true, - PlotlyServerUrl = "https://chart-studio.plotly.com", - ModeBarButtonsToAdd = [ - StyleParam.ModeBarButton.DrawRect - ] - ) - -let violin2 = - Chart.Violin ( - x2,y2, - ShowBox = true, - BoxFillColor = Color.fromKeyword ColorKeyword.Green - ) - |> Chart.withConfigStyle( - ShowEditInChartStudio = true, - ModeBarButtonsToAdd = [ - StyleParam.ModeBarButton.DrawLine - ] - ) - -violin2 -|> GenericChart.getConfig -|> DynObj.print - -violin1 -|> GenericChart.getConfig -|> DynObj.print - -[ - violin1 - violin2 -] -|> Chart.combine -|> Chart.withTraceInfo( - Name = "violins", - LegendGroup = "violins", - LegendGroupTitle = Title.init("Some violins m8") -) -|> Chart.show - -let table1 = - let header = ["RowIndex";"A";"simple";"table"] - let rows = - [ - ["0";"I" ;"am" ;"a"] - ["1";"little";"example";"!"] - ] - Chart.Table(header, rows) - |> Chart.show - -Trace2D.initHistogram( - Trace2DStyle.Histogram( - Y = [1;2;3;3;4;4;4;5;6;6;7] - ) -) -|> GenericChart.ofTraceObject true -|> Chart.show - -let contour = - [ - Chart.Carpet( - "contour", - A = [0.; 1.; 2.; 3.; 0.; 1.; 2.; 3.; 0.; 1.; 2.; 3.], - B = [4.; 4.; 4.; 4.; 5.; 5.; 5.; 5.; 6.; 6.; 6.; 6.], - X = [2.; 3.; 4.; 5.; 2.2; 3.1; 4.1; 5.1; 1.5; 2.5; 3.5; 4.5], - Y = [1.; 1.4; 1.6; 1.75; 2.; 2.5; 2.7; 2.75; 3.; 3.5; 3.7; 3.75], - AAxis = LinearAxis.initCarpet( - TickPrefix = "a = ", - Smoothing = 0., - MinorGridCount = 9, - AxisType = StyleParam.AxisType.Linear - ), - BAxis = LinearAxis.initCarpet( - TickPrefix = "b = ", - Smoothing = 0., - MinorGridCount = 9, - AxisType = StyleParam.AxisType.Linear - ), - UseDefaults = false, - Opacity = 0.75 - ) - Chart.ContourCarpet( - [1.; 1.96; 2.56; 3.0625; 4.; 5.0625; 1.; 7.5625; 9.; 12.25; 15.21; 14.0625], - "contour", - A = [0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3], - B = [4; 4; 4; 4; 5; 5; 5; 5; 6; 6; 6; 6], - UseDefaults = false, - ContourLineColor = Color.fromKeyword White, - ShowContourLabels = true - ) - ] - |> Chart.combine - |> Chart.show - -Chart.BubbleTernary( - [ - 1,2,3,5 - 2,2,2,15 - 3,2,1,25 - ] -) -|> Chart.show - -let multiTraceGrid = - [ - Chart.Point([1,2; 2,3], UseDefaults = false) - Chart.PointTernary([1,2,3; 2,3,4], UseDefaults = false) - Chart.Heatmap([[1; 2];[3; 4]], ShowScale=false, UseDefaults = false) - Chart.Point3D([1,3,2], UseDefaults = false) - Chart.PointMapbox([1,2], UseDefaults = false) |> Chart.withMapbox(Mapbox.init(Style = StyleParam.MapboxStyle.OpenStreetMap)) - [ - // you can use nested combined charts, but they have to have the same trace type (Cartesian2D in this case) - let y = [2.; 1.5; 5.; 1.5; 2.; 2.5; 2.1; 2.5; 1.5; 1.;2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.] - Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All, UseDefaults = false); - Chart.BoxPlot("y'",y,Name="bin2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All, UseDefaults = false); - ] - |> Chart.combine - ] - |> Chart.Grid(2,3) - |> Chart.withSize(1000,1000) - |> Chart.show - -let multiTraceSingleStack = - [ - Chart.Point([1,2; 2,3], UseDefaults = false) - Chart.PointTernary([1,2,3; 2,3,4], UseDefaults = false) - Chart.Heatmap([[1; 2];[3; 4]], ShowScale=false, UseDefaults = false) - Chart.Point3D([1,3,2], UseDefaults = false) - Chart.PointMapbox([1,2], UseDefaults = false) |> Chart.withMapbox(Mapbox.init(Style = StyleParam.MapboxStyle.OpenStreetMap)) - [ - // you can use nested combined charts, but they have to have the same trace type (Cartesian2D in this case) - let y = [2.; 1.5; 5.; 1.5; 2.; 2.5; 2.1; 2.5; 1.5; 1.;2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.] - Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All, UseDefaults = false); - Chart.BoxPlot("y'",y,Name="bin2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All, UseDefaults = false); - ] - |> Chart.combine - ] - |> Chart.SingleStack() - |> Chart.withSize(1000,1000) - |> Chart.show \ No newline at end of file diff --git a/src/Plotly.NET/Plotly.NET.fsproj b/src/Plotly.NET/Plotly.NET.fsproj index c669f4c7d..a126fab4e 100644 --- a/src/Plotly.NET/Plotly.NET.fsproj +++ b/src/Plotly.NET/Plotly.NET.fsproj @@ -80,6 +80,9 @@ + + + @@ -120,6 +123,7 @@ + @@ -141,6 +145,7 @@ + diff --git a/src/Plotly.NET/Traces/TraceID.fs b/src/Plotly.NET/Traces/TraceID.fs index 19b5016be..ec3e5498b 100644 --- a/src/Plotly.NET/Traces/TraceID.fs +++ b/src/Plotly.NET/Traces/TraceID.fs @@ -16,6 +16,7 @@ type TraceID = | Ternary | Carpet | Domain + | Smith | Multi static member ofTrace(t: Trace) : TraceID = @@ -28,6 +29,7 @@ type TraceID = | :? TraceTernary -> TraceID.Ternary | :? TraceCarpet -> TraceID.Carpet | :? TraceDomain -> TraceID.Domain + | :? TraceSmith -> TraceID.Smith | unknownTraceType -> failwith $"cannot get trace id for type {unknownTraceType.GetType()}" static member ofTraces(t: seq) : TraceID = diff --git a/src/Plotly.NET/Traces/TraceSmith.fs b/src/Plotly.NET/Traces/TraceSmith.fs new file mode 100644 index 000000000..7ad899681 --- /dev/null +++ b/src/Plotly.NET/Traces/TraceSmith.fs @@ -0,0 +1,147 @@ +namespace Plotly.NET + +open Plotly.NET.LayoutObjects +open Plotly.NET.TraceObjects +open DynamicObj +open System +open System.Runtime.InteropServices + +type TraceSmith(traceTypeName) = + + inherit Trace(traceTypeName) + + ///initializes a trace of type "scattersmith" applying the given trace styling function + static member initScatterSmith(applyStyle: TraceSmith -> TraceSmith) = + TraceSmith("scattersmith") |> applyStyle + +type TraceSmithStyle() = + + static member SetSmith([] ?SmithId: StyleParam.SubPlotId) = + (fun (trace: TraceSmith) -> + + SmithId |> DynObj.setValueOptBy trace "subplot" StyleParam.SubPlotId.toString + + trace) + + /// + /// Create a function that applies the styles of a scatter smith plot to a Trace object + /// + /// Sets the trace name. The trace name appear as the legend item and on hover. + /// Determines whether or not this trace is visible. If "legendonly", the trace is not drawn, but can appear as a legend item (provided that the legend itself is visible). + /// Determines whether or not an item corresponding to this trace is shown in the legend. + /// Sets the legend rank for this trace. 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 this trace. Traces part of the same legend group hide/show at the same time when toggling legend items. + /// Sets the legend group title for this trace. + /// Sets the opacity of the trace. + /// Determines the drawing mode for this scatter trace. If the provided `mode` includes "text" then the `text` elements appear at the coordinates. Otherwise, the `text` elements appear on hover. If there are less than 20 points and the trace is not stacked then the default is "lines+markers". Otherwise, "lines". + /// Assigns id labels to each datum. These ids for object constancy of data points during animation. Should be an array of strings, not numbers or any other type. + /// Sets the imaginary component of the data, in units of normalized impedance such that real=1, imag=0 is the center of the chart. + /// 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 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. + /// Template string used for rendering the information text that appear on points. Note that this will override `textinfo`. Variables are inserted using %{variable}, for example "y: %{y}". Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example "Price: %{y:$.2f}". https://github.com/d3/d3-format/tree/v1.4.5#d3-format for details on the formatting syntax. Dates are formatted using d3-time-format's syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}". https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format for details on the date formatting syntax. Every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available. + /// Template string used for rendering the information text that appear on points. Note that this will override `textinfo`. Variables are inserted using %{variable}, for example "y: %{y}". Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example "Price: %{y:$.2f}". https://github.com/d3/d3-format/tree/v1.4.5#d3-format for details on the formatting syntax. Dates are formatted using d3-time-format's syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}". https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format for details on the date formatting syntax. Every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available. + /// Sets hover 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. To be seen, trace `hoverinfo` must contain a "text" flag. + /// Sets hover 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. To be seen, trace `hoverinfo` must contain a "text" flag. + /// Determines which trace information appear on hover. If `none` or `skip` are set, no information is displayed upon hovering. But, if `none` is set, click and hover events are still fired. + /// Template string used for rendering the information that appear on hover box. Note that this will override `hoverinfo`. Variables are inserted using %{variable}, for example "y: %{y}" as well as %{xother}, {%_xother}, {%_xother_}, {%xother_}. When showing info for several points, "xother" will be added to those with different x positions from the first point. An underscore before or after "(x|y)other" will add a space on that side, only when this field is shown. Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example "Price: %{y:$.2f}". https://github.com/d3/d3-format/tree/v1.4.5#d3-format for details on the formatting syntax. Dates are formatted using d3-time-format's syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}". https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format for details on the date formatting syntax. The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plotly.com/javascript/plotlyjs-events/#event-data. Additionally, every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available. variable `norm` Anything contained in tag `<extra>` is displayed in the secondary box, for example "<extra>{fullData.name}</extra>". To hide the secondary box completely, use an empty tag `<extra></extra>`. + /// Template string used for rendering the information that appear on hover box. Note that this will override `hoverinfo`. Variables are inserted using %{variable}, for example "y: %{y}" as well as %{xother}, {%_xother}, {%_xother_}, {%xother_}. When showing info for several points, "xother" will be added to those with different x positions from the first point. An underscore before or after "(x|y)other" will add a space on that side, only when this field is shown. Numbers are formatted using d3-format's syntax %{variable:d3-format}, for example "Price: %{y:$.2f}". https://github.com/d3/d3-format/tree/v1.4.5#d3-format for details on the formatting syntax. Dates are formatted using d3-time-format's syntax %{variable|d3-time-format}, for example "Day: %{2019-01-01|%A}". https://github.com/d3/d3-time-format/tree/v2.2.3#locale_format for details on the date formatting syntax. The variables available in `hovertemplate` are the ones emitted as event data described at this link https://plotly.com/javascript/plotlyjs-events/#event-data. Additionally, every attributes that can be specified per-point (the ones that are `arrayOk: true`) are available. variable `norm` Anything contained in tag `<extra>` is displayed in the secondary box, for example "<extra>{fullData.name}</extra>". To hide the secondary box completely, use an empty tag `<extra></extra>`. + /// Assigns extra meta information associated with this trace that can be used in various text attributes. Attributes such as trace `name`, graph, axis and colorbar `title.text`, annotation `text` `rangeselector`, `updatemenues` and `sliders` `label` text all support `meta`. To access the trace `meta` values in an attribute in the same trace, simply use `%{meta[i]}` where `i` is the index or key of the `meta` item in question. To access trace `meta` in layout attributes, use `%{data[n[.meta[i]}` where `i` is the index or key of the `meta` and `n` is the trace index. + /// Assigns extra data each datum. This may be useful when listening to hover, click and selection events. Note that, "scatter" traces also appends customdata items in the markers DOM elements + /// Sets a reference between this trace's data coordinates and a smith subplot. If "smith" (the default value), the data refer to `layout.smith`. If "smith2", the data refer to `layout.smith2`, and so on. + /// Sets the marker of this trace. + /// Sets the line of this trace. + /// Sets the text font of this trace. + /// Array containing integer indices of selected points. Has an effect only for traces that support selections. Note that an empty array means an empty selection where the `unselected` are turned on for all points, whereas, any other non-array values means no selection all where the `selected` and `unselected` styles have no effect. + /// Sets the style of selected points of this trace. + /// Sets the style of unselected points of this trace. + /// Determines whether or not markers and text nodes are clipped about the subplot axes. To show markers and text nodes above axis lines and tick labels, make sure to set `xaxis.layer` and `yaxis.layer` to "below traces". + /// Determines whether or not gaps (i.e. {nan} or missing values) in the provided data arrays are connected. + /// 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. + /// 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 style of the hoverlabels of this trace. + /// Do the hover effects highlight individual points (markers or line points) or do they highlight filled regions? If the fill is "toself" or "tonext" and there are no markers or text, then the default is "fills", otherwise it is "points". + /// Controls persistence of some user-driven changes to the trace: `constraintrange` in `parcoords` traces, as well as some `editable: true` modifications such as `name` and `colorbar.title`. Defaults to `layout.uirevision`. Note that other user-driven trace attribute changes are controlled by `layout` attributes: `trace.visible` is controlled by `layout.legend.uirevision`, `selectedpoints` is controlled by `layout.selectionrevision`, and `colorbar.(x|y)` (accessible with `config: {editable: true}`) is controlled by `layout.editrevision`. Trace changes are tracked by `uid`, which only falls back on trace index if no `uid` is provided. So if your app can add/remove traces before the end of the `data` array, such that the same trace has a different index, you can still preserve user-driven changes if you give each trace a `uid` that stays with it as it moves. + static member ScatterSmith + ( + [] ?Name: string, + [] ?Visible: StyleParam.Visible, + [] ?ShowLegend: bool, + [] ?LegendRank: int, + [] ?LegendGroup: string, + [] ?LegendGroupTitle: Title, + [] ?Opacity: float, + [] ?Mode: StyleParam.Mode, + [] ?Ids: seq<#IConvertible>, + [] ?Imag: seq<#IConvertible>, + [] ?Real: seq<#IConvertible>, + [] ?Text: #IConvertible, + [] ?MultiText: seq<#IConvertible>, + [] ?TextPosition: StyleParam.TextPosition, + [] ?MultiTextPosition: seq, + [] ?TextTemplate: string, + [] ?MultiTextTemplate: seq, + [] ?HoverText: string, + [] ?MultiHoverText: seq, + [] ?HoverInfo: StyleParam.HoverInfo, + [] ?HoverTemplate: string, + [] ?MultiHoverTemplate: seq, + [] ?Meta: string, + [] ?CustomData: seq<#IConvertible>, + [] ?Subplot: StyleParam.SubPlotId, + [] ?Marker: Marker, + [] ?Line: Line, + [] ?TextFont: Font, + [] ?SelectedPoints: seq<#IConvertible>, + [] ?Selected: Selection, + [] ?Unselected: Selection, + [] ?ClipOnAxis: bool, + [] ?ConnectGaps: bool, + [] ?Fill: StyleParam.Fill, + [] ?FillColor: Color, + [] ?HoverLabel: Hoverlabel, + [] ?HoverOn: StyleParam.HoverOn, + [] ?UIRevision: string + ) = + fun (trace: ('T :> Trace)) -> + + Name |> DynObj.setValueOpt trace "name" + Visible |> DynObj.setValueOptBy trace "visible" StyleParam.Visible.convert + ShowLegend |> DynObj.setValueOpt trace "showlegend" + LegendRank |> DynObj.setValueOpt trace "legendrank" + LegendGroup |> DynObj.setValueOpt trace "legendgroup" + LegendGroupTitle |> DynObj.setValueOpt trace "legendgrouptitle" + Opacity |> DynObj.setValueOpt trace "opacity" + Mode |> DynObj.setValueOptBy trace "mode" StyleParam.Mode.convert + Ids |> DynObj.setValueOpt trace "ids" + Imag |> DynObj.setValueOpt trace "imag" + Real |> DynObj.setValueOpt trace "real" + (Text, MultiText) |> DynObj.setSingleOrMultiOpt trace "text" + + (TextPosition, MultiTextPosition) + |> DynObj.setSingleOrMultiOptBy trace "textposition" StyleParam.TextPosition.convert + + (TextTemplate, MultiTextTemplate) |> DynObj.setSingleOrMultiOpt trace "texttemplate" + (HoverText, MultiHoverText) |> DynObj.setSingleOrMultiOpt trace "hovertext" + HoverInfo |> DynObj.setValueOptBy trace "hoverinfo" StyleParam.HoverInfo.convert + (HoverTemplate, MultiHoverTemplate) |> DynObj.setSingleOrMultiOpt trace "hovertemplate" + Meta |> DynObj.setValueOpt trace "meta" + CustomData |> DynObj.setValueOpt trace "customdata" + Subplot |> DynObj.setValueOpt trace "subplot" + Marker |> DynObj.setValueOpt trace "marker" + Line |> DynObj.setValueOpt trace "line" + TextFont |> DynObj.setValueOpt trace "textfont" + SelectedPoints |> DynObj.setValueOpt trace "selectedpoints" + Selected |> DynObj.setValueOpt trace "selected" + Unselected |> DynObj.setValueOpt trace "unselected" + ClipOnAxis |> DynObj.setValueOpt trace "cliponaxis" + ConnectGaps |> DynObj.setValueOpt trace "connectgaps" + Fill |> DynObj.setValueOptBy trace "fill" StyleParam.Fill.convert + FillColor |> DynObj.setValueOpt trace "fillcolor" + HoverLabel |> DynObj.setValueOpt trace "hoverlabel" + HoverOn |> DynObj.setValueOptBy trace "hoveron" StyleParam.HoverOn.convert + UIRevision |> DynObj.setValueOpt trace "uirevision" + + trace diff --git a/tests/Plotly.NET.Tests/HtmlCodegen/ChartLayout.fs b/tests/Plotly.NET.Tests/HtmlCodegen/ChartLayout.fs index 2558ba6de..0e567be7b 100644 --- a/tests/Plotly.NET.Tests/HtmlCodegen/ChartLayout.fs +++ b/tests/Plotly.NET.Tests/HtmlCodegen/ChartLayout.fs @@ -160,20 +160,65 @@ let singleStackChart = let multiTraceGrid = [ - Chart.Point([1,2; 2,3], UseDefaults = false) - Chart.PointTernary([1,2,3; 2,3,4], UseDefaults = false) - Chart.Heatmap([[1; 2];[3; 4]], ShowScale=false, UseDefaults = false) - Chart.Point3D([1,3,2], UseDefaults = false) - Chart.PointMapbox([1,2], UseDefaults = false) |> Chart.withMapbox(Mapbox.init(Style = StyleParam.MapboxStyle.OpenStreetMap)) + Chart.Point([1,2; 2,3], Name = "2D Cartesian", UseDefaults = false) + Chart.Point3D([1,3,2], Name = "3D Cartesian", UseDefaults = false) + Chart.PointPolar([10,20], Name = "Polar", UseDefaults = false) + Chart.PointGeo([1,2], Name = "Geo", UseDefaults = false) + Chart.PointMapbox([1,2], Name = "MapBox", UseDefaults = false) |> Chart.withMapbox(Mapbox.init(Style = StyleParam.MapboxStyle.OpenStreetMap)) + Chart.PointTernary([1,2,3; 2,3,4], Name = "Ternary", UseDefaults = false) + [ + Chart.Carpet( + "contour", + A = [0.; 1.; 2.; 3.; 0.; 1.; 2.; 3.; 0.; 1.; 2.; 3.], + B = [4.; 4.; 4.; 4.; 5.; 5.; 5.; 5.; 6.; 6.; 6.; 6.], + X = [2.; 3.; 4.; 5.; 2.2; 3.1; 4.1; 5.1; 1.5; 2.5; 3.5; 4.5], + Y = [1.; 1.4; 1.6; 1.75; 2.; 2.5; 2.7; 2.75; 3.; 3.5; 3.7; 3.75], + AAxis = LinearAxis.initCarpet( + TickPrefix = "a = ", + Smoothing = 0., + MinorGridCount = 9, + AxisType = StyleParam.AxisType.Linear + ), + BAxis = LinearAxis.initCarpet( + TickPrefix = "b = ", + Smoothing = 0., + MinorGridCount = 9, + AxisType = StyleParam.AxisType.Linear + ), + UseDefaults = false, + Opacity = 0.75 + ) + Chart.ContourCarpet( + [1.; 1.96; 2.56; 3.0625; 4.; 5.0625; 1.; 7.5625; 9.; 12.25; 15.21; 14.0625], + "contour", + A = [0; 1; 2; 3; 0; 1; 2; 3; 0; 1; 2; 3], + B = [4; 4; 4; 4; 5; 5; 5; 5; 6; 6; 6; 6], + UseDefaults = false, + ContourLineColor = Color.fromKeyword White, + ShowContourLabels = true, + ShowScale = false + ) + ] + |> Chart.combine + Chart.Pie([10;40;50;], Name = "Domain", UseDefaults = false) + Chart.BubbleSmith( + [0.5; 1.; 2.; 3.], + [0.5; 1.; 2.; 3.], + sizes = [10;20;30;40], + MultiText=["one";"two";"three";"four";"five";"six";"seven"], + TextPosition=StyleParam.TextPosition.TopCenter, + Name = "Smith", + UseDefaults = false + ) [ // you can use nested combined charts, but they have to have the same trace type (Cartesian2D in this case) let y = [2.; 1.5; 5.; 1.5; 2.; 2.5; 2.1; 2.5; 1.5; 1.;2.; 1.5; 5.; 1.5; 3.; 2.5; 2.5; 1.5; 3.5; 1.] - Chart.BoxPlot("y" ,y,Name="bin1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All, UseDefaults = false); - Chart.BoxPlot("y'",y,Name="bin2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All, UseDefaults = false); + Chart.BoxPlot("y" ,y,Name="Combined 1",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All, UseDefaults = false); + Chart.BoxPlot("y'",y,Name="Combined 2",Jitter=0.1,BoxPoints=StyleParam.BoxPoints.All, UseDefaults = false); ] |> Chart.combine ] - |> Chart.Grid(2,3) + |> Chart.Grid(4,3) |> Chart.withSize(1000,1000) let multiTraceSingleStack = @@ -210,11 +255,11 @@ let ``Multicharts and subplots`` = |> chartGeneratedContains subPlotChart ); testCase "MultiTrace Subplot grid data" ( fun () -> - """var data = [{"type":"scatter","mode":"markers","x":[1,2],"y":[2,3],"marker":{},"line":{},"xaxis":"x","yaxis":"y"},{"type":"scatterternary","mode":"markers","a":[1,2],"b":[2,3],"c":[3,4],"marker":{},"line":{},"subplot":"ternary2"},{"type":"heatmap","z":[[1,2],[3,4]],"showscale":false,"xaxis":"x3","yaxis":"y3"},{"type":"scatter3d","mode":"markers","x":[1],"y":[3],"z":[2],"marker":{},"line":{},"scene":"scene4"},{"type":"scattermapbox","mode":"markers","lat":[2],"lon":[1],"marker":{},"line":{},"subplot":"mapbox5"},{"type":"box","name":"bin1","x":"y","y":[2.0,1.5,5.0,1.5,2.0,2.5,2.1,2.5,1.5,1.0,2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"marker":{},"line":{},"boxpoints":"all","jitter":0.1,"xaxis":"x6","yaxis":"y6"},{"type":"box","name":"bin2","x":"y'","y":[2.0,1.5,5.0,1.5,2.0,2.5,2.1,2.5,1.5,1.0,2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"marker":{},"line":{},"boxpoints":"all","jitter":0.1,"xaxis":"x6","yaxis":"y6"}];""" + """var data = [{"type":"scatter","name":"2D Cartesian","mode":"markers","x":[1,2],"y":[2,3],"marker":{},"line":{},"xaxis":"x","yaxis":"y"},{"type":"scatter3d","name":"3D Cartesian","mode":"markers","x":[1],"y":[3],"z":[2],"marker":{},"line":{},"scene":"scene2"},{"type":"scatterpolar","name":"Polar","mode":"markers","r":[10],"theta":[20],"marker":{},"subplot":"polar3"},{"type":"scattergeo","name":"Geo","mode":"markers","lat":[2],"lon":[1],"marker":{},"line":{},"geo":"geo4"},{"type":"scattermapbox","name":"MapBox","mode":"markers","lat":[2],"lon":[1],"marker":{},"line":{},"subplot":"mapbox5"},{"type":"scatterternary","name":"Ternary","mode":"markers","a":[1,2],"b":[2,3],"c":[3,4],"marker":{},"line":{},"subplot":"ternary6"},{"type":"carpet","opacity":0.75,"x":[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":[1.0,1.4,1.6,1.75,2.0,2.5,2.7,2.75,3.0,3.5,3.7,3.75],"a":[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":[4.0,4.0,4.0,4.0,5.0,5.0,5.0,5.0,6.0,6.0,6.0,6.0],"aaxis":{"type":"linear","tickprefix":"a = ","minorgridcount":9,"smoothing":0.0},"baxis":{"type":"linear","tickprefix":"b = ","minorgridcount":9,"smoothing":0.0},"carpet":"contour","xaxis":"x7","yaxis":"y7"},{"type":"contourcarpet","z":[1.0,1.96,2.56,3.0625,4.0,5.0625,1.0,7.5625,9.0,12.25,15.21,14.0625],"a":[0,1,2,3,0,1,2,3,0,1,2,3],"b":[4,4,4,4,5,5,5,5,6,6,6,6],"line":{"color":"rgba(255, 255, 255, 1.0)"},"showscale":false,"carpet":"contour","contours":{"showlabels":true}},{"type":"pie","name":"Domain","values":[10,40,50],"marker":{"line":{}},"domain":{"row":2,"column":1}},{"type":"scattersmith","name":"Smith","mode":"markers+text","imag":[0.5,1.0,2.0,3.0],"real":[0.5,1.0,2.0,3.0],"text":["one","two","three","four","five","six","seven"],"textposition":"top center","marker":{"size":[10,20,30,40]},"line":{},"subplot":"smith9"},{"type":"box","name":"Combined 1","x":"y","y":[2.0,1.5,5.0,1.5,2.0,2.5,2.1,2.5,1.5,1.0,2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"marker":{},"line":{},"boxpoints":"all","jitter":0.1,"xaxis":"x10","yaxis":"y10"},{"type":"box","name":"Combined 2","x":"y'","y":[2.0,1.5,5.0,1.5,2.0,2.5,2.1,2.5,1.5,1.0,2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"marker":{},"line":{},"boxpoints":"all","jitter":0.1,"xaxis":"x10","yaxis":"y10"}];""" |> chartGeneratedContains multiTraceGrid ); testCase "MultiTrace Subplot grid layout" ( fun () -> - """var layout = {"xaxis":{},"yaxis":{},"ternary2":{"domain":{"row":0,"column":1}},"xaxis3":{},"yaxis3":{},"scene4":{"domain":{"row":1,"column":0}},"mapbox":{"style":"open-street-map","domain":{"row":1,"column":1}},"mapbox5":{"style":"open-street-map","domain":{"row":1,"column":1}},"xaxis6":{},"yaxis6":{},"grid":{"rows":2,"columns":3,"pattern":"independent"},"width":1000,"height":1000};""" + """var layout = {"xaxis":{},"yaxis":{},"scene2":{"domain":{"row":0,"column":1}},"polar3":{"domain":{"row":0,"column":2}},"geo4":{"domain":{"row":1,"column":0}},"mapbox":{"style":"open-street-map","domain":{"row":1,"column":1}},"mapbox5":{"style":"open-street-map","domain":{"row":1,"column":1}},"ternary6":{"domain":{"row":1,"column":2}},"xaxis7":{},"yaxis7":{},"smith9":{"domain":{"row":2,"column":2}},"xaxis10":{},"yaxis10":{},"grid":{"rows":4,"columns":3,"pattern":"independent"},"width":1000,"height":1000};""" |> chartGeneratedContains multiTraceGrid ); testCase "Single Stack data" ( fun () -> diff --git a/tests/Plotly.NET.Tests/HtmlCodegen/Charts3D.fs b/tests/Plotly.NET.Tests/HtmlCodegen/Charts3D.fs index d9a363065..50c7b1523 100644 --- a/tests/Plotly.NET.Tests/HtmlCodegen/Charts3D.fs +++ b/tests/Plotly.NET.Tests/HtmlCodegen/Charts3D.fs @@ -271,12 +271,12 @@ let streamTubeChart = [] let ``StreamTube charts`` = - testList "StreamTube.Volume charts" [ - testCase "Volume data" ( fun () -> + testList "Charts3D.StreamTube charts" [ + testCase "StreamTube data" ( fun () -> """var data = [{"type":"streamtube","x":[0,0,0],"y":[0,1,2],"z":[0,0,0],"u":[0,0,0],"v":[1,1,1],"w":[0,0,0],"colorscale":"Viridis"}];""" |> chartGeneratedContains streamTubeChart ); - testCase "Volume layout" ( fun () -> + testCase "StreamTube layout" ( fun () -> emptyLayout streamTubeChart ); ] diff --git a/tests/Plotly.NET.Tests/HtmlCodegen/SmithCharts.fs b/tests/Plotly.NET.Tests/HtmlCodegen/SmithCharts.fs new file mode 100644 index 000000000..7d1604b18 --- /dev/null +++ b/tests/Plotly.NET.Tests/HtmlCodegen/SmithCharts.fs @@ -0,0 +1,95 @@ +module Tests.SmithCharts + +open Expecto +open Plotly.NET +open Plotly.NET.LayoutObjects +open Plotly.NET.TraceObjects +open Plotly.NET.GenericChart +open System + +open TestUtils.HtmlCodegen + +let scatterSmithChart = + Chart.ScatterSmith( + [0.5; 1.; 2.; 3.], + [0.5; 1.; 2.; 3.], + StyleParam.Mode.Lines_Markers_Text, + MultiText = ["Pretty"; "Cool"; "Plot"; "Huh?"], + TextPosition = StyleParam.TextPosition.TopCenter, + UseDefaults = false + ) + +let pointSmithChart = + Chart.PointSmith( + [0.5; 1.; 2.; 3.], + [0.5; 1.; 2.; 3.], + UseDefaults = false + ) + +let lineSmithChart = + Chart.LineSmith( + [0.5; 1.; 2.; 3.], + [0.5; 1.; 2.; 3.], + LineDash = StyleParam.DrawingStyle.DashDot, + LineColor = Color.fromKeyword Purple, + UseDefaults = false + ) + +let bubbleSmithChart = + Chart.BubbleSmith( + [0.5; 1.; 2.; 3.], + [0.5; 1.; 2.; 3.], + sizes = [10;20;30;40], + MultiText=["one";"two";"three";"four";"five";"six";"seven"], + TextPosition=StyleParam.TextPosition.TopCenter, + UseDefaults = false + ) + + +[] +let ``Smith Scatter charts`` = + testList "SmithCharts.Scatter charts" [ + testCase "Scatter data" ( fun () -> + """var data = [{"type":"scattersmith","mode":"lines+markers+text","imag":[0.5,1.0,2.0,3.0],"real":[0.5,1.0,2.0,3.0],"text":["Pretty","Cool","Plot","Huh?"],"textposition":"top center","marker":{},"line":{}}];""" + |> chartGeneratedContains scatterSmithChart + ) + testCase "Scatter layout" ( fun () -> + emptyLayout scatterSmithChart + ) + ] + +[] +let ``Smith Point charts`` = + testList "SmithCharts.Point charts" [ + testCase "Point data" ( fun () -> + """var data = [{"type":"scattersmith","mode":"markers","imag":[0.5,1.0,2.0,3.0],"real":[0.5,1.0,2.0,3.0],"marker":{},"line":{}}];""" + |> chartGeneratedContains pointSmithChart + ) + testCase "Point layout" ( fun () -> + emptyLayout pointSmithChart + ) + ] + +[] +let ``Smith Line charts`` = + testList "SmithCharts.Line charts" [ + testCase "Line data" ( fun () -> + """var data = [{"type":"scattersmith","mode":"lines","imag":[0.5,1.0,2.0,3.0],"real":[0.5,1.0,2.0,3.0],"marker":{},"line":{"color":"rgba(128, 0, 128, 1.0)","dash":"dashdot"}}];""" + |> chartGeneratedContains lineSmithChart + ) + testCase "Line layout" ( fun () -> + emptyLayout lineSmithChart + ) + ] + +[] +let ``Smith Bubble charts`` = + testList "SmithCharts.Bubble charts" [ + testCase "Bubble data" ( fun () -> + """var data = [{"type":"scattersmith","mode":"markers+text","imag":[0.5,1.0,2.0,3.0],"real":[0.5,1.0,2.0,3.0],"text":["one","two","three","four","five","six","seven"],"textposition":"top center","marker":{"size":[10,20,30,40]},"line":{}}];""" + |> chartGeneratedContains bubbleSmithChart + ) + testCase "Bubble layout" ( fun () -> + emptyLayout bubbleSmithChart + ) + ] \ No newline at end of file diff --git a/tests/Plotly.NET.Tests/Plotly.NET.Tests.fsproj b/tests/Plotly.NET.Tests/Plotly.NET.Tests.fsproj index 8ba058014..4cf0e227e 100644 --- a/tests/Plotly.NET.Tests/Plotly.NET.Tests.fsproj +++ b/tests/Plotly.NET.Tests/Plotly.NET.Tests.fsproj @@ -29,6 +29,7 @@ +