From 2e8a1ca16f3fecd2782bb6c29b60c4b422ca2c3d Mon Sep 17 00:00:00 2001 From: Benedikt Venn Date: Mon, 7 Feb 2022 15:51:50 +0100 Subject: [PATCH] fix title initialization add Chart.withTitle fix #266 --- src/Plotly.NET/ChartAPI/Chart.fs | 6 ++++++ src/Plotly.NET/CommonAbstractions/StyleParams.fs | 2 ++ src/Plotly.NET/CommonAbstractions/Title.fs | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Plotly.NET/ChartAPI/Chart.fs b/src/Plotly.NET/ChartAPI/Chart.fs index a0ad81a75..6945eebc1 100644 --- a/src/Plotly.NET/ChartAPI/Chart.fs +++ b/src/Plotly.NET/ChartAPI/Chart.fs @@ -1547,6 +1547,12 @@ type Chart = GenericChart.addLayout layout ch) + // Set the title of a Chart + [] + static member withTitle(title) = + (fun (ch: GenericChart) -> + let layout = Layout() |> Layout.style (Title = title) + GenericChart.addLayout layout ch) // Set showLegend of a Chart [] diff --git a/src/Plotly.NET/CommonAbstractions/StyleParams.fs b/src/Plotly.NET/CommonAbstractions/StyleParams.fs index 197bfa918..dd129cf68 100644 --- a/src/Plotly.NET/CommonAbstractions/StyleParams.fs +++ b/src/Plotly.NET/CommonAbstractions/StyleParams.fs @@ -2636,6 +2636,7 @@ module StyleParam = [] type Side = | Top + | TopLeft | Bottom | Left | Right @@ -2643,6 +2644,7 @@ module StyleParam = static member toString = function | Top -> "top" + | TopLeft -> "top left" | Bottom -> "bottom" | Left -> "left" | Right -> "right" diff --git a/src/Plotly.NET/CommonAbstractions/Title.fs b/src/Plotly.NET/CommonAbstractions/Title.fs index 44acfd4ab..e4ac3e2b8 100644 --- a/src/Plotly.NET/CommonAbstractions/Title.fs +++ b/src/Plotly.NET/CommonAbstractions/Title.fs @@ -32,7 +32,7 @@ type Title() = Text |> DynObj.setValueOpt title "text" Font |> DynObj.setValueOpt title "font" Standoff |> DynObj.setValueOpt title "standoff" - Side |> DynObj.setValueOpt title "side" + Side |> DynObj.setValueOptBy title "side" StyleParam.Side.convert X |> DynObj.setValueOpt title "x" Y |> DynObj.setValueOpt title "y"