diff --git a/docs/02_0_line-scatter-plots.fsx b/docs/02_0_line-scatter-plots.fsx index 93fb66702..5ece9f57a 100644 --- a/docs/02_0_line-scatter-plots.fsx +++ b/docs/02_0_line-scatter-plots.fsx @@ -52,7 +52,7 @@ let line1 = x,y, Name="line", ShowMarkers=true, - MarkerSymbol=StyleParam.Symbol.Square) + MarkerSymbol=StyleParam.MarkerSymbol.Square) |> Chart.withLineStyle(Width=2.,Dash=StyleParam.DrawingStyle.Dot) (*** condition: ipynb ***) diff --git a/docs/index.fsx b/docs/index.fsx index bd25a3207..4b8a104da 100644 --- a/docs/index.fsx +++ b/docs/index.fsx @@ -219,17 +219,28 @@ One of the main design points of Plotly.NET it is to provide support for multipl ### Fluent interface style in C#: ``` -static void Main(string[] args) +using System; +using Plotly.NET; +using Microsoft.FSharp.Core; // use this for less verbose and more helpful intellisense + +namespace Plotly.NET.Tests.CSharp { - double[] x = new double[] { 1, 2 }; - double[] y = new double[] { 5, 10 }; - GenericChart.GenericChart chart = Chart.Point(x: x, y: y); - chart - .WithTraceName("Hello from C#", true) - .withXAxisStyle(title: "xAxis", Showgrid: false, Showline: true) - .withYAxisStyle(title: "yAxis", Showgrid: false, Showline: true) - .Show(); + class Program + { + static void Main(string[] args) + { + double[] x = new double[] { 1, 2 }; + double[] y = new double[] { 5, 10 }; + GenericChart.GenericChart chart = Chart2D.Chart.Point(x: x, y: y); + chart + .WithTraceName("Hello from C#", true) + .WithXAxisStyle(title: Title.init("xAxis"), ShowGrid: false, ShowLine: true) + .WithYAxisStyle(title: Title.init("yAxis"), ShowGrid: false, ShowLine: true) + .Show(); + } + } } + ``` ### Declarative style in F# using the underlying `DynamicObj`: @@ -273,36 +284,47 @@ GenericChart.ofTraceObject(trace) ### Declarative style in C# using the underlying `DynamicObj`: ``` -static void Main(string[] args) +using System; +using Plotly.NET; +using Microsoft.FSharp.Core; // use this for less verbose and more helpful intellisense +using Plotly.NET.LayoutObjects; + +namespace Plotly.NET.Tests.CSharp { - double[] x = new double[] { 1, 2 }; - double[] y = new double[] { 5, 10 }; - - Axis.LinearAxis xAxis = new Axis.LinearAxis(); - xAxis.SetValue("title", "xAxis"); - xAxis.SetValue("showgrid", false); - xAxis.SetValue("showline", true); - - Axis.LinearAxis yAxis = new Axis.LinearAxis(); - yAxis.SetValue("title", "yAxis"); - yAxis.SetValue("showgrid", false); - yAxis.SetValue("showline", true); - - Layout layout = new Layout(); - layout.SetValue("xaxis", xAxis); - layout.SetValue("yaxis", yAxis); - layout.SetValue("showlegend", true); - - Trace trace = new Trace("scatter"); - trace.SetValue("x", x); - trace.SetValue("y", y); - trace.SetValue("mode", "markers"); - trace.SetValue("name", "Hello from C#"); - - GenericChart - .ofTraceObject(trace) - .WithLayout(layout) - .Show(); + class Program + { + static void Main(string[] args) + { + double[] x = new double[] { 1, 2 }; + double[] y = new double[] { 5, 10 }; + + LinearAxis xAxis = new LinearAxis(); + xAxis.SetValue("title", "xAxis"); + xAxis.SetValue("showgrid", false); + xAxis.SetValue("showline", true); + + LinearAxis yAxis = new LinearAxis(); + yAxis.SetValue("title", "yAxis"); + yAxis.SetValue("showgrid", false); + yAxis.SetValue("showline", true); + + Layout layout = new Layout(); + layout.SetValue("xaxis", xAxis); + layout.SetValue("yaxis", yAxis); + layout.SetValue("showlegend", true); + + Trace trace = new Trace("scatter"); + trace.SetValue("x", x); + trace.SetValue("y", y); + trace.SetValue("mode", "markers"); + trace.SetValue("name", "Hello from C#"); + + GenericChart + .ofTraceObject(trace) + .WithLayout(layout) + .Show(); + } + } } ``` diff --git a/src/Plotly.NET.ImageExport/Plotly.NET.ImageExport.fsproj b/src/Plotly.NET.ImageExport/Plotly.NET.ImageExport.fsproj index 8f13dcc79..bab29dea8 100644 --- a/src/Plotly.NET.ImageExport/Plotly.NET.ImageExport.fsproj +++ b/src/Plotly.NET.ImageExport/Plotly.NET.ImageExport.fsproj @@ -37,7 +37,7 @@ - + diff --git a/src/Plotly.NET/CSharpLayer/GenericChartExtensions.fs b/src/Plotly.NET/CSharpLayer/GenericChartExtensions.fs index bae45b65c..3366e2882 100644 --- a/src/Plotly.NET/CSharpLayer/GenericChartExtensions.fs +++ b/src/Plotly.NET/CSharpLayer/GenericChartExtensions.fs @@ -48,17 +48,61 @@ module GenericChartExtensions = [] member this.WithMarkerStyle ( - [] ?Size, - [] ?Color, - [] ?Symbol, - [] ?Opacity + [] ?AutoColorScale : bool, + [] ?CAuto : bool, + [] ?CMax : float, + [] ?CMid : float, + [] ?CMin : float, + [] ?Color : Color, + [] ?Colors : seq, + [] ?ColorAxis : StyleParam.SubPlotId, + [] ?ColorBar : ColorBar, + [] ?Colorscale : StyleParam.Colorscale, + [] ?Gradient : Gradient, + [] ?Outline : Line, + [] ?Size : int, + [] ?MultiSize : seq, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Pattern : Pattern, + [] ?Symbol : StyleParam.MarkerSymbol, + [] ?MultiSymbols : seq, + [] ?OutlierColor : Color, + [] ?Maxdisplayed : int, + [] ?ReverseScale : bool, + [] ?ShowScale : bool, + [] ?SizeMin : int, + [] ?SizeMode : StyleParam.MarkerSizeMode, + [] ?SizeRef : int ) = this |> Chart.withMarkerStyle( - ?Size=Size, - ?Color=Color, - ?Symbol=Symbol, - ?Opacity=Opacity + ?AutoColorScale = AutoColorScale , + ?CAuto = CAuto , + ?CMax = CMax , + ?CMid = CMid , + ?CMin = CMin , + ?Color = Color , + ?Colors = Colors , + ?ColorAxis = ColorAxis , + ?ColorBar = ColorBar , + ?Colorscale = Colorscale , + ?Gradient = Gradient , + ?Outline = Outline , + ?Size = Size , + ?MultiSize = MultiSize , + ?Opacity = Opacity , + ?MultiOpacity = MultiOpacity , + ?Pattern = Pattern , + ?Symbol = Symbol , + ?MultiSymbols = MultiSymbols , + ?OutlierColor = OutlierColor , + ?Maxdisplayed = Maxdisplayed , + ?ReverseScale = ReverseScale , + ?ShowScale = ShowScale , + ?SizeMin = SizeMin , + ?SizeMode = SizeMode , + ?SizeRef = SizeRef ) /// Apply styling to the Line(s) of the chart as Object. diff --git a/src/Plotly.NET/ChartAPI/Chart.fs b/src/Plotly.NET/ChartAPI/Chart.fs index adef70048..5d3518784 100644 --- a/src/Plotly.NET/ChartAPI/Chart.fs +++ b/src/Plotly.NET/ChartAPI/Chart.fs @@ -121,16 +121,65 @@ type Chart = [] static member withMarkerStyle ( - [] ?Size, - [] ?Color, - [] ?Symbol, - [] ?Opacity + [] ?AutoColorScale : bool, + [] ?CAuto : bool, + [] ?CMax : float, + [] ?CMid : float, + [] ?CMin : float, + [] ?Color : Color, + [] ?Colors : seq, + [] ?ColorAxis : StyleParam.SubPlotId, + [] ?ColorBar : ColorBar, + [] ?Colorscale : StyleParam.Colorscale, + [] ?Gradient : Gradient, + [] ?Outline : Line, + [] ?Size : int, + [] ?MultiSize : seq, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Pattern : Pattern, + [] ?Symbol : StyleParam.MarkerSymbol, + [] ?MultiSymbols : seq, + [] ?OutlierColor : Color, + [] ?Maxdisplayed : int, + [] ?ReverseScale : bool, + [] ?ShowScale : bool, + [] ?SizeMin : int, + [] ?SizeMode : StyleParam.MarkerSizeMode, + [] ?SizeRef : int ) = - let marker = - Marker.init ( - ?Size=Size,?Color=Color,?Symbol=Symbol,?Opacity=Opacity + fun (ch:GenericChart) -> + ch + |> mapTrace ( + TraceStyle.Marker( + ?AutoColorScale = AutoColorScale, + ?CAuto = CAuto , + ?CMax = CMax , + ?CMid = CMid , + ?CMin = CMin , + ?Color = Color , + ?Colors = Colors , + ?ColorAxis = ColorAxis , + ?ColorBar = ColorBar , + ?Colorscale = Colorscale , + ?Gradient = Gradient , + ?Outline = Outline , + ?Size = Size , + ?MultiSize = MultiSize , + ?Opacity = Opacity , + ?MultiOpacity = MultiOpacity, + ?Pattern = Pattern, + ?Symbol = Symbol , + ?MultiSymbols = MultiSymbols , + ?OutlierColor = OutlierColor , + ?Maxdisplayed = Maxdisplayed , + ?ReverseScale = ReverseScale , + ?ShowScale = ShowScale , + ?SizeMin = SizeMin , + ?SizeMode = SizeMode , + ?SizeRef = SizeRef ) - Chart.withMarker(marker) + ) /// Apply styling to the Line(s) of the chart as Object. [] @@ -148,12 +197,21 @@ type Chart = [] ?Shape, [] ?Dash, [] ?Smoothing, - [] ?Colorscale + [] ?Colorscale, + [] ?OutlierColor, + [] ?OutlierWidth ) = let line = Line.init ( - ?Width=Width,?Color=Color,?Shape=Shape,?Dash=Dash,?Smoothing=Smoothing,?Colorscale=Colorscale) - + ?Width = Width, + ?Color = Color, + ?Shape = Shape, + ?Dash = Dash, + ?Smoothing = Smoothing, + ?Colorscale = Colorscale, + ?OutlierColor = OutlierColor, + ?OutlierWidth = OutlierWidth + ) Chart.withLine(line) /// Apply styling to the xError(s) of the chart as Object diff --git a/src/Plotly.NET/ChartAPI/Chart2D.fs b/src/Plotly.NET/ChartAPI/Chart2D.fs index 48d9a5dce..0cdcde1a6 100644 --- a/src/Plotly.NET/ChartAPI/Chart2D.fs +++ b/src/Plotly.NET/ChartAPI/Chart2D.fs @@ -521,7 +521,7 @@ module Chart2D = ?Orientation= Orientation, ?GroupNorm = GroupNorm) >> TraceStyle.TraceInfo(?Name=Name,?ShowLegend=ShowLegend,?Opacity=Opacity) - >> TraceStyle.Marker(?Color=Color,?Symbol=MarkerSymbol, MultiSizes=sizes) + >> TraceStyle.Marker(?Color=Color,?Symbol=MarkerSymbol, MultiSize=sizes) >> TraceStyle.TextLabel(?Text=Labels,?Textposition=TextPosition,?Textfont=TextFont) let useWebGL = defaultArg UseWebGL false @@ -880,7 +880,7 @@ module Chart2D = ) ) |> TraceStyle.TraceInfo(?Name=Name,?ShowLegend=ShowLegend,?Opacity=Opacity) - |> TraceStyle.Marker(?Color=Color,?Line=Line) + |> TraceStyle.Marker(?Color=Color,?Outline=Line) |> TraceStyle.TextLabel(?Text=Labels,?Textposition=TextPosition,?Textfont=TextFont) |> GenericChart.ofTraceObject @@ -982,156 +982,418 @@ module Chart2D = ) |> GenericChart.ofTraceObject - /// Illustrates comparisons among individual items [] - static member Column(keys, values, - [] ?Name, - [] ?ShowLegend, - [] ?Color, - [] ?Opacity, - [] ?Labels, - [] ?TextPosition, - [] ?TextFont, - [] ?Marker: Marker) = + static member Bar + ( + values: seq<#IConvertible>, + [] ?Keys : seq<#IConvertible>, + [] ?Name : string , + [] ?ShowLegend : bool, + [] ?Color : Color , + [] ?PatternShape : StyleParam.PatternShape, + [] ?MultiPatternShape : seq, + [] ?Pattern : Pattern, + [] ?Base : #IConvertible, + [] ?Width : #IConvertible, + [] ?MultiWidth : seq<#IConvertible>, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?TextPosition : StyleParam.TextPosition, + [] ?MultiTextPosition : seq, + [] ?TextFont : Font, + [] ?Marker : Marker + ) = + + let pattern = + Pattern + |> Option.defaultValue (TraceObjects.Pattern.init()) + |> TraceObjects.Pattern.style( + ?Shape = PatternShape, + ?MultiShape = MultiPatternShape + ) + let marker = + Marker + |> Option.defaultValue (TraceObjects.Marker.init()) + |> TraceObjects.Marker.style( + ?Color = Color, + Pattern = pattern, + ?MultiOpacity = MultiOpacity + ) - let marker = - match Marker with - | Some marker -> marker |> TraceObjects.Marker.style(?Color=Color) - | Option.None -> TraceObjects.Marker.init (?Color=Color) - - Trace2D.initBar (Trace2DStyle.Bar(X = keys,Y = values,Marker=marker)) - |> TraceStyle.TraceInfo(?Name=Name,?ShowLegend=ShowLegend,?Opacity=Opacity) - |> TraceStyle.TextLabel(?Text=Labels,?Textposition=TextPosition,?Textfont=TextFont) - |> GenericChart.ofTraceObject - + + Trace2D.initBar ( + Trace2DStyle.Bar( + X = values, + ?Y = Keys, + Orientation = StyleParam.Orientation.Horizontal, + ?Name = Name , + ?ShowLegend = ShowLegend , + ?Base = Base , + ?Width = Width , + ?MultiWidth = MultiWidth , + ?Opacity = Opacity , + ?Text = Text , + ?MultiText = MultiText , + ?TextPosition = TextPosition , + ?MultiTextPosition = MultiTextPosition , + ?TextFont = TextFont , + Marker = marker + ) + ) + |> GenericChart.ofTraceObject /// Illustrates comparisons among individual items [] - static member Column(keysvalues, - [] ?Name, - [] ?ShowLegend, - [] ?Color, - [] ?Opacity, - [] ?Labels, - [] ?TextPosition, - [] ?TextFont, - [] ?Marker) = - let keys,values = Seq.unzip keysvalues - Chart.Column(keys, values, ?Name=Name,?ShowLegend=ShowLegend,?Color=Color,?Opacity=Opacity,?Labels=Labels,?TextPosition=TextPosition,?TextFont=TextFont,?Marker=Marker) + static member Bar + ( + keysValues: seq<#IConvertible * #IConvertible>, + [] ?Name : string , + [] ?ShowLegend : bool, + [] ?Color : Color , + [] ?PatternShape : StyleParam.PatternShape, + [] ?MultiPatternShape : seq, + [] ?Pattern : Pattern, + [] ?Base : #IConvertible, + [] ?Width : #IConvertible, + [] ?MultiWidth : seq<#IConvertible>, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?TextPosition : StyleParam.TextPosition, + [] ?MultiTextPosition : seq, + [] ?TextFont : Font, + [] ?Marker : Marker + ) = + let keys,values = Seq.unzip keysValues + Chart.Bar( + values, + keys, + ?Name = Name , + ?ShowLegend = ShowLegend , + ?Color = Color , + ?PatternShape = PatternShape , + ?MultiPatternShape = MultiPatternShape, + ?Pattern = Pattern , + ?Base = Base , + ?Width = Width , + ?MultiWidth = MultiWidth , + ?Opacity = Opacity , + ?MultiOpacity = MultiOpacity , + ?Text = Text , + ?MultiText = MultiText , + ?TextPosition = TextPosition , + ?MultiTextPosition = MultiTextPosition, + ?TextFont = TextFont , + ?Marker = Marker + ) - /// Displays series of column chart type as stacked columns. + /// Displays series of tcolumn chart type as stacked bars. [] - static member StackedColumn(keys, values, - [] ?Name, - [] ?ShowLegend, - [] ?Color, - [] ?Opacity, - [] ?Labels, - [] ?TextPosition, - [] ?TextFont, - [] ?Marker) = - let marker = - match Marker with - | Some marker -> marker |> TraceObjects.Marker.style(?Color=Color) - | Option.None -> TraceObjects.Marker.init (?Color=Color) - - Trace2D.initBar (Trace2DStyle.Bar(X = keys,Y = values,Marker=marker)) - |> TraceStyle.TraceInfo(?Name=Name,?ShowLegend=ShowLegend,?Opacity=Opacity) - |> TraceStyle.TextLabel(?Text=Labels,?Textposition=TextPosition,?Textfont=TextFont) - |> GenericChart.ofTraceObject - //|> GenericChart.setLayout (Layout.init (Layout.style(Barmode=StyleParam.Barmode.Stack))) - |> GenericChart.setLayout (Layout.init (BarMode=StyleParam.BarMode.Stack)) + static member StackedBar + ( + values: seq<#IConvertible>, + [] ?Keys : seq<#IConvertible>, + [] ?Name : string , + [] ?ShowLegend : bool, + [] ?Color : Color , + [] ?PatternShape : StyleParam.PatternShape, + [] ?MultiPatternShape : seq, + [] ?Pattern : Pattern, + [] ?Base : #IConvertible, + [] ?Width : #IConvertible, + [] ?MultiWidth : seq<#IConvertible>, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?TextPosition : StyleParam.TextPosition, + [] ?MultiTextPosition : seq, + [] ?TextFont : Font, + [] ?Marker : Marker + ) = - /// Displays series of column chart type as stacked columns. - [] - static member StackedColumn(keysvalues, - [] ?Name, - [] ?ShowLegend, - [] ?Color, - [] ?Opacity, - [] ?Labels, - [] ?TextPosition, - [] ?TextFont, - [] ?Marker) = - let keys,values = Seq.unzip keysvalues - Chart.StackedColumn(keys, values,?Name=Name,?ShowLegend=ShowLegend,?Color=Color,?Opacity=Opacity,?Labels=Labels,?TextPosition=TextPosition,?TextFont=TextFont,?Marker=Marker) + Chart.Bar( + values, + ?Keys = Keys, + ?Name = Name , + ?ShowLegend = ShowLegend , + ?Color = Color , + ?PatternShape = PatternShape , + ?MultiPatternShape = MultiPatternShape, + ?Pattern = Pattern , + ?Base = Base , + ?Width = Width , + ?MultiWidth = MultiWidth , + ?Opacity = Opacity , + ?MultiOpacity = MultiOpacity , + ?Text = Text , + ?MultiText = MultiText , + ?TextPosition = TextPosition , + ?MultiTextPosition = MultiTextPosition, + ?TextFont = TextFont , + ?Marker = Marker + ) + |> GenericChart.mapLayout (Layout.style (BarMode=StyleParam.BarMode.Stack)) + /// Displays series of tcolumn chart type as stacked bars. + [] + static member StackedBar + ( + keysValues: seq<#IConvertible * #IConvertible>, + [] ?Name : string , + [] ?ShowLegend : bool, + [] ?Color : Color , + [] ?PatternShape : StyleParam.PatternShape, + [] ?MultiPatternShape : seq, + [] ?Pattern : Pattern, + [] ?Base : #IConvertible, + [] ?Width : #IConvertible, + [] ?MultiWidth : seq<#IConvertible>, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?TextPosition : StyleParam.TextPosition, + [] ?MultiTextPosition : seq, + [] ?TextFont : Font, + [] ?Marker : Marker + ) = + + let keys,values = Seq.unzip keysValues + Chart.StackedBar( + values, + keys, + ?Name = Name , + ?ShowLegend = ShowLegend , + ?Color = Color , + ?Pattern = Pattern , + ?PatternShape = PatternShape , + ?MultiPatternShape = MultiPatternShape, + ?Base = Base , + ?Width = Width , + ?MultiWidth = MultiWidth , + ?Opacity = Opacity , + ?MultiOpacity = MultiOpacity , + ?Text = Text , + ?MultiText = MultiText , + ?TextPosition = TextPosition , + ?MultiTextPosition = MultiTextPosition, + ?TextFont = TextFont , + ?Marker = Marker + ) + /// Illustrates comparisons among individual items [] - static member Bar(keys, values, - [] ?Name, - [] ?ShowLegend, - [] ?Color, - [] ?Opacity, - [] ?Labels, - [] ?TextPosition, - [] ?TextFont, - [] ?Marker) = - let marker = - match Marker with - | Some marker -> marker |> TraceObjects.Marker.style(?Color=Color) - | Option.None -> TraceObjects.Marker.init (?Color=Color) - Trace2D.initBar (Trace2DStyle.Bar(X = values,Y = keys,Marker=marker,Orientation = StyleParam.Orientation.Horizontal)) - |> TraceStyle.TraceInfo(?Name=Name,?ShowLegend=ShowLegend,?Opacity=Opacity) - |> TraceStyle.TextLabel(?Text=Labels,?Textposition=TextPosition,?Textfont=TextFont) - |> GenericChart.ofTraceObject + static member Column + ( + values: seq<#IConvertible>, + [] ?Keys : seq<#IConvertible>, + [] ?Name : string , + [] ?ShowLegend : bool, + [] ?Color : Color , + [] ?Pattern : Pattern, + [] ?PatternShape : StyleParam.PatternShape, + [] ?MultiPatternShape : seq, + [] ?Base : #IConvertible, + [] ?Width : #IConvertible, + [] ?MultiWidth : seq<#IConvertible>, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?TextPosition : StyleParam.TextPosition, + [] ?MultiTextPosition : seq, + [] ?TextFont : Font, + [] ?Marker : Marker + ) = + let pattern = + Pattern + |> Option.defaultValue (TraceObjects.Pattern.init()) + |> TraceObjects.Pattern.style( + ?Shape = PatternShape, + ?MultiShape = MultiPatternShape + ) + let marker = + Marker + |> Option.defaultValue (TraceObjects.Marker.init()) + |> TraceObjects.Marker.style( + ?Color = Color, + Pattern = pattern, + ?MultiOpacity = MultiOpacity + ) + + Trace2D.initBar ( + Trace2DStyle.Bar( + Y = values, + ?X = Keys, + Orientation = StyleParam.Orientation.Vertical, + ?Name = Name , + ?ShowLegend = ShowLegend , + ?Base = Base , + ?Width = Width , + ?MultiWidth = MultiWidth , + ?Opacity = Opacity , + ?Text = Text , + ?MultiText = MultiText , + ?TextPosition = TextPosition , + ?MultiTextPosition = MultiTextPosition , + ?TextFont = TextFont , + Marker = marker + ) + ) + |> GenericChart.ofTraceObject /// Illustrates comparisons among individual items [] - static member Bar(keysvalues, - [] ?Name, - [] ?ShowLegend, - [] ?Color, - [] ?Opacity, - [] ?Labels, - [] ?TextPosition, - [] ?TextFont, - [] ?Marker) = - let keys,values = Seq.unzip keysvalues - Chart.Bar(keys, values, ?Name=Name,?ShowLegend=ShowLegend,?Color=Color,?Opacity=Opacity,?Labels=Labels,?TextPosition=TextPosition,?TextFont=TextFont,?Marker=Marker) + static member Column + ( + keysValues: seq<#IConvertible * #IConvertible>, + [] ?Name : string , + [] ?ShowLegend : bool, + [] ?Color : Color , + [] ?PatternShape : StyleParam.PatternShape, + [] ?MultiPatternShape : seq, + [] ?Pattern : Pattern, + [] ?Base : #IConvertible, + [] ?Width : #IConvertible, + [] ?MultiWidth : seq<#IConvertible>, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?TextPosition : StyleParam.TextPosition, + [] ?MultiTextPosition : seq, + [] ?TextFont : Font, + [] ?Marker : Marker + ) = + let keys,values = Seq.unzip keysValues + Chart.Column( + values, + keys, + ?Name = Name , + ?ShowLegend = ShowLegend , + ?Color = Color , + ?Pattern = Pattern , + ?PatternShape = PatternShape , + ?MultiPatternShape = MultiPatternShape, + ?Base = Base , + ?Width = Width , + ?MultiWidth = MultiWidth , + ?Opacity = Opacity , + ?MultiOpacity = MultiOpacity , + ?Text = Text , + ?MultiText = MultiText , + ?TextPosition = TextPosition , + ?MultiTextPosition = MultiTextPosition, + ?TextFont = TextFont , + ?Marker = Marker + ) /// Displays series of tcolumn chart type as stacked bars. [] - static member StackedBar(keys, values, - [] ?Name, - [] ?ShowLegend, - [] ?Color, - [] ?Opacity, - [] ?Labels, - [] ?TextPosition, - [] ?TextFont, - [] ?Marker) = - let marker = - match Marker with - | Some marker -> marker |> TraceObjects.Marker.style(?Color=Color) - | Option.None -> TraceObjects.Marker.init (?Color=Color) - Trace2D.initBar (Trace2DStyle.Bar(X = values,Y = keys,Marker=marker,Orientation = StyleParam.Orientation.Horizontal)) - |> TraceStyle.TraceInfo(?Name=Name,?ShowLegend=ShowLegend,?Opacity=Opacity) - |> TraceStyle.TextLabel(?Text=Labels,?Textposition=TextPosition,?Textfont=TextFont) - |> GenericChart.ofTraceObject - //|> GenericChart.setLayout (Layout.init (Layout.style(Barmode=StyleParam.Barmode.Stack))) - |> GenericChart.setLayout (Layout.init (BarMode=StyleParam.BarMode.Stack)) + static member StackedColumn + ( + values: seq<#IConvertible>, + [] ?Keys : seq<#IConvertible>, + [] ?Name : string , + [] ?ShowLegend : bool, + [] ?Color : Color , + [] ?PatternShape : StyleParam.PatternShape, + [] ?MultiPatternShape : seq, + [] ?Pattern : Pattern, + [] ?Base : #IConvertible, + [] ?Width : #IConvertible, + [] ?MultiWidth : seq<#IConvertible>, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?TextPosition : StyleParam.TextPosition, + [] ?MultiTextPosition : seq, + [] ?TextFont : Font, + [] ?Marker : Marker + + ) = + + Chart.Column( + values, + ?Keys = Keys, + ?Name = Name , + ?ShowLegend = ShowLegend , + ?Color = Color , + ?PatternShape = PatternShape , + ?MultiPatternShape = MultiPatternShape, + ?Pattern = Pattern , + ?Base = Base , + ?Width = Width , + ?MultiWidth = MultiWidth , + ?Opacity = Opacity , + ?MultiOpacity = MultiOpacity , + ?Text = Text , + ?MultiText = MultiText , + ?TextPosition = TextPosition , + ?MultiTextPosition = MultiTextPosition, + ?TextFont = TextFont , + ?Marker = Marker + ) + |> GenericChart.mapLayout (Layout.style (BarMode=StyleParam.BarMode.Stack)) /// Displays series of tcolumn chart type as stacked bars. [] - static member StackedBar(keysvalues, - [] ?Name, - [] ?ShowLegend, - [] ?Color, - [] ?Opacity, - [] ?Labels, - [] ?TextPosition, - [] ?TextFont, - [] ?Marker) = - let keys,values = Seq.unzip keysvalues - Chart.StackedBar(keys, values, ?Name=Name,?ShowLegend=ShowLegend,?Color=Color,?Opacity=Opacity,?Labels=Labels,?TextPosition=TextPosition,?TextFont=TextFont,?Marker=Marker) + static member StackedColumn + ( + keysValues: seq<#IConvertible * #IConvertible>, + [] ?Name : string , + [] ?ShowLegend : bool, + [] ?Color : Color , + [] ?Pattern : Pattern, + [] ?PatternShape : StyleParam.PatternShape, + [] ?MultiPatternShape : seq, + [] ?Base : #IConvertible, + [] ?Width : #IConvertible, + [] ?MultiWidth : seq<#IConvertible>, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Text : #IConvertible, + [] ?MultiText : seq<#IConvertible>, + [] ?TextPosition : StyleParam.TextPosition, + [] ?MultiTextPosition : seq, + [] ?TextFont : Font, + [] ?Marker : Marker + ) = + + let keys,values = Seq.unzip keysValues + Chart.StackedColumn( + values, + keys, + ?Name = Name , + ?ShowLegend = ShowLegend , + ?Color = Color , + ?PatternShape = PatternShape , + ?MultiPatternShape = MultiPatternShape, + ?Pattern = Pattern , + ?Base = Base , + ?Width = Width , + ?MultiWidth = MultiWidth , + ?Opacity = Opacity , + ?MultiOpacity = MultiOpacity , + ?Text = Text , + ?MultiText = MultiText , + ?TextPosition = TextPosition , + ?MultiTextPosition = MultiTextPosition, + ?TextFont = TextFont , + ?Marker = Marker + ) /// Computes a histogram with auto-determined the bin size. [] diff --git a/src/Plotly.NET/ChartAPI/Chart3D.fs b/src/Plotly.NET/ChartAPI/Chart3D.fs index 5b8ebc6d2..4b80768a7 100644 --- a/src/Plotly.NET/ChartAPI/Chart3D.fs +++ b/src/Plotly.NET/ChartAPI/Chart3D.fs @@ -221,7 +221,7 @@ module Chart3D = ) ) |> TraceStyle.TraceInfo(?Name=Name,?ShowLegend=ShowLegend,?Opacity=Opacity) - |> TraceStyle.Marker(?Color=Color,?Symbol=MarkerSymbol, MultiSizes=sizes) + |> TraceStyle.Marker(?Color=Color,?Symbol=MarkerSymbol, MultiSize=sizes) |> TraceStyle.TextLabel(?Text=Labels,?Textposition=TextPosition,?Textfont=TextFont) |> GenericChart.ofTraceObject diff --git a/src/Plotly.NET/ChartAPI/ChartDomain.fs b/src/Plotly.NET/ChartAPI/ChartDomain.fs index 8a999ecaf..368a6d558 100644 --- a/src/Plotly.NET/ChartAPI/ChartDomain.fs +++ b/src/Plotly.NET/ChartAPI/ChartDomain.fs @@ -234,7 +234,7 @@ module ChartDomain = ) ) |> TraceStyle.TraceInfo(?Name=Name,?ShowLegend=ShowLegend,?Opacity=Opacity) - |> TraceStyle.Marker(?Color=Color,?Line=Line) + |> TraceStyle.Marker(?Color=Color,?Outline=Line) |> TraceStyle.Domain(?X=X,?Y=Y,?Row=Row,?Column=Column) |> TraceStyle.TextLabel(?Text=Text,?Textposition=TextPosition) |> GenericChart.ofTraceObject diff --git a/src/Plotly.NET/ChartAPI/ChartPolar.fs b/src/Plotly.NET/ChartAPI/ChartPolar.fs index 70bfe8477..3d9febcf7 100644 --- a/src/Plotly.NET/ChartAPI/ChartPolar.fs +++ b/src/Plotly.NET/ChartAPI/ChartPolar.fs @@ -337,7 +337,7 @@ module ChartPolar = Mode = changeMode StyleParam.Mode.Markers ) >> TraceStyle.TraceInfo(?Name=Name,?ShowLegend=ShowLegend,?Opacity=Opacity) - >> TraceStyle.Marker(?Color=Color,?Symbol=MarkerSymbol,MultiSizes=sizes) + >> TraceStyle.Marker(?Color=Color,?Symbol=MarkerSymbol,MultiSize=sizes) >> TraceStyle.TextLabel(?Text=Labels,?Textposition=TextPosition,?Textfont=TextFont) let useWebGL = defaultArg UseWebGL false diff --git a/src/Plotly.NET/ChartAPI/ChartTernary.fs b/src/Plotly.NET/ChartAPI/ChartTernary.fs index 09fa1b22f..53a10ef2a 100644 --- a/src/Plotly.NET/ChartAPI/ChartTernary.fs +++ b/src/Plotly.NET/ChartAPI/ChartTernary.fs @@ -28,7 +28,7 @@ module ChartTernary = [] ?Labels : seq<#IConvertible>, [] ?Name : string, [] ?ShowLegend : bool, - [] ?MarkerSymbol : StyleParam.Symbol, + [] ?MarkerSymbol : StyleParam.MarkerSymbol, [] ?Color : Color, [] ?Opacity : float, [] ?TextPosition : StyleParam.TextPosition, @@ -60,7 +60,7 @@ module ChartTernary = [] ?Labels : seq<#IConvertible>, [] ?Name : string, [] ?ShowLegend : bool, - [] ?MarkerSymbol : StyleParam.Symbol, + [] ?MarkerSymbol : StyleParam.MarkerSymbol, [] ?Color : Color, [] ?Opacity : float, [] ?TextPosition : StyleParam.TextPosition, @@ -96,7 +96,7 @@ module ChartTernary = [] ?Labels : seq<#IConvertible>, [] ?Name : string, [] ?ShowLegend : bool, - [] ?MarkerSymbol : StyleParam.Symbol, + [] ?MarkerSymbol : StyleParam.MarkerSymbol, [] ?Color : Color, [] ?Opacity : float, [] ?TextPosition : StyleParam.TextPosition, @@ -125,7 +125,7 @@ module ChartTernary = [] ?Labels : seq<#IConvertible>, [] ?Name : string, [] ?ShowLegend : bool, - [] ?MarkerSymbol : StyleParam.Symbol, + [] ?MarkerSymbol : StyleParam.MarkerSymbol, [] ?Color : Color, [] ?Opacity : float, [] ?TextPosition : StyleParam.TextPosition, @@ -160,7 +160,7 @@ module ChartTernary = [] ?ShowMarkers : bool, [] ?Dash : StyleParam.DrawingStyle, [] ?Width : float, - [] ?MarkerSymbol : StyleParam.Symbol, + [] ?MarkerSymbol : StyleParam.MarkerSymbol, [] ?Color : Color, [] ?Opacity : float, [] ?TextPosition : StyleParam.TextPosition, @@ -199,7 +199,7 @@ module ChartTernary = [] ?ShowMarkers : bool, [] ?Dash : StyleParam.DrawingStyle, [] ?Width : float, - [] ?MarkerSymbol : StyleParam.Symbol, + [] ?MarkerSymbol : StyleParam.MarkerSymbol, [] ?Color : Color, [] ?Opacity : float, [] ?TextPosition : StyleParam.TextPosition, diff --git a/src/Plotly.NET/CommonAbstractions/Line.fs b/src/Plotly.NET/CommonAbstractions/Line.fs index 97ce39de2..f7b95b640 100644 --- a/src/Plotly.NET/CommonAbstractions/Line.fs +++ b/src/Plotly.NET/CommonAbstractions/Line.fs @@ -38,26 +38,42 @@ type Line () = // Applies the styles to Line() static member style ( - [] ?Width:float, - [] ?Color:Color, - [] ?Shape:StyleParam.Shape, - [] ?Dash:StyleParam.DrawingStyle, - [] ?Smoothing:float, - [] ?Colorscale:StyleParam.Colorscale, - [] ?OutlierColor:Color, - [] ?OutlierWidth:float + [] ?Color : Color, + [] ?Width : float, + [] ?MultiWidths : seq, + [] ?Shape : StyleParam.Shape, + [] ?Dash : StyleParam.DrawingStyle, + [] ?Smoothing : float, + [] ?OutlierColor : Color, + [] ?OutlierWidth : float, + [] ?AutoColorScale : bool, + [] ?CAuto : bool, + [] ?CMax : float, + [] ?CMid : float, + [] ?CMin : float, + [] ?ColorAxis : StyleParam.SubPlotId, + [] ?Colorscale : StyleParam.Colorscale, + [] ?ReverseScale : bool ) = (fun (line:Line) -> - Color |> DynObj.setValueOpt line "color" - Width |> DynObj.setValueOpt line "width" - Shape |> DynObj.setValueOptBy line "shape" StyleParam.Shape.convert - Smoothing |> DynObj.setValueOpt line "smoothing" - Dash |> DynObj.setValueOptBy line "dash" StyleParam.DrawingStyle.convert - Colorscale |> DynObj.setValueOptBy line "colorscale" StyleParam.Colorscale.convert - OutlierColor |> DynObj.setValueOpt line "outliercolor" - OutlierWidth |> DynObj.setValueOpt line "outlierwidth" - + Color |> DynObj.setValueOpt line "color" + (Width,MultiWidths) |> DynObj.setSingleOrMultiOpt line "width" + Shape |> DynObj.setValueOptBy line "shape" StyleParam.Shape.convert + Smoothing |> DynObj.setValueOpt line "smoothing" + Dash |> DynObj.setValueOptBy line "dash" StyleParam.DrawingStyle.convert + OutlierColor |> DynObj.setValueOpt line "outliercolor" + OutlierWidth |> DynObj.setValueOpt line "outlierwidth" + AutoColorScale |> DynObj.setValueOpt line "autocolorscale" + CAuto |> DynObj.setValueOpt line "cauto" + CMax |> DynObj.setValueOpt line "cmax" + CMid |> DynObj.setValueOpt line "cmid" + CMin |> DynObj.setValueOpt line "cmin" + Color |> DynObj.setValueOpt line "color" + ColorAxis |> DynObj.setValueOptBy line "coloraxis" StyleParam.SubPlotId.convert + Colorscale |> DynObj.setValueOptBy line "colorscale" StyleParam.Colorscale.convert + ReverseScale |> DynObj.setValueOpt line "reversescale" + // out -> line ) diff --git a/src/Plotly.NET/CommonAbstractions/StyleParams.fs b/src/Plotly.NET/CommonAbstractions/StyleParams.fs index 6fe57ac23..e518b352f 100644 --- a/src/Plotly.NET/CommonAbstractions/StyleParams.fs +++ b/src/Plotly.NET/CommonAbstractions/StyleParams.fs @@ -715,6 +715,22 @@ module StyleParam = // #E# //-------------------------- + [] + type ErrorType = + | Percent | Constant| Sqrt | Data + + static member toString = function + | Percent -> "percent" + | Constant -> "constant" + | Sqrt -> "sqrt" + | Data -> "data" + + + static member convert = ErrorType.toString >> box + override this.ToString() = this |> ErrorType.toString + member this.Convert() = this |> ErrorType.convert + + /// 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. [] @@ -813,6 +829,21 @@ module StyleParam = // #G# //-------------------------- + [] + type GradientType = + | Radial | Horizontal | Vertical | None + + static member toString = function + | Radial -> "radial" + | Horizontal -> "horizontal" + | Vertical -> "vertical" + | None -> "none" + + static member convert = GradientType.toString >> box + override this.ToString() = this |> GradientType.toString + member this.Convert() = this |> GradientType.convert + + [] type GroupNorm = | None | Fraction | Percent @@ -1587,6 +1618,46 @@ module StyleParam = // #P# //-------------------------- + + [] + type PatternFillMode = + | Replace | Overlay + + static member toString = function + | Replace -> "replace" + | Overlay -> "overlay" + + static member convert = PatternFillMode.toString >> box + override this.ToString() = this |> PatternFillMode.toString + member this.Convert() = this |> PatternFillMode.convert + + + [] + type PatternShape = + | None + | DiagonalDescending + | DiagonalAscending + | DiagonalChecked + | HorizontalLines + | VerticalLines + | Checked + | Dots + + static member toString = function + | None -> "" + | DiagonalDescending -> "/" + | DiagonalAscending -> """\""" + | DiagonalChecked -> "x" + | HorizontalLines -> "-" + | VerticalLines -> "|" + | Checked -> "+" + | Dots -> "." + + static member convert = PatternShape.toString >> box + override this.ToString() = this |> PatternShape.toString + member this.Convert() = this |> PatternShape.convert + + [] type PeriodAlignment = | Start | Middle | End @@ -1736,63 +1807,137 @@ module StyleParam = | Open | Dot | OpenDot + static member toString = function - | Open -> "Open" - | Dot -> "Dot" - | OpenDot -> "OpenDot" + | Open -> "open" + | Dot -> "dot" + | OpenDot -> "open-dot" + + static member toModifier = function + | Open -> 100 + | Dot -> 200 + | OpenDot -> 300 static member convert = SymbolStyle.toString >> box override this.ToString() = this |> SymbolStyle.toString member this.Convert() = this |> SymbolStyle.convert [] - type Symbol = - | Circle = 0 - | Square = 1 - | Diamond = 2 - | Cross = 3 - | X = 4 - | TriangleUp = 5 - | TriangleDown = 6 - | TriangleLeft = 7 - | TriangleRight = 8 - | TriangleNE = 9 - | TriangleSE = 10 - | TriangleSW = 11 - | TriangleNW = 12 - | Pentagon = 13 - | Hexagon = 14 - | Hexagon2 = 15 - | Octagon = 16 - | Star = 17 - | Hexagram = 18 - | StarTriangleUp = 19 - | StarTriangleDown = 20 - | StarSquare = 21 - | StarDiamond = 22 - | DiamondTall = 23 - | DiamondWide = 24 - | Hourglass = 25 - | Bowtie = 26 - | CircleCross = 27 - | CircleX = 28 - | SquareCross = 29 - | SquareX = 30 - | DiamondCross = 31 - | DiamondX = 32 - | CrossThin = 33 - | XThin = 34 - | Asterisk = 35 - | Hash = 36 - | YUp = 37 - | YDown = 38 - | YLeft = 39 - | YRight = 40 - | LineEW = 41 - | LineNS = 42 - | LineNE = 43 - | LineNW = 44 - + type MarkerSymbol = + | Modified of MarkerSymbol * SymbolStyle + | Circle + | Square + | Diamond + | Cross + | X + | TriangleUp + | TriangleDown + | TriangleLeft + | TriangleRight + | TriangleNE + | TriangleSE + | TriangleSW + | TriangleNW + | Pentagon + | Hexagon + | Hexagon2 + | Octagon + | Star + | Hexagram + | StarTriangleUp + | StarTriangleDown + | StarSquare + | StarDiamond + | DiamondTall + | DiamondWide + | Hourglass + | Bowtie + | CircleCross + | CircleX + | SquareCross + | SquareX + | DiamondCross + | DiamondX + | CrossThin + | XThin + | Asterisk + | Hash + | YUp + | YDown + | YLeft + | YRight + | LineEW + | LineNS + | LineNE + | LineNW + | ArrowUp + | ArrowDown + | ArrowLeft + | ArrowRight + | ArrowBarUp + | ArrowBarDown + | ArrowBarLeft + | ArrowBarRight + + static member toInteger = function + | Modified (symbol, modifier) -> (symbol |> MarkerSymbol.toInteger) + SymbolStyle.toModifier modifier + | Circle -> 0 + | Square -> 1 + | Diamond -> 2 + | Cross -> 3 + | X -> 4 + | TriangleUp -> 5 + | TriangleDown -> 6 + | TriangleLeft -> 7 + | TriangleRight -> 8 + | TriangleNE -> 9 + | TriangleSE -> 10 + | TriangleSW -> 11 + | TriangleNW -> 12 + | Pentagon -> 13 + | Hexagon -> 14 + | Hexagon2 -> 15 + | Octagon -> 16 + | Star -> 17 + | Hexagram -> 18 + | StarTriangleUp -> 19 + | StarTriangleDown -> 20 + | StarSquare -> 21 + | StarDiamond -> 22 + | DiamondTall -> 23 + | DiamondWide -> 24 + | Hourglass -> 25 + | Bowtie -> 26 + | CircleCross -> 27 + | CircleX -> 28 + | SquareCross -> 29 + | SquareX -> 30 + | DiamondCross -> 31 + | DiamondX -> 32 + | CrossThin -> 33 + | XThin -> 34 + | Asterisk -> 35 + | Hash -> 36 + | YUp -> 37 + | YDown -> 38 + | YLeft -> 39 + | YRight -> 40 + | LineEW -> 41 + | LineNS -> 42 + | LineNE -> 43 + | LineNW -> 44 + | ArrowUp -> 45 + | ArrowDown -> 46 + | ArrowLeft -> 47 + | ArrowRight -> 48 + | ArrowBarUp -> 49 + | ArrowBarDown -> 50 + | ArrowBarLeft -> 51 + | ArrowBarRight -> 52 + + static member convert = MarkerSymbol.toInteger >> string >> box + override this.ToString() = this |> MarkerSymbol.toInteger |> string + member this.Convert() = this |> MarkerSymbol.toInteger |> string |> box /// Determines the line shape. With "spline" the lines are drawn using spline interpolation. The other available values correspond to step-wise line shapes. [] diff --git a/src/Plotly.NET/InternalUtils.fs b/src/Plotly.NET/InternalUtils.fs new file mode 100644 index 000000000..6696fac8d --- /dev/null +++ b/src/Plotly.NET/InternalUtils.fs @@ -0,0 +1,19 @@ +[] +module internal InternalUtils + + open DynamicObj + + [] + module DynObj = + + let setSingleOrMultiOpt (dyn:#DynamicObj) (propName:string) (single:'A option, multi:seq<'A> option) = + if multi.IsSome then + multi |> DynObj.setValueOpt dyn propName + else + single |> DynObj.setValueOpt dyn propName + + let setSingleOrMultiOptBy (dyn:#DynamicObj) (propName:string) (f:'A -> 'B) (single:'A option, multi:seq<'A> option) = + if multi.IsSome then + multi |> DynObj.setValueOptBy dyn propName (Seq.map f) + else + single |> DynObj.setValueOptBy dyn propName f diff --git a/src/Plotly.NET/Layout/ObjectAbstractions/Common/ColorAxis.fs b/src/Plotly.NET/Layout/ObjectAbstractions/Common/ColorAxis.fs index c88a6ff48..f74cc3627 100644 --- a/src/Plotly.NET/Layout/ObjectAbstractions/Common/ColorAxis.fs +++ b/src/Plotly.NET/Layout/ObjectAbstractions/Common/ColorAxis.fs @@ -78,8 +78,8 @@ type ColorAxis() = CMid |> DynObj.setValueOpt ca "cmid" CMax |> DynObj.setValueOpt ca "cmax" ColorBar |> DynObj.setValueOpt ca "colorbar" - ColorScale |> DynObj.setValueOpt ca "colorscale" - ShowScale |> DynObj.setValueOpt ca "showscale" + ColorScale |> DynObj.setValueOptBy ca "colorscale" StyleParam.Colorscale.convert + ShowScale |> DynObj.setValueOpt ca "showscale" ReverseScale |> DynObj.setValueOpt ca "reversescale" ca \ No newline at end of file diff --git a/src/Plotly.NET/Playground.fsx b/src/Plotly.NET/Playground.fsx index b579e132a..1370199db 100644 --- a/src/Plotly.NET/Playground.fsx +++ b/src/Plotly.NET/Playground.fsx @@ -4,6 +4,8 @@ #r "nuget: DynamicObj" #r "nuget: Newtonsoft.Json, 13.0.1" +#load "InternalUtils.fs" + #I "CommonAbstractions" #load "StyleParams.fs" @@ -66,6 +68,8 @@ #I "Traces/ObjectAbstractions" +#load "Gradient.fs" +#load "Pattern.fs" #load "Marker.fs" #load "Projection.fs" #load "Surface.fs" @@ -154,6 +158,63 @@ open FSharpAux open System open System.IO +let crazyMarker = + Marker.init( + MultiSymbols = [ + StyleParam.MarkerSymbol.ArrowBarDown + StyleParam.MarkerSymbol.Modified(StyleParam.MarkerSymbol.DiamondCross, StyleParam.SymbolStyle.OpenDot) + StyleParam.MarkerSymbol.Modified(StyleParam.MarkerSymbol.Square, StyleParam.SymbolStyle.Open) + StyleParam.MarkerSymbol.Modified(StyleParam.MarkerSymbol.Hexagon2, StyleParam.SymbolStyle.Dot) + ], + MultiSize = [50;60;100;70], + MultiOpacity = [0.3; 0.6; 0.9; 1.], + Color = Color.fromColorScaleValues [0.; 0.5; 1.; 0.8], + Colorscale = StyleParam.Colorscale.Viridis, + ShowScale = true + ) + +Chart.Point [1,1; 2,2; 3,3; 4,4] +|> Chart.withMarker crazyMarker +|> Chart.show + + +let labels, values = + [ + "A", 1 + "B", 3 + "C", 2 + "D", 4 + "E", 6 + "F", 5 + "G", 7 + "H", 8 + ] + |> List.unzip + +Chart.Bar( + values, + Color = Color.fromColorScaleValues values +) +|> Chart.withMarkerStyle( + Colorscale = StyleParam.Colorscale.Viridis, + ShowScale = true, + Pattern = Pattern.init( + MultiShapes = [ + StyleParam.PatternShape.None + StyleParam.PatternShape.DiagonalDescending + StyleParam.PatternShape.DiagonalAscending + StyleParam.PatternShape.DiagonalChecked + StyleParam.PatternShape.HorizontalLines + StyleParam.PatternShape.VerticalLines + StyleParam.PatternShape.Checked + StyleParam.PatternShape.Dots + ] + ) +) +|> Chart.show + + + Chart.Line([0.; 0.5; 1.; 2.; 2.2], y=[1.23; 2.5; 0.42; 3.; 1.]) |> Chart.withLayoutImage( LayoutImage.init( @@ -210,7 +271,7 @@ Chart.ScatterTernary( TextPosition = StyleParam.TextPosition.BottomCenter ) |> Chart.withLineStyle(Shape=StyleParam.Shape.Spline) -|> Chart.withMarkerStyle(Symbol = StyleParam.Symbol.Cross) +|> Chart.withMarkerStyle(Symbol = StyleParam.MarkerSymbol.Cross) |> Chart.show Chart.LineTernary( diff --git a/src/Plotly.NET/Plotly.NET.fsproj b/src/Plotly.NET/Plotly.NET.fsproj index 5ca1a0253..2cfa6ae19 100644 --- a/src/Plotly.NET/Plotly.NET.fsproj +++ b/src/Plotly.NET/Plotly.NET.fsproj @@ -34,6 +34,7 @@ + @@ -75,6 +76,8 @@ + + @@ -126,8 +129,8 @@ - - + + diff --git a/src/Plotly.NET/Traces/ObjectAbstractions/Error.fs b/src/Plotly.NET/Traces/ObjectAbstractions/Error.fs index 3cbb26e51..ae52768d0 100644 --- a/src/Plotly.NET/Traces/ObjectAbstractions/Error.fs +++ b/src/Plotly.NET/Traces/ObjectAbstractions/Error.fs @@ -11,6 +11,8 @@ type Error () = inherit DynamicObj () /// Init Error type + /// Determines whether or not this set of error bars is visible. + /// Determines the rule used to generate the error bars. If "constant`, the bar lengths are of a constant value. Set this constant in `value`. If "percent", the bar lengths correspond to a percentage of underlying data. Set this percentage in `value`. If "sqrt", the bar lengths correspond to the square of the underlying data. If "data", the bar lengths are set with data set `array`. /// Determines whether or not the error bars have the same length in both direction (top/bottom for vertical bars, left/right for horizontal bars. /// Sets the data corresponding the length of each error bar. Values are plotted relative to the underlying data. /// Sets the data corresponding the length of each error bar in the bottom (left) direction for vertical (horizontal) bars Values are plotted relative to the underlying data. @@ -24,6 +26,8 @@ type Error () = /// Sets the width (in px) of the cross-bar at both ends of the error bars. static member init ( + [] ?Visible: bool, + [] ?Type: StyleParam.ErrorType, [] ?Symmetric: bool, [] ?Array: seq<#IConvertible>, [] ?Arrayminus: seq<#IConvertible>, @@ -53,6 +57,8 @@ type Error () = ) /// Creates a function that applies the given style parameters to an Error object + /// Determines whether or not this set of error bars is visible. + /// Determines the rule used to generate the error bars. If "constant`, the bar lengths are of a constant value. Set this constant in `value`. If "percent", the bar lengths correspond to a percentage of underlying data. Set this percentage in `value`. If "sqrt", the bar lengths correspond to the square of the underlying data. If "data", the bar lengths are set with data set `array`. /// Determines whether or not the error bars have the same length in both direction (top/bottom for vertical bars, left/right for horizontal bars. /// Sets the data corresponding the length of each error bar. Values are plotted relative to the underlying data. /// Sets the data corresponding the length of each error bar in the bottom (left) direction for vertical (horizontal) bars Values are plotted relative to the underlying data. @@ -66,6 +72,8 @@ type Error () = /// Sets the width (in px) of the cross-bar at both ends of the error bars. static member style ( + [] ?Visible: bool, + [] ?Type: StyleParam.ErrorType, [] ?Symmetric: bool, [] ?Array: seq<#IConvertible>, [] ?Arrayminus: seq<#IConvertible>, @@ -80,17 +88,19 @@ type Error () = ) = (fun (error:Error) -> - Symmetric |> DynObj.setValueOpt error "symmetric" - Array |> DynObj.setValueOpt error "array" - Arrayminus |> DynObj.setValueOpt error "arrayminus" - Value |> DynObj.setValueOpt error "value" - Valueminus |> DynObj.setValueOpt error "valueminus" - Traceref |> DynObj.setValueOpt error "traceref" - Tracerefminus |> DynObj.setValueOpt error "tracerefminus" - Copy_ystyle |> DynObj.setValueOpt error "copy_ystyle" - Color |> DynObj.setValueOpt error "color" - Thickness |> DynObj.setValueOpt error "thickness" - Width |> DynObj.setValueOpt error "width" + Visible |> DynObj.setValueOpt error "visible" + Type |> DynObj.setValueOptBy error "type" StyleParam.ErrorType.convert + Symmetric |> DynObj.setValueOpt error "symmetric" + Array |> DynObj.setValueOpt error "array" + Arrayminus |> DynObj.setValueOpt error "arrayminus" + Value |> DynObj.setValueOpt error "value" + Valueminus |> DynObj.setValueOpt error "valueminus" + Traceref |> DynObj.setValueOpt error "traceref" + Tracerefminus |> DynObj.setValueOpt error "tracerefminus" + Copy_ystyle |> DynObj.setValueOpt error "copy_ystyle" + Color |> DynObj.setValueOpt error "color" + Thickness |> DynObj.setValueOpt error "thickness" + Width |> DynObj.setValueOpt error "width" // out -> error diff --git a/src/Plotly.NET/Traces/ObjectAbstractions/Gradient.fs b/src/Plotly.NET/Traces/ObjectAbstractions/Gradient.fs new file mode 100644 index 000000000..99ddb5b9b --- /dev/null +++ b/src/Plotly.NET/Traces/ObjectAbstractions/Gradient.fs @@ -0,0 +1,39 @@ +namespace Plotly.NET.TraceObjects + +open Plotly.NET +open Plotly.NET.LayoutObjects +open DynamicObj +open System +open System.Runtime.InteropServices + +type Gradient () = + inherit DynamicObj () + + static member init + ( + [] ?Color : Color, + [] ?Type : StyleParam.GradientType, + [] ?MultiTypes: seq + ) = + Gradient() + |> Gradient.style + ( + ?Color = Color, + ?Type = Type, + ?MultiTypes = MultiTypes + ) + + static member style + ( + [] ?Color : Color, + [] ?Type : StyleParam.GradientType, + [] ?MultiTypes: seq + ) = + + fun (gradient: Gradient) -> + + (Type,MultiTypes) |> DynObj.setSingleOrMultiOpt gradient "type" + + Color |> DynObj.setValueOpt gradient "color" + + gradient diff --git a/src/Plotly.NET/Traces/ObjectAbstractions/Marker.fs b/src/Plotly.NET/Traces/ObjectAbstractions/Marker.fs index a4db0cfca..55e71d880 100644 --- a/src/Plotly.NET/Traces/ObjectAbstractions/Marker.fs +++ b/src/Plotly.NET/Traces/ObjectAbstractions/Marker.fs @@ -13,104 +13,120 @@ type Marker () = /// Initialized Marker object static member init ( - [] ?Size, - [] ?Opacity, - [] ?Color, - [] ?Symbol, - [] ?MultiSizes, - [] ?Line, - [] ?ColorBar, - [] ?Colorscale, - [] ?Colors: seq, - [] ?OutlierColor, - [] ?Maxdisplayed, - [] ?Sizeref, - [] ?Sizemin, - [] ?Sizemode, - [] ?Cauto, - [] ?Cmax, - [] ?Cmin, - [] ?Cmid, - [] ?Autocolorscale, - [] ?Reversescale, - [] ?Showscale + [] ?AutoColorScale : bool, + [] ?CAuto : bool, + [] ?CMax : float, + [] ?CMid : float, + [] ?CMin : float, + [] ?Color : Color, + [] ?Colors : seq, + [] ?ColorAxis : StyleParam.SubPlotId, + [] ?ColorBar : ColorBar, + [] ?Colorscale : StyleParam.Colorscale, + [] ?Gradient : Gradient, + [] ?Outline : Line, + [] ?Size : int, + [] ?MultiSize : seq, + [] ?Opacity : float, + [] ?Pattern : Pattern, + [] ?MultiOpacity : seq, + [] ?Symbol : StyleParam.MarkerSymbol, + [] ?MultiSymbols : seq, + [] ?OutlierColor : Color, + [] ?Maxdisplayed : int, + [] ?ReverseScale : bool, + [] ?ShowScale : bool, + [] ?SizeMin : int, + [] ?SizeMode : StyleParam.MarkerSizeMode, + [] ?SizeRef : int ) = Marker () |> Marker.style ( - ?Size = Size , - ?Color = Color , - ?Symbol = Symbol , - ?Opacity = Opacity , - ?MultiSizes = MultiSizes , - ?Line = Line , - ?ColorBar = ColorBar , - ?Colorscale = Colorscale , - //?Colors = Colors , - ?OutlierColor = OutlierColor , - - ?Maxdisplayed = Maxdisplayed , - ?Sizeref = Sizeref , - ?Sizemin = Sizemin , - ?Sizemode = Sizemode , - ?Cauto = Cauto , - ?Cmax = Cmax , - ?Cmid = Cmid , - ?Cmin = Cmin , - ?Autocolorscale= Autocolorscale , - ?Reversescale = Reversescale , - ?Showscale = Showscale - + ?AutoColorScale = AutoColorScale, + ?CAuto = CAuto , + ?CMax = CMax , + ?CMid = CMid , + ?CMin = CMin , + ?Color = Color , + ?Colors = Colors , + ?ColorAxis = ColorAxis , + ?ColorBar = ColorBar , + ?Colorscale = Colorscale , + ?Gradient = Gradient , + ?Outline = Outline , + ?Size = Size , + ?MultiSize = MultiSize , + ?Opacity = Opacity , + ?Pattern = Pattern , + ?MultiOpacity = MultiOpacity , + ?Symbol = Symbol , + ?MultiSymbols = MultiSymbols , + ?OutlierColor = OutlierColor , + ?Maxdisplayed = Maxdisplayed , + ?ReverseScale = ReverseScale , + ?ShowScale = ShowScale , + ?SizeMin = SizeMin , + ?SizeMode = SizeMode , + ?SizeRef = SizeRef ) // Applies the styles to Marker() static member style ( - [] ?Size: int, - [] ?Opacity: float, - [] ?Color: Color, - [] ?Symbol: StyleParam.Symbol, - [] ?MultiSizes: seq<#IConvertible>, - [] ?Line: Line, - [] ?ColorBar: ColorBar, - [] ?Colorscale : StyleParam.Colorscale, - [] ?Colors: seq, - [] ?OutlierColor:Color, - [] ?Maxdisplayed: int, - [] ?Sizeref: float, - [] ?Sizemin: float, - [] ?Sizemode: StyleParam.MarkerSizeMode, - [] ?Cauto: bool, - [] ?Cmax: float, - [] ?Cmin: float, - [] ?Cmid: float, - [] ?Autocolorscale: bool, - [] ?Reversescale: bool, - [] ?Showscale: bool + [] ?AutoColorScale : bool, + [] ?CAuto : bool, + [] ?CMax : float, + [] ?CMid : float, + [] ?CMin : float, + [] ?Color : Color, + [] ?Colors : seq, + [] ?ColorAxis : StyleParam.SubPlotId, + [] ?ColorBar : ColorBar, + [] ?Colorscale : StyleParam.Colorscale, + [] ?Gradient : Gradient, + [] ?Outline : Line, + [] ?Size : int, + [] ?MultiSize : seq, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Pattern : Pattern, + [] ?Symbol : StyleParam.MarkerSymbol, + [] ?MultiSymbols : seq, + [] ?OutlierColor : Color, + [] ?Maxdisplayed : int, + [] ?ReverseScale : bool, + [] ?ShowScale : bool, + [] ?SizeMin : int, + [] ?SizeMode : StyleParam.MarkerSizeMode, + [] ?SizeRef : int ) = (fun (marker: Marker) -> - Size |> DynObj.setValueOpt marker "size" - Color |> DynObj.setValueOpt marker "color" - Symbol |> DynObj.setValueOpt marker "symbol" - Opacity |> DynObj.setValueOpt marker "opacity" - MultiSizes |> DynObj.setValueOpt marker "size" - Line |> DynObj.setValueOpt marker "line" - ColorBar |> DynObj.setValueOpt marker "colorbar" - Colorscale |> DynObj.setValueOptBy marker "colorscale" StyleParam.Colorscale.convert - Colors |> DynObj.setValueOpt marker "colors" - OutlierColor |> DynObj.setValueOpt marker "outliercolor" - Maxdisplayed |> DynObj.setValueOpt marker "maxdisplayed" - Sizeref |> DynObj.setValueOpt marker "sizeref" - Sizemin |> DynObj.setValueOpt marker "sizemin" - Sizemode |> DynObj.setValueOptBy marker "sizemode" StyleParam.MarkerSizeMode.convert - Cauto |> DynObj.setValueOpt marker "cauto" - Cmax |> DynObj.setValueOpt marker "cmax" - Cmid |> DynObj.setValueOpt marker "cmid" - Cmin |> DynObj.setValueOpt marker "cmin" - Autocolorscale |> DynObj.setValueOpt marker "autocolorscale" - Reversescale |> DynObj.setValueOpt marker "reversescale" - Showscale |> DynObj.setValueOpt marker "showscale" + + AutoColorScale |> DynObj.setValueOpt marker "autocolorscale" + CAuto |> DynObj.setValueOpt marker "cauto" + CMax |> DynObj.setValueOpt marker "cmax" + CMid |> DynObj.setValueOpt marker "cmid" + CMin |> DynObj.setValueOpt marker "cmin" + Color |> DynObj.setValueOpt marker "color" + Colors |> DynObj.setValueOpt marker "colors" + ColorAxis |> DynObj.setValueOptBy marker "coloraxis" StyleParam.SubPlotId.convert + ColorBar |> DynObj.setValueOpt marker "colorbar" + Colorscale |> DynObj.setValueOptBy marker "colorscale" StyleParam.Colorscale.convert + Gradient |> DynObj.setValueOpt marker "gradient" + Outline |> DynObj.setValueOpt marker "line" + (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 + OutlierColor |> DynObj.setValueOpt marker "outliercolor" + Maxdisplayed |> DynObj.setValueOpt marker "maxdisplayed" + ReverseScale |> DynObj.setValueOpt marker "reversescale" + ShowScale |> DynObj.setValueOpt marker "showscale" + SizeMin |> DynObj.setValueOpt marker "sizemin" + SizeMode |> DynObj.setValueOpt marker "sizemode" + SizeRef |> DynObj.setValueOpt marker "sizeref" marker ) diff --git a/src/Plotly.NET/Traces/ObjectAbstractions/Pattern.fs b/src/Plotly.NET/Traces/ObjectAbstractions/Pattern.fs new file mode 100644 index 000000000..71fe813f1 --- /dev/null +++ b/src/Plotly.NET/Traces/ObjectAbstractions/Pattern.fs @@ -0,0 +1,73 @@ +namespace Plotly.NET.TraceObjects + +open Plotly.NET +open Plotly.NET.LayoutObjects +open DynamicObj +open System +open System.Runtime.InteropServices + +type Pattern () = + inherit DynamicObj () + + /// + /// + /// + /// When there is no colorscale sets the color of background pattern fill. Defaults to a `marker.color` background when `fillmode` is "overlay". Otherwise, defaults to a transparent background. + /// When there is no colorscale sets the color of foreground pattern fill. Defaults to a `marker.color` background when `fillmode` is "replace". Otherwise, defaults to dark grey or white to increase contrast with the `bgcolor`. + /// Sets the opacity of the foreground pattern fill. Defaults to a 0.5 when `fillmode` is "overlay". Otherwise, defaults to 1. + /// Determines whether `marker.color` should be used as a default to `bgcolor` or a `fgcolor`. + /// Sets the shape of the pattern fill. By default, no pattern is used for filling the area. + /// Sets the shape of the pattern fill. By default, no pattern is used for filling the area. + /// Sets the size of unit squares of the pattern fill in pixels, which corresponds to the interval of repetition of the pattern. + /// Sets the size of unit squares of the pattern fill in pixels, which corresponds to the interval of repetition of the pattern. + /// Sets the solidity of the pattern fill. Solidity is roughly the fraction of the area filled by the pattern. Solidity of 0 shows only the background color without pattern and solidty of 1 shows only the foreground color without pattern. + static member init + ( + ?BGColor : Color, + ?FGColor : Color, + ?FGOpacity : float, + ?FillMode : StyleParam.PatternFillMode, + ?Shape : StyleParam.PatternShape, + ?MultiShape : seq, + ?Size : int, + ?MultiSize : seq, + ?Solidity : float + ) = + Pattern() + |> Pattern.style + ( + ?BGColor = BGColor , + ?FGColor = FGColor , + ?FGOpacity = FGOpacity , + ?FillMode = FillMode , + ?Shape = Shape , + ?MultiShape = MultiShape , + ?Size = Size , + ?MultiSize = MultiSize , + ?Solidity = Solidity + ) + + static member style + ( + ?BGColor : Color, + ?FGColor : Color, + ?FGOpacity : float, + ?FillMode : StyleParam.PatternFillMode, + ?Shape : StyleParam.PatternShape, + ?MultiShape : seq, + ?Size : int, + ?MultiSize : seq, + ?Solidity : float + ) = + + fun (pattern: Pattern) -> + + BGColor |> DynObj.setValueOpt pattern "bgcolor" + FGColor |> DynObj.setValueOpt pattern "fgcolor" + FGOpacity |> DynObj.setValueOpt pattern "fgopacity" + FillMode |> DynObj.setValueOptBy pattern "fillmode" StyleParam.PatternFillMode.convert + (Shape, MultiShape) |> DynObj.setSingleOrMultiOptBy pattern "shape" StyleParam.PatternShape.convert + (Size, MultiSize) |> DynObj.setSingleOrMultiOpt pattern "size" + Solidity |> DynObj.setValueOpt pattern "solidity" + + pattern diff --git a/src/Plotly.NET/Traces/Trace.fs b/src/Plotly.NET/Traces/Trace.fs index 0c4bb0ae7..0a89251c2 100644 --- a/src/Plotly.NET/Traces/Trace.fs +++ b/src/Plotly.NET/Traces/Trace.fs @@ -13,6 +13,9 @@ type Trace (traceTypeName) = // Implictit ITrace member val ``type`` = traceTypeName with get,set + static member tryGetTypedMember<'T> (propName:string) (trace: Trace) = + trace.TryGetTypedValue<'T>(propName) + //------------------------------------------------------------------------------------------------------------------------------------------------- /// Functions provide the styling of the Chart objects /// These functions are used internally to style traces of Chart objects. Users are usually pointed @@ -130,46 +133,69 @@ type TraceStyle() = trace ) - /// Sets the given Marker styles on the marker property of a Trace object static member Marker ( - [] ?Size: int, - [] ?Opacity: float, - [] ?Color: Color, - [] ?Symbol: StyleParam.Symbol, - [] ?MultiSizes: seq<#IConvertible>, - [] ?Line: Line, - [] ?ColorBar: ColorBar, - [] ?Colorscale : StyleParam.Colorscale, - [] ?Colors: seq, - [] ?OutlierColor:Color, - [] ?Maxdisplayed: int, - [] ?Sizeref: float, - [] ?Sizemin: float, - [] ?Sizemode: StyleParam.MarkerSizeMode, - [] ?Cauto: bool, - [] ?Cmax: float, - [] ?Cmin: float, - [] ?Cmid: float, - [] ?Autocolorscale: bool, - [] ?Reversescale: bool, - [] ?Showscale: bool - + [] ?AutoColorScale : bool, + [] ?CAuto : bool, + [] ?CMax : float, + [] ?CMid : float, + [] ?CMin : float, + [] ?Color : Color, + [] ?Colors : seq, + [] ?ColorAxis : StyleParam.SubPlotId, + [] ?ColorBar : ColorBar, + [] ?Colorscale : StyleParam.Colorscale, + [] ?Gradient : Gradient, + [] ?Outline : Line, + [] ?Size : int, + [] ?MultiSize : seq, + [] ?Opacity : float, + [] ?MultiOpacity : seq, + [] ?Pattern : Pattern, + [] ?Symbol : StyleParam.MarkerSymbol, + [] ?MultiSymbols : seq, + [] ?OutlierColor : Color, + [] ?Maxdisplayed : int, + [] ?ReverseScale : bool, + [] ?ShowScale : bool, + [] ?SizeMin : int, + [] ?SizeMode : StyleParam.MarkerSizeMode, + [] ?SizeRef : int ) = (fun (trace:('T :> Trace)) -> let marker = - match (trace.TryGetValue "marker") with - | Some m -> m :?> Marker - | None -> Marker () - - |> Marker.style(?Size=Size,?Color=Color,?Colors=Colors,?Symbol=Symbol, - ?Opacity=Opacity,?MultiSizes=MultiSizes,?Line=Line, - ?ColorBar=ColorBar,?Colorscale=Colorscale,?OutlierColor=OutlierColor, - ?Maxdisplayed=Maxdisplayed,?Sizeref=Sizeref,?Sizemin=Sizemin, - ?Sizemode=Sizemode,?Cauto=Cauto,?Cmax=Cmax,?Cmin=Cmin,?Cmid=Cmid, - ?Autocolorscale=Autocolorscale,?Reversescale=Reversescale,?Showscale=Showscale - ) + trace + |> Trace.tryGetTypedMember "marker" + |> Option.defaultValue (Marker.init()) + |> Marker.style( + ?AutoColorScale = AutoColorScale, + ?CAuto = CAuto , + ?CMax = CMax , + ?CMid = CMid , + ?CMin = CMin , + ?Color = Color , + ?Colors = Colors , + ?ColorAxis = ColorAxis , + ?ColorBar = ColorBar , + ?Colorscale = Colorscale , + ?Gradient = Gradient , + ?Outline = Outline , + ?Size = Size , + ?MultiSize = MultiSize , + ?Opacity = Opacity , + ?MultiOpacity = MultiOpacity , + ?Pattern = Pattern , + ?Symbol = Symbol , + ?MultiSymbols = MultiSymbols , + ?OutlierColor = OutlierColor , + ?Maxdisplayed = Maxdisplayed , + ?ReverseScale = ReverseScale , + ?ShowScale = ShowScale , + ?SizeMin = SizeMin , + ?SizeMode = SizeMode , + ?SizeRef = SizeRef + ) trace.SetValue("marker", marker) trace diff --git a/src/Plotly.NET/Traces/Trace2D.fs b/src/Plotly.NET/Traces/Trace2D.fs index cc2fba620..194fbe6d7 100644 --- a/src/Plotly.NET/Traces/Trace2D.fs +++ b/src/Plotly.NET/Traces/Trace2D.fs @@ -147,11 +147,16 @@ type Trace2DStyle() = /// Alternate to `y`. Builds a linear space of y coordinates. Use with `dy` where `y0` is the starting coordinate and `dy` the step. /// Sets the y coordinate step. See `y0` for more info. /// 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>`. /// Sets the hover text formatting rulefor `x` 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"By default the values are formatted using `xaxis.hoverformat`. /// Sets the hover text formatting rulefor `y` 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"By default the values are formatted using `xaxis.hoverformat`. /// 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. @@ -185,7 +190,7 @@ type Trace2DStyle() = /// Sets the calendar system to use with `x` date data. /// Sets the calendar system to use with `y` date data. /// 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 inline Scatter + static member Scatter ( [] ?Name : string, [] ?Visible : StyleParam.Visible, @@ -202,12 +207,17 @@ type Trace2DStyle() = [] ?Y : seq<#IConvertible>, [] ?Y0 : #IConvertible, [] ?DY : #IConvertible, - [] ?Text : 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, [] ?XHoverFormat : string, [] ?YHoverFormat : string, [] ?Meta : string, @@ -244,60 +254,60 @@ type Trace2DStyle() = ) = (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" - X |> DynObj.setValueOpt trace "x" - X0 |> DynObj.setValueOpt trace "x0" - DX |> DynObj.setValueOpt trace "dx" - Y |> DynObj.setValueOpt trace "y" - Y0 |> DynObj.setValueOpt trace "y0" - DY |> DynObj.setValueOpt trace "dy" - Text |> DynObj.setValueOpt trace "text" - TextPosition |> DynObj.setValueOptBy trace "textposition" StyleParam.TextPosition.convert - TextTemplate |> DynObj.setValueOpt trace "texttemplate" - HoverText |> DynObj.setValueOpt trace "hovertext" - HoverInfo |> DynObj.setValueOptBy trace "hoverinfo" StyleParam.HoverInfo.convert - HoverTemplate |> DynObj.setValueOpt trace "hovertemplate" - XHoverFormat |> DynObj.setValueOpt trace "xhoverformat" - YHoverFormat |> DynObj.setValueOpt trace "yhoverformat" - 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 - Orientation |> DynObj.setValueOptBy trace "orientation" StyleParam.Orientation.convert - GroupNorm |> DynObj.setValueOptBy trace "groupnorm" StyleParam.GroupNorm.convert - StackGroup |> DynObj.setValueOpt trace "stackgroup" - XPeriod |> DynObj.setValueOpt trace "xperiod" - XPeriodAlignment |> DynObj.setValueOptBy trace "xperiodalignment" StyleParam.PeriodAlignment.convert - XPeriod0 |> DynObj.setValueOpt trace "xperiod0" - YPeriod |> DynObj.setValueOpt trace "yperiod" - YPeriodAlignment |> DynObj.setValueOptBy trace "yperiodalignment" StyleParam.PeriodAlignment.convert - YPeriod0 |> DynObj.setValueOpt trace "yperiod0" - Marker |> DynObj.setValueOpt trace "marker" - Line |> DynObj.setValueOpt trace "line" - TextFont |> DynObj.setValueOpt trace "textfont" - ErrorX |> DynObj.setValueOpt trace "error_x" - ErrorY |> DynObj.setValueOpt trace "error_y" - 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 - StackGaps |> DynObj.setValueOptBy trace "stackgaps" StyleParam.StackGaps.convert - XCalendar |> DynObj.setValueOptBy trace "xcalendar" StyleParam.Calendar.convert - YCalendar |> DynObj.setValueOptBy trace "ycalendar" StyleParam.Calendar.convert - UIRevision |> DynObj.setValueOpt trace "uirevision" + 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" + X |> DynObj.setValueOpt trace "x" + X0 |> DynObj.setValueOpt trace "x0" + DX |> DynObj.setValueOpt trace "dx" + Y |> DynObj.setValueOpt trace "y" + Y0 |> DynObj.setValueOpt trace "y0" + DY |> DynObj.setValueOpt trace "dy" + (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" + XHoverFormat |> DynObj.setValueOpt trace "xhoverformat" + YHoverFormat |> DynObj.setValueOpt trace "yhoverformat" + 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 + Orientation |> DynObj.setValueOptBy trace "orientation" StyleParam.Orientation.convert + GroupNorm |> DynObj.setValueOptBy trace "groupnorm" StyleParam.GroupNorm.convert + StackGroup |> DynObj.setValueOpt trace "stackgroup" + XPeriod |> DynObj.setValueOpt trace "xperiod" + XPeriodAlignment |> DynObj.setValueOptBy trace "xperiodalignment" StyleParam.PeriodAlignment.convert + XPeriod0 |> DynObj.setValueOpt trace "xperiod0" + YPeriod |> DynObj.setValueOpt trace "yperiod" + YPeriodAlignment |> DynObj.setValueOptBy trace "yperiodalignment" StyleParam.PeriodAlignment.convert + YPeriod0 |> DynObj.setValueOpt trace "yperiod0" + Marker |> DynObj.setValueOpt trace "marker" + Line |> DynObj.setValueOpt trace "line" + TextFont |> DynObj.setValueOpt trace "textfont" + ErrorX |> DynObj.setValueOpt trace "error_x" + ErrorY |> DynObj.setValueOpt trace "error_y" + 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 + StackGaps |> DynObj.setValueOptBy trace "stackgaps" StyleParam.StackGaps.convert + XCalendar |> DynObj.setValueOptBy trace "xcalendar" StyleParam.Calendar.convert + YCalendar |> DynObj.setValueOptBy trace "ycalendar" StyleParam.Calendar.convert + UIRevision |> DynObj.setValueOpt trace "uirevision" trace ) @@ -320,12 +330,21 @@ type Trace2DStyle() = [] ?Y0 : #IConvertible, [] ?DY : #IConvertible, [] ?Base : #IConvertible, - [] ?Text : seq<#IConvertible>, + [] ?Width : #IConvertible, + [] ?MultiWidth : seq<#IConvertible>, + [] ?Offset : #IConvertible, + [] ?MultiOffset : 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, [] ?XHoverFormat : string, [] ?YHoverFormat : string, [] ?Meta : string, @@ -362,59 +381,61 @@ type Trace2DStyle() = ) = (fun (bar:('T :> Trace)) -> - Name |> DynObj.setValueOpt bar "name" - Visible |> DynObj.setValueOptBy bar "visible" StyleParam.Visible.convert - ShowLegend |> DynObj.setValueOpt bar "showlegend" - LegendRank |> DynObj.setValueOpt bar "legendrank" - LegendGroup |> DynObj.setValueOpt bar "legendgroup" - LegendGroupTitle |> DynObj.setValueOpt bar "legendgrouptitle" - Opacity |> DynObj.setValueOpt bar "opacity" - Ids |> DynObj.setValueOpt bar "ids" - X |> DynObj.setValueOpt bar "x" - X0 |> DynObj.setValueOpt bar "x0" - DX |> DynObj.setValueOpt bar "dx" - Y |> DynObj.setValueOpt bar "y" - Y0 |> DynObj.setValueOpt bar "y0" - DY |> DynObj.setValueOpt bar "dy" - Base |> DynObj.setValueOpt bar "base" - Text |> DynObj.setValueOpt bar "text" - TextPosition |> DynObj.setValueOptBy bar "textposition" StyleParam.TextPosition.convert - TextTemplate |> DynObj.setValueOpt bar "texttemplate" - HoverText |> DynObj.setValueOpt bar "hovertext" - HoverInfo |> DynObj.setValueOptBy bar "hoverinfo" StyleParam.HoverInfo.convert - HoverTemplate |> DynObj.setValueOpt bar "hovertemplate" - XHoverFormat |> DynObj.setValueOpt bar "xhoverformat" - YHoverFormat |> DynObj.setValueOpt bar "yhoverformat" - Meta |> DynObj.setValueOpt bar "meta" - CustomData |> DynObj.setValueOpt bar "customdata" - XAxis |> DynObj.setValueOptBy bar "xaxis" StyleParam.LinearAxisId.convert - YAxis |> DynObj.setValueOptBy bar "yaxis" StyleParam.LinearAxisId.convert - Orientation |> DynObj.setValueOptBy bar "orientation" StyleParam.Orientation.convert - AlignmentGroup |> DynObj.setValueOpt bar "alignmentgroup" - OffsetGroup |> DynObj.setValueOpt bar "offsetgroup" - XPeriod |> DynObj.setValueOpt bar "xperiod" - XPeriodAlignment |> DynObj.setValueOptBy bar "xperiodalignment" StyleParam.PeriodAlignment.convert - XPeriod0 |> DynObj.setValueOpt bar "xperiod0" - YPeriod |> DynObj.setValueOpt bar "yperiod" - YPeriodAlignment |> DynObj.setValueOptBy bar "yperiodalignment" StyleParam.PeriodAlignment.convert - YPeriod0 |> DynObj.setValueOpt bar "yperiod0" - Marker |> DynObj.setValueOpt bar "marker" - TextAngle |> DynObj.setValueOpt bar "textangle" - TextFont |> DynObj.setValueOpt bar "textfont" - ErrorX |> DynObj.setValueOpt bar "errorx" - ErrorY |> DynObj.setValueOpt bar "errory" - SelectedPoints |> DynObj.setValueOpt bar "selectedpoints" - Selected |> DynObj.setValueOpt bar "selected" - Unselected |> DynObj.setValueOpt bar "unselected" - ClipOnAxis |> DynObj.setValueOpt bar "cliponaxis" - Constraintext |> DynObj.setValueOptBy bar "constraintext" StyleParam.ConstrainText.convert - HoverLabel |> DynObj.setValueOpt bar "hoverlabel" - InsideTextAnchor |> DynObj.setValueOptBy bar "insidetextanchor" StyleParam.InsideTextAnchor.convert - InsideTextFont |> DynObj.setValueOpt bar "insidetextfont" - OutsideTextFont |> DynObj.setValueOpt bar "outsidetextfont" - XCalendar |> DynObj.setValueOptBy bar "xcalendar" StyleParam.Calendar.convert - YCalendar |> DynObj.setValueOptBy bar "ycalendar" StyleParam.Calendar.convert - UIRevision |> DynObj.setValueOpt bar "uirevision" + Name |> DynObj.setValueOpt bar "name" + Visible |> DynObj.setValueOptBy bar "visible" StyleParam.Visible.convert + ShowLegend |> DynObj.setValueOpt bar "showlegend" + LegendRank |> DynObj.setValueOpt bar "legendrank" + LegendGroup |> DynObj.setValueOpt bar "legendgroup" + LegendGroupTitle |> DynObj.setValueOpt bar "legendgrouptitle" + Opacity |> DynObj.setValueOpt bar "opacity" + Ids |> DynObj.setValueOpt bar "ids" + X |> DynObj.setValueOpt bar "x" + X0 |> DynObj.setValueOpt bar "x0" + DX |> DynObj.setValueOpt bar "dx" + Y |> DynObj.setValueOpt bar "y" + Y0 |> DynObj.setValueOpt bar "y0" + DY |> DynObj.setValueOpt bar "dy" + Base |> DynObj.setValueOpt bar "base" + (Width, MultiWidth) |> DynObj.setSingleOrMultiOpt bar "width" + (Offset, MultiOffset) |> DynObj.setSingleOrMultiOpt bar "offset" + (Text, MultiText) |> DynObj.setSingleOrMultiOpt bar "text" + (TextPosition, MultiTextPosition) |> DynObj.setSingleOrMultiOptBy bar "textposition" StyleParam.TextPosition.convert + (TextTemplate, MultiTextTemplate) |> DynObj.setSingleOrMultiOpt bar "texttemplate" + (HoverText, MultiHoverText) |> DynObj.setSingleOrMultiOpt bar "hovertext" + HoverInfo |> DynObj.setValueOptBy bar "hoverinfo" StyleParam.HoverInfo.convert + (HoverTemplate, MultiHoverTemplate) |> DynObj.setSingleOrMultiOpt bar "hovertemplate" + XHoverFormat |> DynObj.setValueOpt bar "xhoverformat" + YHoverFormat |> DynObj.setValueOpt bar "yhoverformat" + Meta |> DynObj.setValueOpt bar "meta" + CustomData |> DynObj.setValueOpt bar "customdata" + XAxis |> DynObj.setValueOptBy bar "xaxis" StyleParam.LinearAxisId.convert + YAxis |> DynObj.setValueOptBy bar "yaxis" StyleParam.LinearAxisId.convert + Orientation |> DynObj.setValueOptBy bar "orientation" StyleParam.Orientation.convert + AlignmentGroup |> DynObj.setValueOpt bar "alignmentgroup" + OffsetGroup |> DynObj.setValueOpt bar "offsetgroup" + XPeriod |> DynObj.setValueOpt bar "xperiod" + XPeriodAlignment |> DynObj.setValueOptBy bar "xperiodalignment" StyleParam.PeriodAlignment.convert + XPeriod0 |> DynObj.setValueOpt bar "xperiod0" + YPeriod |> DynObj.setValueOpt bar "yperiod" + YPeriodAlignment |> DynObj.setValueOptBy bar "yperiodalignment" StyleParam.PeriodAlignment.convert + YPeriod0 |> DynObj.setValueOpt bar "yperiod0" + Marker |> DynObj.setValueOpt bar "marker" + TextAngle |> DynObj.setValueOpt bar "textangle" + TextFont |> DynObj.setValueOpt bar "textfont" + ErrorX |> DynObj.setValueOpt bar "errorx" + ErrorY |> DynObj.setValueOpt bar "errory" + SelectedPoints |> DynObj.setValueOpt bar "selectedpoints" + Selected |> DynObj.setValueOpt bar "selected" + Unselected |> DynObj.setValueOpt bar "unselected" + ClipOnAxis |> DynObj.setValueOpt bar "cliponaxis" + Constraintext |> DynObj.setValueOptBy bar "constraintext" StyleParam.ConstrainText.convert + HoverLabel |> DynObj.setValueOpt bar "hoverlabel" + InsideTextAnchor |> DynObj.setValueOptBy bar "insidetextanchor" StyleParam.InsideTextAnchor.convert + InsideTextFont |> DynObj.setValueOpt bar "insidetextfont" + OutsideTextFont |> DynObj.setValueOpt bar "outsidetextfont" + XCalendar |> DynObj.setValueOptBy bar "xcalendar" StyleParam.Calendar.convert + YCalendar |> DynObj.setValueOptBy bar "ycalendar" StyleParam.Calendar.convert + UIRevision |> DynObj.setValueOpt bar "uirevision" bar diff --git a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs index 5d479fd04..c366fa8fb 100644 --- a/tests/Plotly.NET.Tests.CSharpConsole/Program.cs +++ b/tests/Plotly.NET.Tests.CSharpConsole/Program.cs @@ -1,5 +1,7 @@ using System; using Plotly.NET; +using Microsoft.FSharp.Core; // use this for less verbose and more helpful intellisense +using Plotly.NET.LayoutObjects; namespace Plotly.NET.Tests.CSharp { @@ -7,8 +9,34 @@ class Program { static void Main(string[] args) { - Console.WriteLine(StyleParam.TextPosition.MiddleRight.ToString()); - Console.WriteLine(StyleParam.TextPosition.MiddleRight.Convert()); + double[] x = new double[] { 1, 2 }; + double[] y = new double[] { 5, 10 }; + + LinearAxis xAxis = new LinearAxis(); + xAxis.SetValue("title", "xAxis"); + xAxis.SetValue("showgrid", false); + xAxis.SetValue("showline", true); + + LinearAxis yAxis = new LinearAxis(); + yAxis.SetValue("title", "yAxis"); + yAxis.SetValue("showgrid", false); + yAxis.SetValue("showline", true); + + Layout layout = new Layout(); + layout.SetValue("xaxis", xAxis); + layout.SetValue("yaxis", yAxis); + layout.SetValue("showlegend", true); + + Trace trace = new Trace("scatter"); + trace.SetValue("x", x); + trace.SetValue("y", y); + trace.SetValue("mode", "markers"); + trace.SetValue("name", "Hello from C#"); + + GenericChart + .ofTraceObject(trace) + .WithLayout(layout) + .Show(); } } } diff --git a/tests/Plotly.NET.Tests/HtmlCodegen/SimpleCharts.fs b/tests/Plotly.NET.Tests/HtmlCodegen/SimpleCharts.fs index 6d78c2cbd..c86868a9b 100644 --- a/tests/Plotly.NET.Tests/HtmlCodegen/SimpleCharts.fs +++ b/tests/Plotly.NET.Tests/HtmlCodegen/SimpleCharts.fs @@ -16,7 +16,7 @@ let withLineStyleChart = x,y, Name="line", ShowMarkers=true, - MarkerSymbol=StyleParam.Symbol.Square) + MarkerSymbol=StyleParam.MarkerSymbol.Square) |> Chart.withLineStyle(Width=2.,Dash=StyleParam.DrawingStyle.Dot) @@ -45,7 +45,7 @@ let textLabelChart = let ``Line and scatter plots`` = testList "SimpleCharts.Line and scatter plots" [ testCase "With LineStyle data" ( fun () -> - """var data = [{"type":"scatter","mode":"lines+markers","x":[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0],"y":[2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"line":{"width":2.0,"dash":"dot"},"name":"line","marker":{"symbol":1}}];""" + """var data = [{"type":"scatter","mode":"lines+markers","x":[1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0],"y":[2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"line":{"width":2.0,"dash":"dot"},"name":"line","marker":{"symbol":"1"}}];""" |> chartGeneratedContains withLineStyleChart ); testCase "With LineStyle layout" ( fun () -> @@ -78,19 +78,19 @@ let ``Line and scatter plots`` = let columnChart = let values = [20; 14; 23;] let keys = ["Product A"; "Product B"; "Product C";] - Chart.Column(keys, values) + Chart.Column(values, keys) let barChart = let values = [20; 14; 23;] let keys = ["Product A"; "Product B"; "Product C";] - Chart.Bar(keys, values) + Chart.Bar(values, keys) let stackedBarChart = let values = [20; 14; 23;] let keys = ["Product A"; "Product B"; "Product C";] [ - Chart.StackedBar(keys,values,Name="old"); - Chart.StackedBar(keys,[8; 21; 13;],Name="new") + Chart.StackedBar(values, keys, Name="old"); + Chart.StackedBar([8; 21; 13;], keys, Name="new") ] |> Chart.combine @@ -98,8 +98,8 @@ let stackedColumnChart = let values = [20; 14; 23;] let keys = ["Product A"; "Product B"; "Product C";] [ - Chart.StackedColumn(keys,values,Name="old"); - Chart.StackedColumn(keys,[8; 21; 13;],Name="new") + Chart.StackedColumn(values,keys,Name="old"); + Chart.StackedColumn([8; 21; 13;],keys,Name="new") ] |> Chart.combine @@ -107,21 +107,21 @@ let stackedColumnChart = let ``Bar and column charts`` = testList "SimpleCharts.Bar and column charts" [ testCase "Column chart data" ( fun () -> - "var data = [{\"type\":\"bar\",\"x\":[\"Product A\",\"Product B\",\"Product C\"],\"y\":[20,14,23],\"marker\":{}}];" + """var data = [{"type":"bar","x":["Product A","Product B","Product C"],"y":[20,14,23],"orientation":"v","marker":{"pattern":{}}}];""" |> chartGeneratedContains columnChart ); testCase "Column chart layout" ( fun () -> emptyLayout columnChart ); testCase "Bar chart data" ( fun () -> - "var data = [{\"type\":\"bar\",\"x\":[20,14,23],\"y\":[\"Product A\",\"Product B\",\"Product C\"],\"orientation\":\"h\",\"marker\":{}}];" + """var data = [{"type":"bar","x":[20,14,23],"y":["Product A","Product B","Product C"],"orientation":"h","marker":{"pattern":{}}}];""" |> chartGeneratedContains barChart ); testCase "Bar chart layout" ( fun () -> emptyLayout barChart ); testCase "Stacked bar data" ( fun () -> - "var data = [{\"type\":\"bar\",\"x\":[20,14,23],\"y\":[\"Product A\",\"Product B\",\"Product C\"],\"orientation\":\"h\",\"marker\":{},\"name\":\"old\"},{\"type\":\"bar\",\"x\":[8,21,13],\"y\":[\"Product A\",\"Product B\",\"Product C\"],\"orientation\":\"h\",\"marker\":{},\"name\":\"new\"}];" + """var data = [{"type":"bar","name":"old","x":[20,14,23],"y":["Product A","Product B","Product C"],"orientation":"h","marker":{"pattern":{}}},{"type":"bar","name":"new","x":[8,21,13],"y":["Product A","Product B","Product C"],"orientation":"h","marker":{"pattern":{}}}];""" |> chartGeneratedContains stackedBarChart ); testCase "Stacked bar layout" ( fun () -> @@ -129,7 +129,7 @@ let ``Bar and column charts`` = |> chartGeneratedContains stackedColumnChart ); testCase "Stacked column data" ( fun () -> - "var data = [{\"type\":\"bar\",\"x\":[\"Product A\",\"Product B\",\"Product C\"],\"y\":[20,14,23],\"marker\":{},\"name\":\"old\"},{\"type\":\"bar\",\"x\":[\"Product A\",\"Product B\",\"Product C\"],\"y\":[8,21,13],\"marker\":{},\"name\":\"new\"}];" + """var data = [{"type":"bar","name":"old","x":["Product A","Product B","Product C"],"y":[20,14,23],"orientation":"v","marker":{"pattern":{}}},{"type":"bar","name":"new","x":["Product A","Product B","Product C"],"y":[8,21,13],"orientation":"v","marker":{"pattern":{}}}];""" |> chartGeneratedContains stackedColumnChart ); testCase "Stacked column layout" ( fun () ->