diff --git a/Plotly.NET.sln b/Plotly.NET.sln index da836e59c..873566a31 100644 --- a/Plotly.NET.sln +++ b/Plotly.NET.sln @@ -90,6 +90,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{7B09CC0A-F docs\09_2_sankey.fsx = docs\09_2_sankey.fsx docs\10_0_ternary_line_scatter_plots.fsx = docs\10_0_ternary_line_scatter_plots.fsx 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\_template.fsx = docs\_template.fsx docs\_template.html = docs\_template.html docs\_template.ipynb = docs\_template.ipynb diff --git a/docs/10_0_ternary_line_scatter_plots.fsx b/docs/10_0_ternary_line_scatter_plots.fsx index 668ca0c73..ea396636e 100644 --- a/docs/10_0_ternary_line_scatter_plots.fsx +++ b/docs/10_0_ternary_line_scatter_plots.fsx @@ -60,14 +60,14 @@ Ternary plots are tools for analyzing compositional data in the three-dimensiona use `Chart.PointTernary` to create a ternary plot that displays points on a ternary coordinate system: *) -let ternaryPolar = Chart.PointTernary(a,b,c) +let ternaryPoint = Chart.PointTernary(a,b,c) (*** condition: ipynb ***) #if IPYNB -ternaryPolar +ternaryPoint #endif // IPYNB (***hide***) -ternaryPolar |> GenericChart.toChartHTML +ternaryPoint |> GenericChart.toChartHTML (***include-it-raw***) (** diff --git a/docs/11_1_carpet_line_scatter_plots.fsx b/docs/11_1_carpet_line_scatter_plots.fsx new file mode 100644 index 000000000..25b706356 --- /dev/null +++ b/docs/11_1_carpet_line_scatter_plots.fsx @@ -0,0 +1,168 @@ +(** +--- +title: Carpet line and scatter plots +category: Carpet Plots +categoryindex: 12 +index: 1 +--- +*) + +(*** hide ***) + +(*** condition: prepare ***) +#r "nuget: Newtonsoft.JSON, 12.0.3" +#r "nuget: DynamicObj" +#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 + +(** +# Carpet 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 carpet charts in F#. + +let's first create some data for the purpose of creating example charts: + +*) + +open Plotly.NET + +//carpet coordinate data +let a = [4.; 4.; 4.; 4.5; 4.5; 4.5; 5.; 5.; 5.; 6.; 6.; 6.] +let b = [1.; 2.; 3.; 1.; 2.; 3.; 1.; 2.; 3.; 1.; 2.; 3.] +let y = [2.; 3.5; 4.; 3.; 4.5; 5.; 5.5; 6.5; 7.5; 8.; 8.5; 10.] + +//carpet plot data +let aData = [4.; 5.; 5.; 6.] +let bData = [1.; 1.; 2.; 3.] +let sizes = [5; 10; 15; 20] + +(** +A carpet plot is any of a few different specific types of plot. The more common plot referred to as a carpet plot is one that illustrates the interaction between two or more independent variables and one or more dependent variables in a two-dimensional plot. + +Besides the ability to incorporate more variables, another feature that distinguishes a carpet plot from an equivalent contour plot or 3D surface plot is that a carpet plot can be used to more accurately interpolate data points. + +A conventional carpet plot can capture the interaction of up to three independent variables and three dependent variables and still be easily read and interpolated. + +Carpet plots have common applications within areas such as material science for showing elastic modulus in laminates,and within aeronautics. + +A carpet plot with two independent variables and one dependent variable is often called a cheater plot for the use of a phantom "cheater" axis instead of the horizontal axis. + +(https://en.wikipedia.org/wiki/Carpet_plot) + +## Carpet Traces + +In plotly, carpet plots are different to all other trace types in the regard that the coordinate system of the carpet is not set on the layout, but is itself a trace. + +Use `Chart.Carpet` to define these `coordinate traces`. All carpets have a mandatory identifier, which will be used by other traces to define which carpet coordinate system to use. +*) + +let carpet = Chart.Carpet("carpetIdentifier", A = a, B = b, Y = y) + +(*** condition: ipynb ***) +#if IPYNB +carpet +#endif // IPYNB + +(***hide***) +carpet |> GenericChart.toChartHTML +(***include-it-raw***) + +(** +## Carpet point charts + +use `Chart.PointCarpet` to create a point plot on the referenced carpet coordinate system: +*) +let carpetPoint = + [ + carpet + Chart.PointCarpet(aData,bData,"carpetIdentifier", Name = "Point") + ] + |> Chart.combine + +(*** condition: ipynb ***) +#if IPYNB +carpetPoint +#endif // IPYNB + +(***hide***) +carpetPoint |> GenericChart.toChartHTML +(***include-it-raw***) + +(** +## Carpet line charts + +use `Chart.LineCarpet` to create a line plot on the referenced carpet coordinate system: +*) + +let carpetLine = + [ + carpet + Chart.LineCarpet(aData,bData,"carpetIdentifier",Name = "Line") + ] + |> Chart.combine + +(*** condition: ipynb ***) +#if IPYNB +carpetLine +#endif // IPYNB + +(***hide***) +carpetLine |> GenericChart.toChartHTML +(***include-it-raw***) + +(** +## Carpet Spline charts + +use `Chart.LineCarpet` to create a spline plot on the referenced carpet coordinate system: +*) + +let carpetSpline = + [ + carpet + Chart.SplineCarpet(aData,bData,"carpetIdentifier",Name = "Spline") + ] + |> Chart.combine + +(*** condition: ipynb ***) +#if IPYNB +carpetSpline +#endif // IPYNB + +(***hide***) +carpetSpline |> GenericChart.toChartHTML +(***include-it-raw***) + +(** +## Carpet bubble charts + +use `Chart.LineCarpet` to create a bubble plot on the referenced carpet coordinate system: +*) + +let carpetBubble = + [ + carpet + Chart.BubbleCarpet((Seq.zip3 aData bData sizes),"carpetIdentifier",Name = "Bubble") + ] + |> Chart.combine + +(*** condition: ipynb ***) +#if IPYNB +carpetBubble +#endif // IPYNB + +(***hide***) +carpetBubble |> GenericChart.toChartHTML +(***include-it-raw***) + + + + diff --git a/docs/11_2_contourcarpet_plots.fsx b/docs/11_2_contourcarpet_plots.fsx new file mode 100644 index 000000000..a0d2a54eb --- /dev/null +++ b/docs/11_2_contourcarpet_plots.fsx @@ -0,0 +1,74 @@ +(** +--- +title: Contour carpet plots +category: Carpet Plots +categoryindex: 12 +index: 2 +--- +*) + +(*** hide ***) + +(*** condition: prepare ***) +#r "nuget: Newtonsoft.JSON, 12.0.3" +#r "nuget: DynamicObj" +#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 + +(** +# Contour carpet 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 contour plots on carpets in F#. + +*) + +open Plotly.NET +open Plotly.NET.LayoutObjects + +let contourCarpet = + [ + 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 + ) + ) + Chart.ContourCarpet( + "contour", + [1.; 1.96; 2.56; 3.0625; 4.; 5.0625; 1.; 7.5625; 9.; 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] + ) + ] + |> Chart.combine + +(*** condition: ipynb ***) +#if IPYNB +contourCarpet +#endif // IPYNB + +(***hide***) +contourCarpet |> GenericChart.toChartHTML +(***include-it-raw***) \ No newline at end of file diff --git a/src/Plotly.NET/ChartAPI/Chart.fs b/src/Plotly.NET/ChartAPI/Chart.fs index 5d3518784..43b5feccb 100644 --- a/src/Plotly.NET/ChartAPI/Chart.fs +++ b/src/Plotly.NET/ChartAPI/Chart.fs @@ -170,7 +170,7 @@ type Chart = ?MultiOpacity = MultiOpacity, ?Pattern = Pattern, ?Symbol = Symbol , - ?MultiSymbols = MultiSymbols , + ?MultiSymbol = MultiSymbols , ?OutlierColor = OutlierColor , ?Maxdisplayed = Maxdisplayed , ?ReverseScale = ReverseScale , diff --git a/src/Plotly.NET/ChartAPI/ChartCarpet.fs b/src/Plotly.NET/ChartAPI/ChartCarpet.fs new file mode 100644 index 000000000..a7cd53f2b --- /dev/null +++ b/src/Plotly.NET/ChartAPI/ChartCarpet.fs @@ -0,0 +1,681 @@ +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 ChartCarpet = + + [] + type Chart = + + /// Shows how proportions of data, shown as pie-shaped pieces, contribute to the data. + [] + static member Carpet + ( + carpetId: string, + [] ?Name : string, + [] ?ShowLegend : bool, + [] ?Opacity : float, + [] ?X : seq<#IConvertible>, + [] ?MultiX : seq<#seq<#IConvertible>>, + [] ?Y : seq<#IConvertible>, + [] ?MultiY : seq<#seq<#IConvertible>>, + [] ?A : seq<#IConvertible>, + [] ?B : seq<#IConvertible>, + [] ?AAxis : LinearAxis, + [] ?BAxis : LinearAxis, + [] ?XAxis : StyleParam.LinearAxisId, + [] ?YAxis : StyleParam.LinearAxisId, + [] ?Color : Color, + [] ?CheaterSlope : float + ) = + TraceCarpet.initCarpet( + TraceCarpetStyle.Carpet( + Carpet = StyleParam.SubPlotId.Carpet carpetId, + ?Name = Name , + ?ShowLegend = ShowLegend , + ?Opacity = Opacity , + ?X = X , + ?MultiX = MultiX , + ?Y = Y , + ?MultiY = MultiY , + ?A = A , + ?B = B , + ?AAxis = AAxis , + ?BAxis = BAxis , + ?XAxis = XAxis , + ?YAxis = YAxis , + ?Color = Color , + ?CheaterSlope = CheaterSlope + ) + ) + |> GenericChart.ofTraceObject + + [] + static member ScatterCarpet + ( + a : seq<#IConvertible>, + b : seq<#IConvertible>, + mode : StyleParam.Mode, + carpetAnchorId : string, + [] ?Name : string, + [] ?ShowLegend : bool, + [] ?MarkerSymbol : StyleParam.MarkerSymbol, + [] ?MultiMarkerSymbol : seq, + [] ?Color : Color, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?TextPosition : StyleParam.TextPosition, + [] ?MultiTextPosition : seq, + [] ?TextFont : Font, + [] ?Size : int, + [] ?MultiSize : seq, + [] ?Marker : Marker, + [] ?Dash : StyleParam.DrawingStyle, + [] ?Width : float , + [] ?Line : Line + ) = + TraceCarpet.initScatterCarpet( + TraceCarpetStyle.ScatterCarpet( + A = a, + B = b, + Mode = mode, + Carpet = (carpetAnchorId |> StyleParam.SubPlotId.Carpet), + ?Name = Name , + ?ShowLegend = ShowLegend , + ?Opacity = Opacity , + ?Text = Text , + ?MultiText = MultiText , + ?TextPosition = TextPosition , + ?MultiTextPosition = MultiTextPosition, + ?TextFont = TextFont , + ?Marker = Marker , + ?Line = Line + ) + >> TraceStyle.Marker( + ?Symbol = MarkerSymbol , + ?MultiSymbol = MultiMarkerSymbol, + ?Color = Color , + ?Opacity = Opacity , + ?MultiOpacity = MultiOpacity , + ?Size = Size, + ?MultiSize = MultiSize + ) + >> TraceStyle.Line( + ?Dash = Dash, + ?Width = Width, + ?Color = Color + ) + + ) + |> GenericChart.ofTraceObject + + [] + static member ScatterCarpet + ( + ab : seq<#IConvertible*#IConvertible>, + mode : StyleParam.Mode, + carpetAnchorId : string, + [] ?Name : string, + [] ?ShowLegend : bool, + [] ?MarkerSymbol : StyleParam.MarkerSymbol, + [] ?MultiMarkerSymbol : seq, + [] ?Color : Color, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?TextPosition : StyleParam.TextPosition, + [] ?MultiTextPosition : seq, + [] ?TextFont : Font, + [] ?Size : int, + [] ?MultiSize : seq, + [] ?Marker : Marker, + [] ?Dash : StyleParam.DrawingStyle, + [] ?Width : float , + [] ?Line : Line + ) = + let a,b = Seq.unzip ab + + Chart.ScatterCarpet( + a, b, mode, carpetAnchorId, + ?Name = Name , + ?ShowLegend = ShowLegend , + ?MarkerSymbol = MarkerSymbol , + ?MultiMarkerSymbol = MultiMarkerSymbol, + ?Color = Color , + ?Opacity = Opacity , + ?MultiOpacity = MultiOpacity , + ?Text = Text , + ?MultiText = MultiText , + ?TextPosition = TextPosition , + ?MultiTextPosition = MultiTextPosition, + ?TextFont = TextFont , + ?Size = Size , + ?MultiSize = MultiSize , + ?Marker = Marker , + ?Dash = Dash , + ?Width = Width , + ?Line = Line + ) + + + [] + static member PointCarpet + ( + a : seq<#IConvertible>, + b : seq<#IConvertible>, + carpetAnchorId : string, + [] ?Name : string, + [] ?ShowLegend : bool, + [] ?MarkerSymbol : StyleParam.MarkerSymbol, + [] ?MultiMarkerSymbol : seq, + [] ?Color : Color, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?TextPosition : StyleParam.TextPosition, + [] ?MultiTextPosition : seq, + [] ?TextFont : Font, + [] ?Size : int, + [] ?MultiSize : seq, + [] ?Marker : Marker + ) = + + let changeMode = StyleParam.ModeUtils.showText (TextPosition.IsSome || TextFont.IsSome) + + TraceCarpet.initScatterCarpet( + TraceCarpetStyle.ScatterCarpet( + A = a, + B = b, + Mode = changeMode StyleParam.Mode.Markers, + Carpet = (carpetAnchorId |> StyleParam.SubPlotId.Carpet), + ?Name = Name , + ?ShowLegend = ShowLegend , + ?Opacity = Opacity , + ?Text = Text , + ?MultiText = MultiText , + ?TextPosition = TextPosition , + ?MultiTextPosition = MultiTextPosition, + ?TextFont = TextFont , + ?Marker = Marker + ) + >> TraceStyle.Marker( + ?Symbol = MarkerSymbol , + ?MultiSymbol = MultiMarkerSymbol, + ?Color = Color , + ?Opacity = Opacity , + ?MultiOpacity = MultiOpacity , + ?Size = Size , + ?MultiSize = MultiSize + ) + ) + |> GenericChart.ofTraceObject + + [] + static member PointCarpet + ( + ab : seq<#IConvertible*#IConvertible>, + carpetAnchorId : string, + [] ?Name : string, + [] ?ShowLegend : bool, + [] ?MarkerSymbol : StyleParam.MarkerSymbol, + [] ?MultiMarkerSymbol : seq, + [] ?Color : Color, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?TextPosition : StyleParam.TextPosition, + [] ?MultiTextPosition : seq, + [] ?TextFont : Font, + [] ?Size : int, + [] ?MultiSize : seq, + [] ?Marker : Marker + ) = + + let a,b = Seq.unzip ab + + Chart.PointCarpet( + a, b, carpetAnchorId, + ?Name = Name , + ?ShowLegend = ShowLegend , + ?MarkerSymbol = MarkerSymbol , + ?MultiMarkerSymbol = MultiMarkerSymbol , + ?Color = Color , + ?Opacity = Opacity , + ?MultiOpacity = MultiOpacity , + ?Text = Text , + ?MultiText = MultiText , + ?TextPosition = TextPosition , + ?MultiTextPosition = MultiTextPosition , + ?TextFont = TextFont , + ?Size = Size , + ?MultiSize = MultiSize , + ?Marker = Marker + ) + + [] + static member LineCarpet + ( + a : seq<#IConvertible>, + b : seq<#IConvertible>, + carpetAnchorId : string, + [] ?Name : string, + [] ?ShowMarkers : bool, + [] ?Dash : StyleParam.DrawingStyle, + [] ?Width : float , + [] ?Line : Line, + [] ?ShowLegend : bool, + [] ?MarkerSymbol : StyleParam.MarkerSymbol, + [] ?MultiMarkerSymbol : seq, + [] ?Color : Color, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?TextPosition : StyleParam.TextPosition, + [] ?MultiTextPosition : seq, + [] ?TextFont : Font, + [] ?Size : int, + [] ?MultiSize : seq, + [] ?Marker : Marker + ) = + + let changeMode = + let isShowMarker = + match ShowMarkers with + | Some isShow -> isShow + | Option.None -> false + StyleParam.ModeUtils.showText (TextPosition.IsSome || TextFont.IsSome) + >> StyleParam.ModeUtils.showMarker (isShowMarker) + + TraceCarpet.initScatterCarpet( + TraceCarpetStyle.ScatterCarpet( + A = a, + B = b, + Mode = changeMode StyleParam.Mode.Lines, + Carpet = (carpetAnchorId |> StyleParam.SubPlotId.Carpet), + ?Name = Name , + ?ShowLegend = ShowLegend , + ?Opacity = Opacity , + ?Text = Text , + ?MultiText = MultiText , + ?TextPosition = TextPosition , + ?MultiTextPosition = MultiTextPosition, + ?TextFont = TextFont , + ?Marker = Marker , + ?Line = Line + ) + >> TraceStyle.Marker( + ?Symbol = MarkerSymbol , + ?MultiSymbol = MultiMarkerSymbol, + ?Color = Color , + ?Opacity = Opacity , + ?MultiOpacity = MultiOpacity , + ?Size = Size , + ?MultiSize = MultiSize + ) + >> TraceStyle.Line( + ?Dash = Dash, + ?Width = Width, + ?Color = Color + ) + ) + |> GenericChart.ofTraceObject + + [] + static member LineCarpet + ( + ab : seq<#IConvertible*#IConvertible>, + carpetAnchorId : string, + [] ?Name : string, + [] ?ShowMarkers : bool, + [] ?Dash : StyleParam.DrawingStyle, + [] ?Width : float , + [] ?Line : Line, + [] ?ShowLegend : bool, + [] ?MarkerSymbol : StyleParam.MarkerSymbol, + [] ?MultiMarkerSymbol : seq, + [] ?Color : Color, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?TextPosition : StyleParam.TextPosition, + [] ?MultiTextPosition : seq, + [] ?TextFont : Font, + [] ?Size : int, + [] ?MultiSize : seq, + [] ?Marker : Marker + ) = + + let a,b = Seq.unzip ab + + Chart.LineCarpet( + a, b, carpetAnchorId, + ?Name = Name , + ?ShowMarkers = ShowMarkers , + ?Dash = Dash , + ?Width = Width , + ?Line = Line , + ?ShowLegend = ShowLegend , + ?MarkerSymbol = MarkerSymbol , + ?MultiMarkerSymbol = MultiMarkerSymbol , + ?Color = Color , + ?Opacity = Opacity , + ?MultiOpacity = MultiOpacity , + ?Text = Text , + ?MultiText = MultiText , + ?TextPosition = TextPosition , + ?MultiTextPosition = MultiTextPosition , + ?TextFont = TextFont , + ?Size = Size , + ?MultiSize = MultiSize , + ?Marker = Marker + ) + + [] + static member SplineCarpet + ( + a : seq<#IConvertible>, + b : seq<#IConvertible>, + carpetAnchorId : string, + [] ?Name : string, + [] ?ShowMarkers : bool, + [] ?Dash : StyleParam.DrawingStyle, + [] ?Width : float , + [] ?Smoothing : float, + [] ?Line : Line, + [] ?ShowLegend : bool, + [] ?MarkerSymbol : StyleParam.MarkerSymbol, + [] ?MultiMarkerSymbol : seq, + [] ?Color : Color, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?TextPosition : StyleParam.TextPosition, + [] ?MultiTextPosition : seq, + [] ?TextFont : Font, + [] ?Size : int, + [] ?MultiSize : seq, + [] ?Marker : Marker + ) = + + let changeMode = + let isShowMarker = + match ShowMarkers with + | Some isShow -> isShow + | Option.None -> false + StyleParam.ModeUtils.showText (TextPosition.IsSome || TextFont.IsSome) + >> StyleParam.ModeUtils.showMarker (isShowMarker) + + TraceCarpet.initScatterCarpet( + TraceCarpetStyle.ScatterCarpet( + A = a, + B = b, + Mode = changeMode StyleParam.Mode.Lines, + Carpet = (carpetAnchorId |> StyleParam.SubPlotId.Carpet), + ?Name = Name , + ?ShowLegend = ShowLegend , + ?Opacity = Opacity , + ?Text = Text , + ?MultiText = MultiText , + ?TextPosition = TextPosition , + ?MultiTextPosition = MultiTextPosition, + ?TextFont = TextFont , + ?Marker = Marker , + ?Line = Line + ) + >> TraceStyle.Marker( + ?Symbol = MarkerSymbol , + ?MultiSymbol = MultiMarkerSymbol, + ?Color = Color , + ?Opacity = Opacity , + ?MultiOpacity = MultiOpacity , + ?Size = Size , + ?MultiSize = MultiSize + ) + >> TraceStyle.Line( + ?Color = Color, + ?Dash = Dash, + ?Width = Width, + Shape = StyleParam.Shape.Spline, + ?Smoothing = Smoothing + ) + ) + |> GenericChart.ofTraceObject + + [] + static member SplineCarpet + ( + ab : seq<#IConvertible*#IConvertible>, + carpetAnchorId : string, + [] ?Name : string, + [] ?ShowMarkers : bool, + [] ?Dash : StyleParam.DrawingStyle, + [] ?Width : float , + [] ?Smoothing : float, + [] ?Line : Line, + [] ?ShowLegend : bool, + [] ?MarkerSymbol : StyleParam.MarkerSymbol, + [] ?MultiMarkerSymbol : seq, + [] ?Color : Color, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?TextPosition : StyleParam.TextPosition, + [] ?MultiTextPosition : seq, + [] ?TextFont : Font, + [] ?Size : int, + [] ?MultiSize : seq, + [] ?Marker : Marker + ) = + + let a,b = Seq.unzip ab + + Chart.SplineCarpet( + a, b, carpetAnchorId, + ?Name = Name , + ?ShowMarkers = ShowMarkers , + ?Dash = Dash , + ?Width = Width , + ?Smoothing = Smoothing , + ?Line = Line , + ?ShowLegend = ShowLegend , + ?MarkerSymbol = MarkerSymbol , + ?MultiMarkerSymbol = MultiMarkerSymbol , + ?Color = Color , + ?Opacity = Opacity , + ?MultiOpacity = MultiOpacity , + ?Text = Text , + ?MultiText = MultiText , + ?TextPosition = TextPosition , + ?MultiTextPosition = MultiTextPosition , + ?TextFont = TextFont , + ?Size = Size , + ?MultiSize = MultiSize , + ?Marker = Marker + ) + + static member BubbleCarpet + ( + a : seq<#IConvertible>, + b : seq<#IConvertible>, + sizes : seq, + carpetAnchorId : string, + [] ?Name : string, + [] ?ShowLegend : bool, + [] ?MarkerSymbol : StyleParam.MarkerSymbol, + [] ?MultiMarkerSymbol : seq, + [] ?Color : Color, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?TextPosition : StyleParam.TextPosition, + [] ?MultiTextPosition : seq, + [] ?TextFont : Font, + [] ?Marker : Marker + ) = + Chart.PointCarpet( + a,b,carpetAnchorId, + MultiSize = sizes, + ?Name = Name , + ?ShowLegend = ShowLegend , + ?MarkerSymbol = MarkerSymbol , + ?MultiMarkerSymbol = MultiMarkerSymbol, + ?Color = Color , + ?Opacity = Opacity , + ?MultiOpacity = MultiOpacity , + ?Text = Text , + ?MultiText = MultiText , + ?TextPosition = TextPosition , + ?MultiTextPosition = MultiTextPosition, + ?TextFont = TextFont , + ?Marker = Marker + ) + + static member BubbleCarpet + ( + absizes : seq<#IConvertible*#IConvertible*int>, + carpetAnchorId : string, + [] ?Name : string, + [] ?ShowLegend : bool, + [] ?MarkerSymbol : StyleParam.MarkerSymbol, + [] ?MultiMarkerSymbol : seq, + [] ?Color : Color, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?TextPosition : StyleParam.TextPosition, + [] ?MultiTextPosition : seq, + [] ?TextFont : Font, + [] ?Marker : Marker + ) = + + let a,b,sizes = Seq.unzip3 absizes + + Chart.PointCarpet( + a,b,carpetAnchorId, + MultiSize = sizes, + ?Name = Name , + ?ShowLegend = ShowLegend , + ?MarkerSymbol = MarkerSymbol , + ?MultiMarkerSymbol = MultiMarkerSymbol, + ?Color = Color , + ?Opacity = Opacity , + ?MultiOpacity = MultiOpacity , + ?Text = Text , + ?MultiText = MultiText , + ?TextPosition = TextPosition , + ?MultiTextPosition = MultiTextPosition, + ?TextFont = TextFont , + ?Marker = Marker + ) + + static member ContourCarpet + ( + carpetAnchorId : string, + z : seq<#IConvertible>, + [] ?Name : string, + [] ?ShowLegend: bool, + [] ?Opacity : float, + [] ?A : seq<#IConvertible>, + [] ?B : seq<#IConvertible>, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?Dash : StyleParam.DrawingStyle, + [] ?Width : float , + [] ?LineColor : Color , + [] ?Line : Line, + [] ?ColorScale: StyleParam.Colorscale, + [] ?ShowScale : bool, + [] ?Contours : Contours + ) = + TraceCarpet.initContourCarpet( + TraceCarpetStyle.ContourCarpet ( + Carpet = StyleParam.SubPlotId.Carpet carpetAnchorId, + ?Name = Name , + ?ShowLegend = ShowLegend , + ?Opacity = Opacity , + Z = z , + ?A = A , + ?B = B , + ?Text = Text , + ?MultiText = MultiText , + ?Line = Line , + ?ColorScale = ColorScale , + ?ShowScale = ShowScale , + ?Contours = Contours + ) + >> TraceStyle.Line( + ?Dash = Dash , + ?Width = Width , + ?Color = LineColor + ) + ) + |> GenericChart.ofTraceObject + + + static member ContourCarpet + ( + carpetAnchorId : string, + abz : seq<#IConvertible * #IConvertible * #IConvertible>, + [] ?Name : string, + [] ?ShowLegend: bool, + [] ?Opacity : float, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?Dash : StyleParam.DrawingStyle, + [] ?Width : float , + [] ?LineColor : Color , + [] ?Line : Line, + [] ?ColorScale: StyleParam.Colorscale, + [] ?ShowScale : bool, + [] ?Contours : Contours + ) = + + let a,b,z = Seq.unzip3 abz + + TraceCarpet.initContourCarpet( + TraceCarpetStyle.ContourCarpet ( + Carpet = StyleParam.SubPlotId.Carpet carpetAnchorId, + ?Name = Name , + ?ShowLegend = ShowLegend , + ?Opacity = Opacity , + Z = z , + A = a , + B = b , + ?Text = Text , + ?MultiText = MultiText , + ?Line = Line , + ?ColorScale = ColorScale , + ?ShowScale = ShowScale , + ?Contours = Contours + ) + >> TraceStyle.Line( + ?Dash = Dash , + ?Width = Width , + ?Color = LineColor + ) + ) + |> GenericChart.ofTraceObject + + \ No newline at end of file diff --git a/src/Plotly.NET/CommonAbstractions/StyleParams.fs b/src/Plotly.NET/CommonAbstractions/StyleParams.fs index e518b352f..953430e5b 100644 --- a/src/Plotly.NET/CommonAbstractions/StyleParams.fs +++ b/src/Plotly.NET/CommonAbstractions/StyleParams.fs @@ -136,6 +136,7 @@ module StyleParam = | Polar of int | Ternary of int | Scene of int + | Carpet of string static member toString = function | XAxis id -> if id < 2 then "xaxis" else sprintf "xaxis%i" id @@ -146,6 +147,7 @@ module StyleParam = | Polar id -> if id < 2 then "polar" else sprintf "polar%i" id | Ternary id -> if id < 2 then "ternary" else sprintf "ternary%i" id | Scene id -> if id < 2 then "scene" else sprintf "scene%i" id + | Carpet id -> id static member convert = SubPlotId.toString >> box override this.ToString() = this |> SubPlotId.toString @@ -315,6 +317,32 @@ module StyleParam = //-------------------------- + [] + type CoordinateType = + | Array + | Scaled + + static member toString = function + | Array -> "array" + | Scaled -> "scaled" + + static member convert = CoordinateType.toString >> box + override this.ToString() = this |> CoordinateType.toString + member this.Convert() = this |> CoordinateType.convert + + [] + type CheaterType = + | Index + | Value + + static member toString = function + | Index -> "index" + | Value -> "value" + + static member convert = CheaterType.toString >> box + override this.ToString() = this |> CheaterType.toString + member this.Convert() = this |> CheaterType.convert + [] type ColorModel = | RGB diff --git a/src/Plotly.NET/InternalUtils.fs b/src/Plotly.NET/InternalUtils.fs index 6696fac8d..6d39600ff 100644 --- a/src/Plotly.NET/InternalUtils.fs +++ b/src/Plotly.NET/InternalUtils.fs @@ -17,3 +17,16 @@ module internal InternalUtils multi |> DynObj.setValueOptBy dyn propName (Seq.map f) else single |> DynObj.setValueOptBy dyn propName f + + let setSingleOrAnyOpt (dyn:#DynamicObj) (propName:string) (single:'A option, any:'B option) = + if any.IsSome then + any |> DynObj.setValueOpt dyn propName + else + single |> DynObj.setValueOpt dyn propName + + let setSingleOrAnyOptBy (dyn:#DynamicObj) (propName:string) (singleF:'A -> 'C) (anyF:'B -> 'D) (single:'A option, any:'B option) = + if any.IsSome then + any |> DynObj.setValueOptBy dyn propName anyF + else + single |> DynObj.setValueOptBy dyn propName singleF + diff --git a/src/Plotly.NET/Layout/ObjectAbstractions/Common/LinearAxis.fs b/src/Plotly.NET/Layout/ObjectAbstractions/Common/LinearAxis.fs index 6423c4dc9..b826f2f35 100644 --- a/src/Plotly.NET/Layout/ObjectAbstractions/Common/LinearAxis.fs +++ b/src/Plotly.NET/Layout/ObjectAbstractions/Common/LinearAxis.fs @@ -479,7 +479,174 @@ type LinearAxis () = ?RangeSelector = RangeSelector , ?Calendar = Calendar ) + /// + /// Initialize a LinearAxis object that can be used as a positional scale for Y, X or Z 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 axis title. + /// Sets the axis type. By default, plotly attempts to determined the axis type by looking into the data of the traces that referenced the axis in question. + /// Using "strict" a numeric string in trace data is not converted to a number. Using "convert types" a numeric string in trace data may be treated as a number during automatic axis `type` detection. Defaults to layout.autotypenumbers. + /// Determines whether or not the range of this axis is computed in relation to the input data. See `rangemode` for more info. If `range` is provided, then `autorange` is set to "false". + /// If "normal", the range is computed in relation to the extrema of the input data. If "tozero"`, the range extends to 0, regardless of the input data If "nonnegative", the range is non-negative, regardless of the input data. Applies only to linear axes. + /// Sets the range of this axis. If the axis `type` is "log", then you must take the log of your desired range (e.g. to set the range from 1 to 100, set the range from 0 to 2). If the axis `type` is "date", it should be date strings, like date data, though Date objects and unix milliseconds will be accepted and converted to strings. If the axis `type` is "category", it should be numbers, using the scale where each category is assigned a serial number from zero in the order it appears. + /// Determines whether or not this axis is zoom-able. If true, then zoom is disabled. + /// Sets the tick mode for this axis. If "auto", the number of ticks is set via `nticks`. If "linear", the placement of the ticks is determined by a starting position `tick0` and a tick step `dtick` ("linear" is the default value if `tick0` and `dtick` are provided). If "array", the placement of the ticks is set via `TickVals` and the tick text is `TickText`. ("array" is the default value if `TickVals` is provided). + /// Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to "auto". + /// Sets the placement of the first tick on this axis. Use with `dtick`. If the axis `type` is "log", then you must take the log of your starting tick (e.g. to set the starting tick to 100, set the `tick0` to 2) except when `dtick`="L<f>" (see `dtick` for more info). If the axis `type` is "date", it should be a date string, like date data. If the axis `type` is "category", it should be a number, using the scale where each category is assigned a serial number from zero in the order it appears. + /// Sets the step in-between ticks on this axis. Use with `tick0`. Must be a positive number, or special strings available to "log" and "date" axes. If the axis `type` is "log", then ticks are set every 10^(n"dtick) where n is the tick number. For example, to set a tick mark at 1, 10, 100, 1000, ... set dtick to 1. To set tick marks at 1, 100, 10000, ... set dtick to 2. To set tick marks at 1, 5, 25, 125, 625, 3125, ... set dtick to log_10(5), or 0.69897000433. "log" has several special values; "L<f>", where `f` is a positive number, gives ticks linearly spaced in value (but not position). For example `tick0` = 0.1, `dtick` = "L0.5" will put ticks at 0.1, 0.6, 1.1, 1.6 etc. To show powers of 10 plus small digits between, use "D1" (all digits) or "D2" (only 2 and 5). `tick0` is ignored for "D1" and "D2". If the axis `type` is "date", then you must convert the time to milliseconds. For example, to set the interval between ticks to one day, set `dtick` to 86400000.0. "date" also has special values "M<n>" gives ticks spaced by a number of months. `n` must be a positive integer. To set ticks on the 15th of every third month, set `tick0` to "2000-01-15" and `dtick` to "M3". To set ticks every 4 years, set `dtick` to "M48" + /// Sets the values at which ticks on this axis appear. Only has an effect if `tickmode` is set to "array". Used with `TickText`. + /// Sets the text displayed at the ticks position via `TickVals`. Only has an effect if `tickmode` is set to "array". Used with `TickVals`. + /// 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. + /// Determines whether or not the tick labels are drawn. + /// Sets the tick font. + /// Sets the angle of the tick labels with respect to the horizontal. For example, a `tickangle` of -90 draws the tick labels vertically. + /// 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. + /// Sets a tick label prefix. + /// Same as `showtickprefix` but for tick suffixes. + /// Sets a tick label suffix. + /// If "all", all exponents are shown besides their significands. If "first", only the exponent of the first tick is shown. If "last", only the exponent of the last tick is shown. If "none", no exponents appear. + /// Determines a formatting rule for the tick exponents. For example, consider the number 1,000,000,000. If "none", it appears as 1,000,000,000. If "e", 1e+9. If "E", 1E+9. If "power", 1x10^9 (with 9 in a super script). If "SI", 1G. If "B", 1B. + /// Hide SI prefix for 10^n if |n| is below this number. This only has an effect when `TickFormat` is "SI" or "B". + /// If "true", even 4-digit integers are separated + /// 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-3.x-api-reference/blob/master/Formatting.md#d3_format. And for dates see: https://github.com/d3/d3-time-format#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" + /// Set rules for customizing TickFormat on different zoom levels + /// Determines whether or not a line bounding this axis is drawn. + /// 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. + /// Sets the color of the grid lines. + /// Sets the width (in px) of the grid lines. + /// Specifies the ordering logic for the case of categorical variables. By default, plotly uses "trace", which specifies the order that is present in the data supplied. Set `categoryorder` to "category ascending" or "category descending" if order should be determined by the alphanumerical order of the category names. Set `categoryorder` to "array" to derive the ordering from the attribute `categoryarray`. If a category is not found in the `categoryarray` array, the sorting behavior for that attribute will be identical to the "trace" mode. The unspecified categories will follow the categories in `categoryarray`. Set `categoryorder` to "total ascending" or "total descending" if order should be determined by the numerical order of the values. Similarly, the order can be determined by the min, max, sum, mean or median of all the values. + /// Sets the order in which categories on this axis appear. Only has an effect if `categoryorder` is set to "array". Used with `categoryorder`. + // + /// The stride between grid lines along the axis + /// The starting index of grid lines along the axis + /// The type of cheater plot when interpreted as cheater plot + /// Determines whether or not a line is drawn at along the final value of this axis. If "true", the end line is drawn on top of the grid lines. + /// Sets the line color of the end line. + /// Sets the width (in px) of the end line. + /// Extra padding between label and the axis + /// Sets a axis label prefix. + /// Sets a axis label suffix. + /// Sets the color of the grid lines. + /// Sets the number of minor grid ticks per major grid tick + /// Sets the width (in px) of the grid lines. + /// Smoothing applied to the axis lines + /// Determines whether or not a line is drawn at along the starting value of this axis. If "true", the start line is drawn on top of the grid lines. + /// Sets the line color of the start line. + /// Sets the width (in px) of the start line. + static member initCarpet + ( + [] ?Color : Color, + [] ?Title : Title, + [] ?AxisType : StyleParam.AxisType, + [] ?AutoTypeNumbers : StyleParam.AutoTypeNumbers, + [] ?AutoRange : StyleParam.AutoRange, + [] ?RangeMode : StyleParam.RangeMode, + [] ?Range : StyleParam.Range, + [] ?FixedRange : bool, + [] ?TickMode : StyleParam.TickMode, + [] ?NTicks : int, + [] ?Tick0 : #IConvertible, + [] ?DTick : #IConvertible, + [] ?TickVals : seq<#IConvertible>, + [] ?TickText : seq<#IConvertible>, + [] ?Ticks : StyleParam.TickOptions, + [] ?ShowTickLabels : bool, + [] ?TickFont : Font, + [] ?TickAngle : int, + [] ?ShowTickPrefix : StyleParam.ShowTickOption, + [] ?TickPrefix : string, + [] ?ShowTickSuffix : StyleParam.ShowTickOption, + [] ?TickSuffix : string, + [] ?ShowExponent : StyleParam.ShowExponent, + [] ?ExponentFormat : StyleParam.ExponentFormat, + [] ?MinExponent : float, + [] ?SeparateThousands : bool, + [] ?TickFormat : string, + [] ?TickFormatStops : seq, + [] ?ShowLine : bool, + [] ?LineColor : Color, + [] ?LineWidth : float, + [] ?ShowGrid : bool, + [] ?GridColor : Color, + [] ?GridWidth : float, + [] ?CategoryOrder : StyleParam.CategoryOrder, + [] ?CategoryArray : seq<#IConvertible>, + [] ?ArrayDTick : int, + [] ?ArrayTick0 : int, + [] ?CheaterType : StyleParam.CheaterType, + [] ?EndLine : bool, + [] ?EndLineColor : Color, + [] ?EndLineWidth : int, + [] ?LabelPadding : int, + [] ?LabelPrefix : string, + [] ?LabelSuffix : string, + [] ?MinorGridColor : Color, + [] ?MinorGridCount : int, + [] ?MinorGridWidth : int, + [] ?Smoothing : float, + [] ?StartLine : bool, + [] ?StartLineColor : Color, + [] ?StartLineWidth : int + ) = + LinearAxis() + |> LinearAxis.style + ( + ?Color = Color , + ?Title = Title , + ?AxisType = AxisType , + ?AutoTypeNumbers = AutoTypeNumbers , + ?AutoRange = AutoRange , + ?RangeMode = RangeMode , + ?Range = Range , + ?FixedRange = FixedRange , + ?TickMode = TickMode , + ?NTicks = NTicks , + ?Tick0 = Tick0 , + ?DTick = DTick , + ?TickVals = TickVals , + ?TickText = TickText , + ?Ticks = Ticks , + ?ShowTickLabels = ShowTickLabels , + ?TickFont = TickFont , + ?TickAngle = TickAngle , + ?ShowTickPrefix = ShowTickPrefix , + ?TickPrefix = TickPrefix , + ?ShowTickSuffix = ShowTickSuffix , + ?TickSuffix = TickSuffix , + ?ShowExponent = ShowExponent , + ?ExponentFormat = ExponentFormat , + ?MinExponent = MinExponent , + ?SeparateThousands = SeparateThousands , + ?TickFormat = TickFormat , + ?TickFormatStops = TickFormatStops , + ?ShowLine = ShowLine , + ?LineColor = LineColor , + ?LineWidth = LineWidth , + ?ShowGrid = ShowGrid , + ?GridColor = GridColor , + ?GridWidth = GridWidth , + ?CategoryOrder = CategoryOrder , + ?CategoryArray = CategoryArray , + ?ArrayDTick = ArrayDTick , + ?ArrayTick0 = ArrayTick0 , + ?CheaterType = CheaterType , + ?EndLine = EndLine , + ?EndLineColor = EndLineColor , + ?EndLineWidth = EndLineWidth , + ?LabelPadding = LabelPadding , + ?LabelPrefix = LabelPrefix , + ?LabelSuffix = LabelSuffix , + ?MinorGridColor = MinorGridColor , + ?MinorGridCount = MinorGridCount , + ?MinorGridWidth = MinorGridWidth , + ?Smoothing = Smoothing , + ?StartLine = StartLine , + ?StartLineColor = StartLineColor , + ?StartLineWidth = StartLineWidth + ) /// /// Create a function that applies the given style parameters to a LinearAxis object /// @@ -558,161 +725,213 @@ type LinearAxis () = /// Sets a range slider for this axis /// Sets a range selector for this axis. This object contains toggable presets for the rangeslider. /// Sets the calendar system to use for `range` and `tick0` if this is a date axis. This does not set the calendar for interpreting data on this axis, that's specified in the trace or via the global `layout.calendar` + // + /// The stride between grid lines along the axis + /// The starting index of grid lines along the axis + /// The type of cheater plot when interpreted as cheater plot + /// Determines whether or not a line is drawn at along the final value of this axis. If "true", the end line is drawn on top of the grid lines. + /// Sets the line color of the end line. + /// Sets the width (in px) of the end line. + /// Extra padding between label and the axis + /// Sets a axis label prefix. + /// Sets a axis label suffix. + /// Sets the color of the grid lines. + /// Sets the number of minor grid ticks per major grid tick + /// Sets the width (in px) of the grid lines. + /// Smoothing applied to the axis lines + /// Determines whether or not a line is drawn at along the starting value of this axis. If "true", the start line is drawn on top of the grid lines. + /// Sets the line color of the start line. + /// Sets the width (in px) of the start line. + static member style ( - [] ?Visible : bool, - [] ?Color : Color, - [] ?Title : Title, - [] ?AxisType : StyleParam.AxisType, - [] ?AutoTypeNumbers : StyleParam.AutoTypeNumbers, - [] ?AutoRange : StyleParam.AutoRange, - [] ?RangeMode : StyleParam.RangeMode, - [] ?Range : StyleParam.Range, - [] ?FixedRange : bool, - [] ?ScaleAnchor : StyleParam.LinearAxisId, - [] ?ScaleRatio : float, - [] ?Constrain : StyleParam.AxisConstraint, - [] ?ConstrainToward : StyleParam.AxisConstraintDirection, - [] ?Matches : StyleParam.LinearAxisId, - [] ?Rangebreaks : seq, - [] ?TickMode : StyleParam.TickMode, - [] ?NTicks : int, - [] ?Tick0 : #IConvertible, - [] ?DTick : #IConvertible, - [] ?TickVals : seq<#IConvertible>, - [] ?TickText : seq<#IConvertible>, - [] ?Ticks : StyleParam.TickOptions, - [] ?TicksOn : StyleParam.CategoryTickAnchor, - [] ?TickLabelMode : StyleParam.TickLabelMode, - [] ?TickLabelPosition : StyleParam.TickLabelPosition, - [] ?TickLabelOverflow : StyleParam.TickLabelOverflow, - [] ?Mirror : StyleParam.Mirror, - [] ?TickLen : float, - [] ?TickWidth : float, - [] ?TickColor : Color, - [] ?ShowTickLabels : bool, - [] ?AutoMargin : bool, - [] ?ShowSpikes : bool, - [] ?SpikeColor : Color, - [] ?SpikeThickness : int, - [] ?SpikeDash : StyleParam.DrawingStyle, - [] ?SpikeMode : StyleParam.SpikeMode, - [] ?SpikeSnap : StyleParam.SpikeSnap, - [] ?TickFont : Font, - [] ?TickAngle : int, - [] ?ShowTickPrefix : StyleParam.ShowTickOption, - [] ?TickPrefix : string, - [] ?ShowTickSuffix : StyleParam.ShowTickOption, - [] ?TickSuffix : string, - [] ?ShowExponent : StyleParam.ShowExponent, - [] ?ExponentFormat : StyleParam.ExponentFormat, - [] ?MinExponent : float, - [] ?SeparateThousands : bool, - [] ?TickFormat : string, - [] ?TickFormatStops : seq, - [] ?HoverFormat : string, - [] ?ShowLine : bool, - [] ?LineColor : Color, - [] ?LineWidth : float, - [] ?ShowGrid : bool, - [] ?GridColor : Color, - [] ?GridWidth : float, - [] ?ZeroLine : bool, - [] ?ZeroLineColor : Color, - [] ?ZeroLineWidth : float, - [] ?ShowDividers : bool, - [] ?DividerColor : Color, - [] ?DividerWidth : int, - [] ?Anchor : StyleParam.LinearAxisId, - [] ?Side : StyleParam.Side, - [] ?Overlaying : StyleParam.LinearAxisId, - [] ?Layer : StyleParam.Layer, - [] ?Domain : StyleParam.Range, - [] ?Position : float, - [] ?CategoryOrder : StyleParam.CategoryOrder, - [] ?CategoryArray : seq<#IConvertible>, - [] ?UIRevision : #IConvertible, - [] ?RangeSlider : RangeSlider, - [] ?RangeSelector : RangeSelector, - [] ?Calendar : StyleParam.Calendar + [] ?Visible : bool, + [] ?Color : Color, + [] ?Title : Title, + [] ?AxisType : StyleParam.AxisType, + [] ?AutoTypeNumbers : StyleParam.AutoTypeNumbers, + [] ?AutoRange : StyleParam.AutoRange, + [] ?RangeMode : StyleParam.RangeMode, + [] ?Range : StyleParam.Range, + [] ?FixedRange : bool, + [] ?ScaleAnchor : StyleParam.LinearAxisId, + [] ?ScaleRatio : float, + [] ?Constrain : StyleParam.AxisConstraint, + [] ?ConstrainToward : StyleParam.AxisConstraintDirection, + [] ?Matches : StyleParam.LinearAxisId, + [] ?Rangebreaks : seq, + [] ?TickMode : StyleParam.TickMode, + [] ?NTicks : int, + [] ?Tick0 : #IConvertible, + [] ?DTick : #IConvertible, + [] ?TickVals : seq<#IConvertible>, + [] ?TickText : seq<#IConvertible>, + [] ?Ticks : StyleParam.TickOptions, + [] ?TicksOn : StyleParam.CategoryTickAnchor, + [] ?TickLabelMode : StyleParam.TickLabelMode, + [] ?TickLabelPosition : StyleParam.TickLabelPosition, + [] ?TickLabelOverflow : StyleParam.TickLabelOverflow, + [] ?Mirror : StyleParam.Mirror, + [] ?TickLen : float, + [] ?TickWidth : float, + [] ?TickColor : Color, + [] ?ShowTickLabels : bool, + [] ?AutoMargin : bool, + [] ?ShowSpikes : bool, + [] ?SpikeColor : Color, + [] ?SpikeThickness : int, + [] ?SpikeDash : StyleParam.DrawingStyle, + [] ?SpikeMode : StyleParam.SpikeMode, + [] ?SpikeSnap : StyleParam.SpikeSnap, + [] ?TickFont : Font, + [] ?TickAngle : int, + [] ?ShowTickPrefix : StyleParam.ShowTickOption, + [] ?TickPrefix : string, + [] ?ShowTickSuffix : StyleParam.ShowTickOption, + [] ?TickSuffix : string, + [] ?ShowExponent : StyleParam.ShowExponent, + [] ?ExponentFormat : StyleParam.ExponentFormat, + [] ?MinExponent : float, + [] ?SeparateThousands : bool, + [] ?TickFormat : string, + [] ?TickFormatStops : seq, + [] ?HoverFormat : string, + [] ?ShowLine : bool, + [] ?LineColor : Color, + [] ?LineWidth : float, + [] ?ShowGrid : bool, + [] ?GridColor : Color, + [] ?GridWidth : float, + [] ?ZeroLine : bool, + [] ?ZeroLineColor : Color, + [] ?ZeroLineWidth : float, + [] ?ShowDividers : bool, + [] ?DividerColor : Color, + [] ?DividerWidth : int, + [] ?Anchor : StyleParam.LinearAxisId, + [] ?Side : StyleParam.Side, + [] ?Overlaying : StyleParam.LinearAxisId, + [] ?Layer : StyleParam.Layer, + [] ?Domain : StyleParam.Range, + [] ?Position : float, + [] ?CategoryOrder : StyleParam.CategoryOrder, + [] ?CategoryArray : seq<#IConvertible>, + [] ?UIRevision : #IConvertible, + [] ?RangeSlider : RangeSlider, + [] ?RangeSelector : RangeSelector, + [] ?Calendar : StyleParam.Calendar, + // exclusive for carpet traces + [] ?ArrayDTick : int, + [] ?ArrayTick0 : int, + [] ?CheaterType : StyleParam.CheaterType, + [] ?EndLine : bool, + [] ?EndLineColor : Color, + [] ?EndLineWidth : int, + [] ?LabelPadding : int, + [] ?LabelPrefix : string, + [] ?LabelSuffix : string, + [] ?MinorGridColor : Color, + [] ?MinorGridCount : int, + [] ?MinorGridWidth : int, + [] ?Smoothing : float, + [] ?StartLine : bool, + [] ?StartLineColor : Color, + [] ?StartLineWidth : int + ) = (fun (axis:LinearAxis) -> - Visible |> DynObj.setValueOpt axis "visible" - Color |> DynObj.setValueOpt axis "color" - Title |> DynObj.setValueOpt axis "title" - AxisType |> DynObj.setValueOptBy axis "type" StyleParam.AxisType.convert - AutoTypeNumbers |> DynObj.setValueOptBy axis "autotypenumbers" StyleParam.AutoTypeNumbers.convert - AutoRange |> DynObj.setValueOptBy axis "autorange" StyleParam.AutoRange.convert - RangeMode |> DynObj.setValueOptBy axis "rangemode" StyleParam.RangeMode.convert - Range |> DynObj.setValueOptBy axis "range" StyleParam.Range.convert - FixedRange |> DynObj.setValueOpt axis "fixedrange" - ScaleAnchor |> DynObj.setValueOptBy axis "scaleanchor" StyleParam.LinearAxisId.convert - ScaleRatio |> DynObj.setValueOpt axis "scaleratio" - Constrain |> DynObj.setValueOptBy axis "constrain" StyleParam.AxisConstraint.convert - ConstrainToward |> DynObj.setValueOptBy axis "constraintoward" StyleParam.AxisConstraintDirection.convert - Matches |> DynObj.setValueOptBy axis "matches" StyleParam.LinearAxisId.convert - Rangebreaks |> DynObj.setValueOpt axis "rangebreaks" - TickMode |> DynObj.setValueOptBy axis "tickmode" StyleParam.TickMode.convert - NTicks |> DynObj.setValueOpt axis "nticks" - Tick0 |> DynObj.setValueOpt axis "tick0" - DTick |> DynObj.setValueOpt axis "dtick" - TickVals |> DynObj.setValueOpt axis "tickvals" - TickText |> DynObj.setValueOpt axis "ticktext" - Ticks |> DynObj.setValueOptBy axis "ticks" StyleParam.TickOptions.convert - TicksOn |> DynObj.setValueOptBy axis "tickson" StyleParam.CategoryTickAnchor.convert - TickLabelMode |> DynObj.setValueOptBy axis "ticklabelmode" StyleParam.TickLabelMode.convert - TickLabelPosition |> DynObj.setValueOptBy axis "ticklabelposition" StyleParam.TickLabelPosition.convert - TickLabelOverflow |> DynObj.setValueOptBy axis "ticklabeloverflow" StyleParam.TickLabelOverflow.convert - Mirror |> DynObj.setValueOptBy axis "mirror" StyleParam.Mirror.convert - TickLen |> DynObj.setValueOpt axis "ticklen" - TickWidth |> DynObj.setValueOpt axis "tickwidth" - TickColor |> DynObj.setValueOpt axis "tickcolor" - ShowTickLabels |> DynObj.setValueOpt axis "showticklabels" - AutoMargin |> DynObj.setValueOpt axis "automargin" - ShowSpikes |> DynObj.setValueOpt axis "showspikes" - SpikeColor |> DynObj.setValueOpt axis "spikecolor" - SpikeThickness |> DynObj.setValueOpt axis "spikethickness" - SpikeDash |> DynObj.setValueOptBy axis "spikedash" StyleParam.DrawingStyle.convert - SpikeMode |> DynObj.setValueOptBy axis "spikemode" StyleParam.SpikeMode.convert - SpikeSnap |> DynObj.setValueOptBy axis "spikesnap" StyleParam.SpikeSnap.convert - TickFont |> DynObj.setValueOpt axis "tickfont" - TickAngle |> DynObj.setValueOpt axis "tickangle" - ShowTickPrefix |> DynObj.setValueOptBy axis "showtickprefix" StyleParam.ShowTickOption.convert - TickPrefix |> DynObj.setValueOpt axis "tickprefix" - ShowTickSuffix |> DynObj.setValueOptBy axis "showticksuffix" StyleParam.ShowTickOption.convert - TickSuffix |> DynObj.setValueOpt axis "ticksuffix" - ShowExponent |> DynObj.setValueOptBy axis "showexponent" StyleParam.ShowExponent.convert - ExponentFormat |> DynObj.setValueOptBy axis "exponentformat" StyleParam.ExponentFormat.convert - MinExponent |> DynObj.setValueOpt axis "minexponent" - SeparateThousands |> DynObj.setValueOpt axis "separatethousands" - TickFormat |> DynObj.setValueOpt axis "tickformat" - TickFormatStops |> DynObj.setValueOpt axis "tickformatstops" - HoverFormat |> DynObj.setValueOpt axis "hoverformat" - ShowLine |> DynObj.setValueOpt axis "showline" - LineColor |> DynObj.setValueOpt axis "linecolor" - LineWidth |> DynObj.setValueOpt axis "linewidth" - ShowGrid |> DynObj.setValueOpt axis "showgrid" - GridColor |> DynObj.setValueOpt axis "gridcolor" - GridWidth |> DynObj.setValueOpt axis "gridwidth" - ZeroLine |> DynObj.setValueOpt axis "zeroline" - ZeroLineColor |> DynObj.setValueOpt axis "zerolinecolor" - ZeroLineWidth |> DynObj.setValueOpt axis "zerolinewidth" - ShowDividers |> DynObj.setValueOpt axis "showdividers" - DividerColor |> DynObj.setValueOpt axis "dividercolor" - DividerWidth |> DynObj.setValueOpt axis "dividerwidth" - Anchor |> DynObj.setValueOptBy axis "anchor" StyleParam.LinearAxisId.convert - Side |> DynObj.setValueOptBy axis "side" StyleParam.Side.convert - Overlaying |> DynObj.setValueOptBy axis "overlaying" StyleParam.LinearAxisId.convert - Layer |> DynObj.setValueOptBy axis "layer" StyleParam.Layer.convert - Domain |> DynObj.setValueOptBy axis "domain" StyleParam.Range.convert - Position |> DynObj.setValueOpt axis "position" - CategoryOrder |> DynObj.setValueOptBy axis "categoryorder" StyleParam.CategoryOrder.convert - CategoryArray |> DynObj.setValueOpt axis "categoryarray" - UIRevision |> DynObj.setValueOpt axis "uirevision" - RangeSlider |> DynObj.setValueOpt axis "rangeslider" - RangeSelector |> DynObj.setValueOpt axis "rangeselector" - Calendar |> DynObj.setValueOptBy axis "calendar" StyleParam.Calendar.convert + Visible |> DynObj.setValueOpt axis "visible" + Color |> DynObj.setValueOpt axis "color" + Title |> DynObj.setValueOpt axis "title" + AxisType |> DynObj.setValueOptBy axis "type" StyleParam.AxisType.convert + AutoTypeNumbers |> DynObj.setValueOptBy axis "autotypenumbers" StyleParam.AutoTypeNumbers.convert + AutoRange |> DynObj.setValueOptBy axis "autorange" StyleParam.AutoRange.convert + RangeMode |> DynObj.setValueOptBy axis "rangemode" StyleParam.RangeMode.convert + Range |> DynObj.setValueOptBy axis "range" StyleParam.Range.convert + FixedRange |> DynObj.setValueOpt axis "fixedrange" + ScaleAnchor |> DynObj.setValueOptBy axis "scaleanchor" StyleParam.LinearAxisId.convert + ScaleRatio |> DynObj.setValueOpt axis "scaleratio" + Constrain |> DynObj.setValueOptBy axis "constrain" StyleParam.AxisConstraint.convert + ConstrainToward |> DynObj.setValueOptBy axis "constraintoward" StyleParam.AxisConstraintDirection.convert + Matches |> DynObj.setValueOptBy axis "matches" StyleParam.LinearAxisId.convert + Rangebreaks |> DynObj.setValueOpt axis "rangebreaks" + TickMode |> DynObj.setValueOptBy axis "tickmode" StyleParam.TickMode.convert + NTicks |> DynObj.setValueOpt axis "nticks" + Tick0 |> DynObj.setValueOpt axis "tick0" + DTick |> DynObj.setValueOpt axis "dtick" + TickVals |> DynObj.setValueOpt axis "tickvals" + TickText |> DynObj.setValueOpt axis "ticktext" + Ticks |> DynObj.setValueOptBy axis "ticks" StyleParam.TickOptions.convert + TicksOn |> DynObj.setValueOptBy axis "tickson" StyleParam.CategoryTickAnchor.convert + TickLabelMode |> DynObj.setValueOptBy axis "ticklabelmode" StyleParam.TickLabelMode.convert + TickLabelPosition |> DynObj.setValueOptBy axis "ticklabelposition" StyleParam.TickLabelPosition.convert + TickLabelOverflow |> DynObj.setValueOptBy axis "ticklabeloverflow" StyleParam.TickLabelOverflow.convert + Mirror |> DynObj.setValueOptBy axis "mirror" StyleParam.Mirror.convert + TickLen |> DynObj.setValueOpt axis "ticklen" + TickWidth |> DynObj.setValueOpt axis "tickwidth" + TickColor |> DynObj.setValueOpt axis "tickcolor" + ShowTickLabels |> DynObj.setValueOpt axis "showticklabels" + AutoMargin |> DynObj.setValueOpt axis "automargin" + ShowSpikes |> DynObj.setValueOpt axis "showspikes" + SpikeColor |> DynObj.setValueOpt axis "spikecolor" + SpikeThickness |> DynObj.setValueOpt axis "spikethickness" + SpikeDash |> DynObj.setValueOptBy axis "spikedash" StyleParam.DrawingStyle.convert + SpikeMode |> DynObj.setValueOptBy axis "spikemode" StyleParam.SpikeMode.convert + SpikeSnap |> DynObj.setValueOptBy axis "spikesnap" StyleParam.SpikeSnap.convert + TickFont |> DynObj.setValueOpt axis "tickfont" + TickAngle |> DynObj.setValueOpt axis "tickangle" + ShowTickPrefix |> DynObj.setValueOptBy axis "showtickprefix" StyleParam.ShowTickOption.convert + TickPrefix |> DynObj.setValueOpt axis "tickprefix" + ShowTickSuffix |> DynObj.setValueOptBy axis "showticksuffix" StyleParam.ShowTickOption.convert + TickSuffix |> DynObj.setValueOpt axis "ticksuffix" + ShowExponent |> DynObj.setValueOptBy axis "showexponent" StyleParam.ShowExponent.convert + ExponentFormat |> DynObj.setValueOptBy axis "exponentformat" StyleParam.ExponentFormat.convert + MinExponent |> DynObj.setValueOpt axis "minexponent" + SeparateThousands |> DynObj.setValueOpt axis "separatethousands" + TickFormat |> DynObj.setValueOpt axis "tickformat" + TickFormatStops |> DynObj.setValueOpt axis "tickformatstops" + HoverFormat |> DynObj.setValueOpt axis "hoverformat" + ShowLine |> DynObj.setValueOpt axis "showline" + LineColor |> DynObj.setValueOpt axis "linecolor" + LineWidth |> DynObj.setValueOpt axis "linewidth" + ShowGrid |> DynObj.setValueOpt axis "showgrid" + GridColor |> DynObj.setValueOpt axis "gridcolor" + GridWidth |> DynObj.setValueOpt axis "gridwidth" + ZeroLine |> DynObj.setValueOpt axis "zeroline" + ZeroLineColor |> DynObj.setValueOpt axis "zerolinecolor" + ZeroLineWidth |> DynObj.setValueOpt axis "zerolinewidth" + ShowDividers |> DynObj.setValueOpt axis "showdividers" + DividerColor |> DynObj.setValueOpt axis "dividercolor" + DividerWidth |> DynObj.setValueOpt axis "dividerwidth" + Anchor |> DynObj.setValueOptBy axis "anchor" StyleParam.LinearAxisId.convert + Side |> DynObj.setValueOptBy axis "side" StyleParam.Side.convert + Overlaying |> DynObj.setValueOptBy axis "overlaying" StyleParam.LinearAxisId.convert + Layer |> DynObj.setValueOptBy axis "layer" StyleParam.Layer.convert + Domain |> DynObj.setValueOptBy axis "domain" StyleParam.Range.convert + Position |> DynObj.setValueOpt axis "position" + CategoryOrder |> DynObj.setValueOptBy axis "categoryorder" StyleParam.CategoryOrder.convert + CategoryArray |> DynObj.setValueOpt axis "categoryarray" + UIRevision |> DynObj.setValueOpt axis "uirevision" + RangeSlider |> DynObj.setValueOpt axis "rangeslider" + RangeSelector |> DynObj.setValueOpt axis "rangeselector" + Calendar |> DynObj.setValueOptBy axis "calendar" StyleParam.Calendar.convert + ArrayDTick |> DynObj.setValueOpt axis "arraydtick" + ArrayTick0 |> DynObj.setValueOpt axis "arraytick0" + CheaterType |> DynObj.setValueOptBy axis "cheatertype" StyleParam.CheaterType.convert + EndLine |> DynObj.setValueOpt axis "endline" + EndLineColor |> DynObj.setValueOpt axis "endlinecolor" + EndLineWidth |> DynObj.setValueOpt axis "endlinewidth" + LabelPadding |> DynObj.setValueOpt axis "labelpadding" + LabelPrefix |> DynObj.setValueOpt axis "labelprefix" + LabelSuffix |> DynObj.setValueOpt axis "labelsuffix" + MinorGridColor |> DynObj.setValueOpt axis "minorgridcolor" + MinorGridCount |> DynObj.setValueOpt axis "minorgridcount" + MinorGridWidth |> DynObj.setValueOpt axis "minorgridwidth" + Smoothing |> DynObj.setValueOpt axis "smoothing" + StartLine |> DynObj.setValueOpt axis "startline" + StartLineColor |> DynObj.setValueOpt axis "startlinecolor" + StartLineWidth |> DynObj.setValueOpt axis "startlinewidth" axis ) diff --git a/src/Plotly.NET/Playground.fsx b/src/Plotly.NET/Playground.fsx index 1370199db..6c4860cce 100644 --- a/src/Plotly.NET/Playground.fsx +++ b/src/Plotly.NET/Playground.fsx @@ -131,6 +131,7 @@ #load "ChartPolar.fs" #load "ChartMap.fs" #load "ChartTernary.fs" +#load "ChartCarpet.fs" #load "ChartDomain.fs" #I "CSharpLayer" @@ -158,9 +159,91 @@ open FSharpAux open System open System.IO +[ + 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 + ) + ) + Chart.ContourCarpet( + "contour", + [1.; 1.96; 2.56; 3.0625; 4.; 5.0625; 1.; 7.5625; 9.; 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] + ) +] +|> Chart.combine +|> Chart.show + +let a = [4.; 4.; 4.; 4.5; 4.5; 4.5; 5.; 5.; 5.; 6.; 6.; 6.] +let b = [1.; 2.; 3.; 1.; 2.; 3.; 1.; 2.; 3.; 1.; 2.; 3.] +let y = [2.; 3.5; 4.; 3.; 4.5; 5.; 5.5; 6.5; 7.5; 8.; 8.5; 10.] + +let carpets = + [ + Chart.Carpet("carpet1",A = a, B = b, Y = y) + Chart.Carpet("carpet2",A = (a |> List.rev) , B = (b |> List.rev), Y = (y |> List.map (fun x -> x + 10.))) + Chart.Carpet("carpet3",A = a, B = b, Y = (y |> List.map (fun x -> x + 20.))) + Chart.Carpet("carpet4",A = (a |> List.rev) , B = (b |> List.rev), Y = (y |> List.map (fun x -> x + 30.))) + Chart.Carpet("carpet5",A = a, B = b, Y = (y |> List.map (fun x -> x + 40.))) + ] + +let aData = [4.; 5.; 5.; 6.] +let bData = [1.; 1.; 2.; 3.] +let sizes = [5; 10; 15; 20] + +let carpetCharts = + [ + Chart.ScatterCarpet( + aData,bData, + StyleParam.Mode.Lines_Markers, + "carpet1", + Name = "Scatter", + MultiMarkerSymbol =[ + StyleParam.MarkerSymbol.ArrowDown + StyleParam.MarkerSymbol.TriangleNW + StyleParam.MarkerSymbol.DiamondX + StyleParam.MarkerSymbol.Hexagon2 + ], + MultiSize = sizes, + Color = Color.fromColors ([Red; Blue; Green; Yellow] |> List.map Color.fromKeyword) + ) + Chart.PointCarpet(aData,bData,"carpet2",Name = "Point") + Chart.LineCarpet(aData,bData,"carpet3",Name = "Line") + Chart.SplineCarpet(aData,bData,"carpet4",Name = "Spline") + Chart.BubbleCarpet((Seq.zip3 aData bData sizes),"carpet5",Name = "Bubble") + ] + +let scatter = Chart.combine [carpets.[0]; carpetCharts.[0]] +let point = Chart.combine [carpets.[1]; carpetCharts.[1]] +let line = Chart.combine [carpets.[2]; carpetCharts.[2]] +let spline = Chart.combine [carpets.[3]; carpetCharts.[3]] +let bubble = Chart.combine [carpets.[4]; carpetCharts.[4]] + +scatter |> Chart.show +point |> Chart.show +line |> Chart.show +spline |> Chart.show +bubble |> Chart.show + + let crazyMarker = Marker.init( - MultiSymbols = [ + MultiSymbol = [ StyleParam.MarkerSymbol.ArrowBarDown StyleParam.MarkerSymbol.Modified(StyleParam.MarkerSymbol.DiamondCross, StyleParam.SymbolStyle.OpenDot) StyleParam.MarkerSymbol.Modified(StyleParam.MarkerSymbol.Square, StyleParam.SymbolStyle.Open) @@ -199,7 +282,7 @@ Chart.Bar( Colorscale = StyleParam.Colorscale.Viridis, ShowScale = true, Pattern = Pattern.init( - MultiShapes = [ + MultiShape = [ StyleParam.PatternShape.None StyleParam.PatternShape.DiagonalDescending StyleParam.PatternShape.DiagonalAscending diff --git a/src/Plotly.NET/Plotly.NET.fsproj b/src/Plotly.NET/Plotly.NET.fsproj index 2cfa6ae19..2483e1372 100644 --- a/src/Plotly.NET/Plotly.NET.fsproj +++ b/src/Plotly.NET/Plotly.NET.fsproj @@ -123,6 +123,7 @@ + diff --git a/src/Plotly.NET/Traces/ObjectAbstractions/Marker.fs b/src/Plotly.NET/Traces/ObjectAbstractions/Marker.fs index 55e71d880..ecec4d103 100644 --- a/src/Plotly.NET/Traces/ObjectAbstractions/Marker.fs +++ b/src/Plotly.NET/Traces/ObjectAbstractions/Marker.fs @@ -31,7 +31,7 @@ type Marker () = [] ?Pattern : Pattern, [] ?MultiOpacity : seq, [] ?Symbol : StyleParam.MarkerSymbol, - [] ?MultiSymbols : seq, + [] ?MultiSymbol : seq, [] ?OutlierColor : Color, [] ?Maxdisplayed : int, [] ?ReverseScale : bool, @@ -62,7 +62,7 @@ type Marker () = ?Pattern = Pattern , ?MultiOpacity = MultiOpacity , ?Symbol = Symbol , - ?MultiSymbols = MultiSymbols , + ?MultiSymbol = MultiSymbol , ?OutlierColor = OutlierColor , ?Maxdisplayed = Maxdisplayed , ?ReverseScale = ReverseScale , @@ -93,7 +93,7 @@ type Marker () = [] ?MultiOpacity : seq, [] ?Pattern : Pattern, [] ?Symbol : StyleParam.MarkerSymbol, - [] ?MultiSymbols : seq, + [] ?MultiSymbol : seq, [] ?OutlierColor : Color, [] ?Maxdisplayed : int, [] ?ReverseScale : bool, @@ -119,7 +119,7 @@ type Marker () = (Size, MultiSize) |> DynObj.setSingleOrMultiOpt marker "size" (Opacity, MultiOpacity) |> DynObj.setSingleOrMultiOpt marker "opacity" Pattern |> DynObj.setValueOpt marker "pattern" - (Symbol, MultiSymbols) |> DynObj.setSingleOrMultiOptBy marker "symbol" StyleParam.MarkerSymbol.convert + (Symbol, MultiSymbol) |> DynObj.setSingleOrMultiOptBy marker "symbol" StyleParam.MarkerSymbol.convert OutlierColor |> DynObj.setValueOpt marker "outliercolor" Maxdisplayed |> DynObj.setValueOpt marker "maxdisplayed" ReverseScale |> DynObj.setValueOpt marker "reversescale" diff --git a/src/Plotly.NET/Traces/Trace.fs b/src/Plotly.NET/Traces/Trace.fs index 0a89251c2..ea51d2de2 100644 --- a/src/Plotly.NET/Traces/Trace.fs +++ b/src/Plotly.NET/Traces/Trace.fs @@ -154,7 +154,7 @@ type TraceStyle() = [] ?MultiOpacity : seq, [] ?Pattern : Pattern, [] ?Symbol : StyleParam.MarkerSymbol, - [] ?MultiSymbols : seq, + [] ?MultiSymbol : seq, [] ?OutlierColor : Color, [] ?Maxdisplayed : int, [] ?ReverseScale : bool, @@ -187,7 +187,7 @@ type TraceStyle() = ?MultiOpacity = MultiOpacity , ?Pattern = Pattern , ?Symbol = Symbol , - ?MultiSymbols = MultiSymbols , + ?MultiSymbol = MultiSymbol , ?OutlierColor = OutlierColor , ?Maxdisplayed = Maxdisplayed , ?ReverseScale = ReverseScale , diff --git a/src/Plotly.NET/Traces/TraceCarpet.fs b/src/Plotly.NET/Traces/TraceCarpet.fs index 2e44d0f97..9061910be 100644 --- a/src/Plotly.NET/Traces/TraceCarpet.fs +++ b/src/Plotly.NET/Traces/TraceCarpet.fs @@ -33,4 +33,242 @@ type TraceCarpetStyle() = CarpetId |> DynObj.setValueOptBy trace "carpet" StyleParam.SubPlotId.toString trace - ) \ No newline at end of file + ) + + static member Carpet + ( + [] ?Name : string, + [] ?Visible : StyleParam.Visible, + [] ?ShowLegend : bool, + [] ?LegendRank : int, + [] ?LegendGroup : string, + [] ?LegendGroupTitle : Title, + [] ?Opacity : float, + [] ?Ids : seq<#IConvertible>, + [] ?X : seq<#IConvertible>, + [] ?MultiX : seq<#seq<#IConvertible>>, + [] ?Y : seq<#IConvertible>, + [] ?MultiY : seq<#seq<#IConvertible>>, + [] ?A : seq<#IConvertible>, + [] ?A0 : #IConvertible, + [] ?DA : #IConvertible, + [] ?B : seq<#IConvertible>, + [] ?B0 : #IConvertible, + [] ?DB : #IConvertible, + [] ?Meta : string, + [] ?CustomData : seq<#IConvertible>, + [] ?AAxis : LinearAxis, + [] ?BAxis : LinearAxis, + [] ?XAxis : StyleParam.LinearAxisId, + [] ?YAxis : StyleParam.LinearAxisId, + [] ?Color : Color, + [] ?Carpet : StyleParam.SubPlotId, + [] ?CheaterSlope : float, + [] ?Font : Font, + [] ?UIRevision : string + + ) = + fun (trace: #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 "opacity" + LegendGroupTitle|> DynObj.setValueOpt trace "legendgrouptitle" + Opacity |> DynObj.setValueOpt trace "opacity" + Ids |> DynObj.setValueOpt trace "ids" + (X, MultiX) |> DynObj.setSingleOrAnyOpt trace "x" + (Y, MultiY) |> DynObj.setSingleOrAnyOpt trace "y" + A |> DynObj.setValueOpt trace "a" + A0 |> DynObj.setValueOpt trace "a0" + DA |> DynObj.setValueOpt trace "da" + B |> DynObj.setValueOpt trace "b" + B0 |> DynObj.setValueOpt trace "b0" + DB |> DynObj.setValueOpt trace "db" + Meta |> DynObj.setValueOpt trace "meta" + CustomData |> DynObj.setValueOpt trace "customdata" + AAxis |> DynObj.setValueOpt trace "aaxis" + BAxis |> DynObj.setValueOpt trace "baxis" + XAxis |> DynObj.setValueOptBy trace "xaxis" StyleParam.LinearAxisId.convert + YAxis |> DynObj.setValueOptBy trace "yaxis" StyleParam.LinearAxisId.convert + Color |> DynObj.setValueOpt trace "color" + Carpet |> DynObj.setValueOptBy trace "carpet" StyleParam.SubPlotId.convert + CheaterSlope |> DynObj.setValueOpt trace "cheaterslope" + Font |> DynObj.setValueOpt trace "font" + UIRevision |> DynObj.setValueOpt trace "uirevision" + + trace + + static member ScatterCarpet + ( + [] ?Name : string, + [] ?Visible : StyleParam.Visible, + [] ?ShowLegend : bool, + [] ?LegendRank : int, + [] ?LegendGroup : string, + [] ?LegendGroupTitle : Title, + [] ?Opacity : float, + [] ?Mode : StyleParam.Mode, + [] ?Ids : seq<#IConvertible>, + [] ?A : seq<#IConvertible>, + [] ?B : 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>, + [] ?XAxis : StyleParam.LinearAxisId, + [] ?YAxis : StyleParam.LinearAxisId, + [] ?Marker : Marker, + [] ?Line : Line, + [] ?TextFont : Font, + [] ?SelectedPoints : seq<#IConvertible>, + [] ?Selected : Selection, + [] ?Unselected : Selection, + [] ?Carpet : StyleParam.SubPlotId, + [] ?ConnectGaps : bool, + [] ?Fill : StyleParam.Fill, + [] ?FillColor : Color, + [] ?HoverLabel : Hoverlabel, + [] ?HoverOn : StyleParam.HoverOn, + [] ?UIRevision : string + ) = + fun (trace: #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" + A |> DynObj.setValueOpt trace "a" + B |> DynObj.setValueOpt trace "b" + (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" + XAxis |> DynObj.setValueOptBy trace "xaxis" StyleParam.LinearAxisId.convert + YAxis |> DynObj.setValueOptBy trace "yaxis" StyleParam.LinearAxisId.convert + 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" + Carpet |> DynObj.setValueOptBy trace "carpet" StyleParam.SubPlotId.convert + 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 + + static member ContourCarpet + ( + [] ?Name : string, + [] ?Visible : StyleParam.Visible, + [] ?ShowLegend : bool, + [] ?LegendRank : int, + [] ?LegendGroup : string, + [] ?LegendGroupTitle : Title, + [] ?Opacity : float, + [] ?Ids : seq<#IConvertible>, + [] ?Z : seq<#IConvertible>, + [] ?A : seq<#IConvertible>, + [] ?AType : StyleParam.CoordinateType, + [] ?A0 : #IConvertible, + [] ?DA : #IConvertible, + [] ?B : seq<#IConvertible>, + [] ?BType : StyleParam.CoordinateType, + [] ?B0 : #IConvertible, + [] ?DB : #IConvertible, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?HoverText : string, + [] ?MultiHoverText : seq, + [] ?Meta : string, + [] ?CustomData : seq<#IConvertible>, + [] ?XAxis : StyleParam.LinearAxisId, + [] ?YAxis : StyleParam.LinearAxisId, + [] ?ColorAxis : StyleParam.SubPlotId, + [] ?Line : Line, + [] ?ColorBar : ColorBar, + [] ?AutoColorScale : bool, + [] ?ColorScale : StyleParam.Colorscale, + [] ?ShowScale : bool, + [] ?ReverseScale : bool, + [] ?ZAuto : bool, + [] ?ZMax : #IConvertible, + [] ?ZMid : #IConvertible, + [] ?ZMin : #IConvertible, + [] ?AutoContour : bool, + [] ?Carpet : StyleParam.SubPlotId, + [] ?Contours : Contours, + [] ?FillColor : Color, + [] ?NContours : int, + [] ?Transpose : bool, + [] ?UIRevision : string + ) = + fun (trace: #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" + Ids |> DynObj.setValueOpt trace "ids" + Z |> DynObj.setValueOpt trace "z" + A |> DynObj.setValueOpt trace "a" + AType |> DynObj.setValueOptBy trace "atype" StyleParam.CoordinateType.convert + A0 |> DynObj.setValueOpt trace "a0" + DA |> DynObj.setValueOpt trace "da" + B |> DynObj.setValueOpt trace "b" + BType |> DynObj.setValueOptBy trace "btype" StyleParam.CoordinateType.convert + B0 |> DynObj.setValueOpt trace "b0" + DB |> DynObj.setValueOpt trace "db" + (Text, MultiText) |> DynObj.setSingleOrMultiOpt trace "text" + (HoverText, MultiHoverText) |> DynObj.setSingleOrMultiOpt trace "hovertext" + Meta |> DynObj.setValueOpt trace "meta" + CustomData |> DynObj.setValueOpt trace "customdata" + XAxis |> DynObj.setValueOptBy trace "xaxis" StyleParam.LinearAxisId.convert + YAxis |> DynObj.setValueOptBy trace "yaxis" StyleParam.LinearAxisId.convert + ColorAxis |> DynObj.setValueOptBy trace "coloraxis" StyleParam.SubPlotId.convert + Line |> DynObj.setValueOpt trace "line" + ColorBar |> DynObj.setValueOpt trace "colorbar" + AutoColorScale |> DynObj.setValueOpt trace "autocolorscale" + ColorScale |> DynObj.setValueOptBy trace "colorscale" StyleParam.Colorscale.convert + ShowScale |> DynObj.setValueOpt trace "showscale" + ReverseScale |> DynObj.setValueOpt trace "reversescale" + ZAuto |> DynObj.setValueOpt trace "zauto" + ZMax |> DynObj.setValueOpt trace "zmax" + ZMid |> DynObj.setValueOpt trace "zmid" + ZMin |> DynObj.setValueOpt trace "zmin" + AutoContour |> DynObj.setValueOpt trace "autocontour" + Carpet |> DynObj.setValueOptBy trace "carpet" StyleParam.SubPlotId.convert + Contours |> DynObj.setValueOpt trace "contours" + FillColor |> DynObj.setValueOpt trace "fillcolor" + NContours |> DynObj.setValueOpt trace "ncontours" + Transpose |> DynObj.setValueOpt trace "transpose" + UIRevision |> DynObj.setValueOpt trace "uirevision" + + trace \ No newline at end of file diff --git a/tests/Plotly.NET.Tests/HtmlCodegen/CarpetCharts.fs b/tests/Plotly.NET.Tests/HtmlCodegen/CarpetCharts.fs new file mode 100644 index 000000000..6146f9ca7 --- /dev/null +++ b/tests/Plotly.NET.Tests/HtmlCodegen/CarpetCharts.fs @@ -0,0 +1,141 @@ +module Tests.CarpetCharts + +open Expecto +open Plotly.NET +open Plotly.NET.LayoutObjects +open Plotly.NET.TraceObjects +open Plotly.NET.GenericChart +open System + +open TestUtils.HtmlCodegen + +let a = [4.; 4.; 4.; 4.5; 4.5; 4.5; 5.; 5.; 5.; 6.; 6.; 6.] +let b = [1.; 2.; 3.; 1.; 2.; 3.; 1.; 2.; 3.; 1.; 2.; 3.] +let y = [2.; 3.5; 4.; 3.; 4.5; 5.; 5.5; 6.5; 7.5; 8.; 8.5; 10.] + +let carpets = + [ + Chart.Carpet("carpet1",A = a, B = b, Y = y) + Chart.Carpet("carpet2",A = (a |> List.rev) , B = (b |> List.rev), Y = (y |> List.map (fun x -> x + 10.))) + Chart.Carpet("carpet3",A = a, B = b, Y = (y |> List.map (fun x -> x + 20.))) + Chart.Carpet("carpet4",A = (a |> List.rev) , B = (b |> List.rev), Y = (y |> List.map (fun x -> x + 30.))) + Chart.Carpet("carpet5",A = a, B = b, Y = (y |> List.map (fun x -> x + 40.))) + ] + +let aData = [4.; 5.; 5.; 6.] +let bData = [1.; 1.; 2.; 3.] +let sizes = [5; 10; 15; 20] + + +let carpetCharts = + [ + Chart.ScatterCarpet( + aData,bData, + StyleParam.Mode.Lines_Markers, + "carpet1", + Name = "Scatter", + MultiMarkerSymbol =[ + StyleParam.MarkerSymbol.ArrowDown + StyleParam.MarkerSymbol.TriangleNW + StyleParam.MarkerSymbol.DiamondX + StyleParam.MarkerSymbol.Hexagon2 + ], + MultiSize = sizes, + Color = Color.fromColors ([Red; Blue; Green; Yellow] |> List.map Color.fromKeyword) + ) + Chart.PointCarpet(aData,bData,"carpet2",Name = "Point") + Chart.LineCarpet(aData,bData,"carpet3",Name = "Line") + Chart.SplineCarpet(aData,bData,"carpet4",Name = "Spline") + Chart.BubbleCarpet((Seq.zip3 aData bData sizes),"carpet5",Name = "Bubble") + ] + +let scatter = Chart.combine [carpets.[0]; carpetCharts.[0]] +let point = Chart.combine [carpets.[1]; carpetCharts.[1]] +let line = Chart.combine [carpets.[2]; carpetCharts.[2]] +let spline = Chart.combine [carpets.[3]; carpetCharts.[3]] +let bubble = Chart.combine [carpets.[4]; carpetCharts.[4]] + + +[] +let ``ScatterCarpet and derived Charts`` = + testList "CarpetCharts.ScatterCarpet and derived Charts" [ + testCase "ScatterCarpet data" ( fun () -> + """var data = [{"type":"carpet","y":[2.0,3.5,4.0,3.0,4.5,5.0,5.5,6.5,7.5,8.0,8.5,10.0],"a":[4.0,4.0,4.0,4.5,4.5,4.5,5.0,5.0,5.0,6.0,6.0,6.0],"b":[1.0,2.0,3.0,1.0,2.0,3.0,1.0,2.0,3.0,1.0,2.0,3.0],"carpet":"carpet1"},{"type":"scattercarpet","name":"Scatter","mode":"lines+markers","a":[4.0,5.0,5.0,6.0],"b":[1.0,1.0,2.0,3.0],"carpet":"carpet1","marker":{"color":["rgba(255, 0, 0, 1.0)","rgba(0, 0, 255, 1.0)","rgba(0, 128, 0, 1.0)","rgba(255, 255, 0, 1.0)"],"size":[5,10,15,20],"symbol":["46","12","32","15"]},"line":{"color":["rgba(255, 0, 0, 1.0)","rgba(0, 0, 255, 1.0)","rgba(0, 128, 0, 1.0)","rgba(255, 255, 0, 1.0)"]}}];""" + |> chartGeneratedContains scatter + ); + testCase "ScatterCarpet layout" ( fun () -> + emptyLayout scatter + ); + testCase "PointCarpet data" ( fun () -> + """var data = [{"type":"carpet","y":[12.0,13.5,14.0,13.0,14.5,15.0,15.5,16.5,17.5,18.0,18.5,20.0],"a":[6.0,6.0,6.0,5.0,5.0,5.0,4.5,4.5,4.5,4.0,4.0,4.0],"b":[3.0,2.0,1.0,3.0,2.0,1.0,3.0,2.0,1.0,3.0,2.0,1.0],"carpet":"carpet2"},{"type":"scattercarpet","name":"Point","mode":"markers","a":[4.0,5.0,5.0,6.0],"b":[1.0,1.0,2.0,3.0],"carpet":"carpet2","marker":{}}];""" + |> chartGeneratedContains point + ); + testCase "PointCarpet layout" ( fun () -> + emptyLayout point + ); + testCase "LineCarpet data" ( fun () -> + """var data = [{"type":"carpet","y":[22.0,23.5,24.0,23.0,24.5,25.0,25.5,26.5,27.5,28.0,28.5,30.0],"a":[4.0,4.0,4.0,4.5,4.5,4.5,5.0,5.0,5.0,6.0,6.0,6.0],"b":[1.0,2.0,3.0,1.0,2.0,3.0,1.0,2.0,3.0,1.0,2.0,3.0],"carpet":"carpet3"},{"type":"scattercarpet","name":"Line","mode":"lines","a":[4.0,5.0,5.0,6.0],"b":[1.0,1.0,2.0,3.0],"carpet":"carpet3","marker":{},"line":{}}];""" + |> chartGeneratedContains line + ); + testCase "LineCarpet layout" ( fun () -> + emptyLayout line + ); + testCase "SplineCarpet data" ( fun () -> + """var data = [{"type":"carpet","y":[32.0,33.5,34.0,33.0,34.5,35.0,35.5,36.5,37.5,38.0,38.5,40.0],"a":[6.0,6.0,6.0,5.0,5.0,5.0,4.5,4.5,4.5,4.0,4.0,4.0],"b":[3.0,2.0,1.0,3.0,2.0,1.0,3.0,2.0,1.0,3.0,2.0,1.0],"carpet":"carpet4"},{"type":"scattercarpet","name":"Spline","mode":"lines","a":[4.0,5.0,5.0,6.0],"b":[1.0,1.0,2.0,3.0],"carpet":"carpet4","marker":{},"line":{"shape":"spline"}}];""" + |> chartGeneratedContains spline + ); + testCase "SplineCarpet layout" ( fun () -> + emptyLayout spline + ); + testCase "BubbleCarpet data" ( fun () -> + """var data = [{"type":"carpet","y":[42.0,43.5,44.0,43.0,44.5,45.0,45.5,46.5,47.5,48.0,48.5,50.0],"a":[4.0,4.0,4.0,4.5,4.5,4.5,5.0,5.0,5.0,6.0,6.0,6.0],"b":[1.0,2.0,3.0,1.0,2.0,3.0,1.0,2.0,3.0,1.0,2.0,3.0],"carpet":"carpet5"},{"type":"scattercarpet","name":"Bubble","mode":"markers","a":[4.0,5.0,5.0,6.0],"b":[1.0,1.0,2.0,3.0],"carpet":"carpet5","marker":{"size":[5,10,15,20]}}];""" + |> chartGeneratedContains bubble + ); + testCase "BubbleCarpet layout" ( fun () -> + emptyLayout bubble + ); + + ] + + +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 + ) + ) + Chart.ContourCarpet( + "contour", + [1.; 1.96; 2.56; 3.0625; 4.; 5.0625; 1.; 7.5625; 9.; 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] + ) + ] + |> Chart.combine + +[] +let ``ContourCarpet Charts`` = + testList "CarpetCharts.ContourCarpet Charts" [ + testCase "ScatterCarpet data" ( fun () -> + """var data = [{"type":"carpet","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"},{"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],"carpet":"contour","line":{}}];""" + |> chartGeneratedContains contour + ); + testCase "ScatterCarpet layout" ( fun () -> + emptyLayout contour + ); + ] \ 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 cd019ed36..60aed8743 100644 --- a/tests/Plotly.NET.Tests/Plotly.NET.Tests.fsproj +++ b/tests/Plotly.NET.Tests/Plotly.NET.Tests.fsproj @@ -20,6 +20,7 @@ +