Skip to content

Commit 2c3fb24

Browse files
committed
fix #398:
- move Padding object to Plotly.NET namespace - add `Pad` argument to `Title` - this commit contains breaking changes
1 parent 427f305 commit 2c3fb24

File tree

3 files changed

+42
-25
lines changed

3 files changed

+42
-25
lines changed

src/Plotly.NET/Layout/ObjectAbstractions/Common/Padding.fs renamed to src/Plotly.NET/CommonAbstractions/Padding.fs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Plotly.NET.LayoutObjects
1+
namespace Plotly.NET
22

33
open DynamicObj
44
open System.Runtime.InteropServices
@@ -7,7 +7,7 @@ type Padding() =
77
inherit DynamicObj()
88

99
/// <summary>
10-
/// Set the padding of the slider component along each side
10+
/// Returns a new Padding object with the given styling. Set the padding of the component along each side
1111
/// </summary>
1212
/// <param name="B">The amount of padding (in px) along the bottom of the component</param>
1313
/// <param name="L">The amount of padding (in px) on the left side of the component</param>
@@ -22,6 +22,13 @@ type Padding() =
2222
) =
2323
Padding() |> Padding.style (?B = B, ?L = L, ?R = R, ?T = T)
2424

25+
/// <summary>
26+
/// Returns a function that applies the given styles to a Padding object. Set the padding of the component along each side
27+
/// </summary>
28+
/// <param name="B">The amount of padding (in px) along the bottom of the component</param>
29+
/// <param name="L">The amount of padding (in px) on the left side of the component</param>
30+
/// <param name="R">The amount of padding (in px) on the right side of the component</param>
31+
/// <param name="T">The amount of padding (in px) along the top of the component</param>
2532
static member style
2633
(
2734
[<Optional; DefaultParameterValue(null)>] ?B: int,

src/Plotly.NET/CommonAbstractions/Title.fs

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,88 +8,98 @@ type Title() =
88
inherit DynamicObj()
99

1010
/// <summary>
11-
/// Returns a new Title object with the given styles. Note that this is a multi-purpose object that can be used as plot or different axis titles, with some attributes being only used in some layouts.
11+
/// Returns a new Title object with the given styling. Note that this is a multi-purpose object that can be used as plot or different axis titles, with some attributes being only used in some layouts Note that this is a multi-purpose object that can be used as plot or different axis titles, with some attributes being only used in some layouts
1212
/// </summary>
1313
/// <param name="Text">For all titles: Sets the plot's title. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.</param>
14-
/// <param name="AutoMargin">For plot titles: Determines whether the title can automatically push the figure margins. If `yref='paper'` then the margin will expand to ensure that the title doesn’t overlap with the edges of the container. If `yref='container'` then the margins will ensure that the title doesn’t overlap with the plot area, tick labels, and axis titles. If `automargin=true` and the margins need to be expanded, then y will be set to a default 1 and yanchor will be set to an appropriate default to ensure that minimal margin space is needed. Note that when `yref='paper'`, only 1 or 0 are allowed y values. Invalid values will be reset to the default 1.</param>
1514
/// <param name="Font">For all titles: Sets the title font. Note that the title's font used to be customized by the now deprecated `titlefont` attribute.</param>
16-
/// <param name="Standoff">For axis titles: Sets the standoff distance (in px) between the axis labels and the title text The default value is a function of the axis tick labels, the title `font.size` and the axis `linewidth`. Note that the axis title position is always constrained within the margins, so the actual standoff distance is always less than the set or default value. By setting `standoff` and turning on `automargin`, plotly.js will push the margins to fit the axis title at given standoff distance.</param>
17-
/// <param name="Side">For colorbar titles: Determines the location of color bar's title with respect to the color bar. Defaults to "top" when `orientation` if "v" and defaults to "right" when `orientation` if "h". Note that the title's location used to be set by the now deprecated `titleside` attribute.</param>
15+
/// <param name="AutoMargin">For plot titles: Determines whether the title can automatically push the figure margins. If `yref='paper'` then the margin will expand to ensure that the title doesn’t overlap with the edges of the container. If `yref='container'` then the margins will ensure that the title doesn’t overlap with the plot area, tick labels, and axis titles. If `automargin=true` and the margins need to be expanded, then y will be set to a default 1 and yanchor will be set to an appropriate default to ensure that minimal margin space is needed. Note that when `yref='paper'`, only 1 or 0 are allowed y values. Invalid values will be reset to the default 1.</param>
16+
/// <param name="Pad">For plot titles: Sets the padding of the title. Each padding value only applies when the corresponding `xanchor`/`yanchor` value is set accordingly. E.g. for left padding to take effect, `xanchor` must be set to "left". The same rule applies if `xanchor`/`yanchor` is determined automatically. Padding is muted if the respective anchor value is "middle"/"center".</param>
1817
/// <param name="X">For plot titles: Sets the x position with respect to `xref` in normalized coordinates from "0" (left) to "1" (right).</param>
1918
/// <param name="XAnchor">For plot titles: Sets the title's horizontal alignment with respect to its x position. "left" means that the title starts at x, "right" means that the title ends at x and "center" means that the title's center is at x. "auto" divides `xref` by three and calculates the `xanchor` value automatically based on the value of `x`.</param>
2019
/// <param name="XRef">For plot titles: Sets the container `x` refers to. "container" spans the entire `width` of the plot. "paper" refers to the width of the plotting area only.</param>
2120
/// <param name="Y">For plot titles: Sets the y position with respect to `yref` in normalized coordinates from "0" (bottom) to "1" (top). "auto" places the baseline of the title onto the vertical center of the top margin.</param>
2221
/// <param name="YAnchor">For plot titles: Sets the title's vertical alignment with respect to its y position. "top" means that the title's cap line is at y, "bottom" means that the title's baseline is at y and "middle" means that the title's midline is at y. "auto" divides `yref` by three and calculates the `yanchor` value automatically based on the value of `y`.</param>
2322
/// <param name="YRef">For plot titles: Sets the container `y` refers to. "container" spans the entire `height` of the plot. "paper" refers to the height of the plotting area only.</param>
23+
/// <param name="Standoff">For axis titles: Sets the standoff distance (in px) between the axis labels and the title text The default value is a function of the axis tick labels, the title `font.size` and the axis `linewidth`. Note that the axis title position is always constrained within the margins, so the actual standoff distance is always less than the set or default value. By setting `standoff` and turning on `automargin`, plotly.js will push the margins to fit the axis title at given standoff distance.</param>
24+
/// <param name="Side">For colorbar titles: Determines the location of color bar's title with respect to the color bar. Defaults to "top" when `orientation` if "v" and defaults to "right" when `orientation` if "h". Note that the title's location used to be set by the now deprecated `titleside` attribute.</param>
2425
static member init
2526
(
2627
[<Optional; DefaultParameterValue(null)>] ?Text: string,
27-
[<Optional; DefaultParameterValue(null)>] ?AutoMargin: bool,
2828
[<Optional; DefaultParameterValue(null)>] ?Font: Font,
29-
[<Optional; DefaultParameterValue(null)>] ?Standoff: int,
30-
[<Optional; DefaultParameterValue(null)>] ?Side: StyleParam.Side,
29+
[<Optional; DefaultParameterValue(null)>] ?AutoMargin: bool,
30+
[<Optional; DefaultParameterValue(null)>] ?Pad: Padding,
3131
[<Optional; DefaultParameterValue(null)>] ?X: float,
3232
[<Optional; DefaultParameterValue(null)>] ?XAnchor: StyleParam.XAnchorPosition,
3333
[<Optional; DefaultParameterValue(null)>] ?XRef: string,
3434
[<Optional; DefaultParameterValue(null)>] ?Y: float,
3535
[<Optional; DefaultParameterValue(null)>] ?YAnchor: StyleParam.YAnchorPosition,
36-
[<Optional; DefaultParameterValue(null)>] ?YRef: string
36+
[<Optional; DefaultParameterValue(null)>] ?YRef: string,
37+
// For axis titles
38+
[<Optional; DefaultParameterValue(null)>] ?Standoff: int,
39+
// For colorbar titles
40+
[<Optional; DefaultParameterValue(null)>] ?Side: StyleParam.Side
3741
) =
3842
Title()
3943
|> Title.style (
4044
?Text = Text,
41-
?AutoMargin = AutoMargin,
4245
?Font = Font,
43-
?Standoff = Standoff,
44-
?Side = Side,
46+
?AutoMargin = AutoMargin,
47+
?Pad = Pad,
4548
?X = X,
4649
?XAnchor = XAnchor,
4750
?XRef = XRef,
4851
?Y = Y,
4952
?YAnchor = YAnchor,
50-
?YRef = YRef
53+
?YRef = YRef,
54+
?Standoff = Standoff,
55+
?Side = Side
5156
)
5257

5358
/// <summary>
5459
/// Returns a function that applies the given styles to a Title object. Note that this is a multi-purpose object that can be used as plot or different axis titles, with some attributes being only used in some layouts
5560
/// </summary>
5661
/// <param name="Text">For all titles: Sets the plot's title. Note that before the existence of `title.text`, the title's contents used to be defined as the `title` attribute itself. This behavior has been deprecated.</param>
57-
/// <param name="AutoMargin">For plot titles: Determines whether the title can automatically push the figure margins. If `yref='paper'` then the margin will expand to ensure that the title doesn’t overlap with the edges of the container. If `yref='container'` then the margins will ensure that the title doesn’t overlap with the plot area, tick labels, and axis titles. If `automargin=true` and the margins need to be expanded, then y will be set to a default 1 and yanchor will be set to an appropriate default to ensure that minimal margin space is needed. Note that when `yref='paper'`, only 1 or 0 are allowed y values. Invalid values will be reset to the default 1.</param>
5862
/// <param name="Font">For all titles: Sets the title font. Note that the title's font used to be customized by the now deprecated `titlefont` attribute.</param>
59-
/// <param name="Standoff">For axis titles: Sets the standoff distance (in px) between the axis labels and the title text The default value is a function of the axis tick labels, the title `font.size` and the axis `linewidth`. Note that the axis title position is always constrained within the margins, so the actual standoff distance is always less than the set or default value. By setting `standoff` and turning on `automargin`, plotly.js will push the margins to fit the axis title at given standoff distance.</param>
60-
/// <param name="Side">For colorbar titles: Determines the location of color bar's title with respect to the color bar. Defaults to "top" when `orientation` if "v" and defaults to "right" when `orientation` if "h". Note that the title's location used to be set by the now deprecated `titleside` attribute.</param>
63+
/// <param name="AutoMargin">For plot titles: Determines whether the title can automatically push the figure margins. If `yref='paper'` then the margin will expand to ensure that the title doesn’t overlap with the edges of the container. If `yref='container'` then the margins will ensure that the title doesn’t overlap with the plot area, tick labels, and axis titles. If `automargin=true` and the margins need to be expanded, then y will be set to a default 1 and yanchor will be set to an appropriate default to ensure that minimal margin space is needed. Note that when `yref='paper'`, only 1 or 0 are allowed y values. Invalid values will be reset to the default 1.</param>
64+
/// <param name="Pad">For plot titles: Sets the padding of the title. Each padding value only applies when the corresponding `xanchor`/`yanchor` value is set accordingly. E.g. for left padding to take effect, `xanchor` must be set to "left". The same rule applies if `xanchor`/`yanchor` is determined automatically. Padding is muted if the respective anchor value is "middle"/"center".</param>
6165
/// <param name="X">For plot titles: Sets the x position with respect to `xref` in normalized coordinates from "0" (left) to "1" (right).</param>
6266
/// <param name="XAnchor">For plot titles: Sets the title's horizontal alignment with respect to its x position. "left" means that the title starts at x, "right" means that the title ends at x and "center" means that the title's center is at x. "auto" divides `xref` by three and calculates the `xanchor` value automatically based on the value of `x`.</param>
6367
/// <param name="XRef">For plot titles: Sets the container `x` refers to. "container" spans the entire `width` of the plot. "paper" refers to the width of the plotting area only.</param>
6468
/// <param name="Y">For plot titles: Sets the y position with respect to `yref` in normalized coordinates from "0" (bottom) to "1" (top). "auto" places the baseline of the title onto the vertical center of the top margin.</param>
6569
/// <param name="YAnchor">For plot titles: Sets the title's vertical alignment with respect to its y position. "top" means that the title's cap line is at y, "bottom" means that the title's baseline is at y and "middle" means that the title's midline is at y. "auto" divides `yref` by three and calculates the `yanchor` value automatically based on the value of `y`.</param>
6670
/// <param name="YRef">For plot titles: Sets the container `y` refers to. "container" spans the entire `height` of the plot. "paper" refers to the height of the plotting area only.</param>
71+
/// <param name="Standoff">For axis titles: Sets the standoff distance (in px) between the axis labels and the title text The default value is a function of the axis tick labels, the title `font.size` and the axis `linewidth`. Note that the axis title position is always constrained within the margins, so the actual standoff distance is always less than the set or default value. By setting `standoff` and turning on `automargin`, plotly.js will push the margins to fit the axis title at given standoff distance.</param>
72+
/// <param name="Side">For colorbar titles: Determines the location of color bar's title with respect to the color bar. Defaults to "top" when `orientation` if "v" and defaults to "right" when `orientation` if "h". Note that the title's location used to be set by the now deprecated `titleside` attribute.</param>
6773
static member style
6874
(
6975
[<Optional; DefaultParameterValue(null)>] ?Text: string,
70-
[<Optional; DefaultParameterValue(null)>] ?AutoMargin: bool,
7176
[<Optional; DefaultParameterValue(null)>] ?Font: Font,
72-
[<Optional; DefaultParameterValue(null)>] ?Standoff: int,
73-
[<Optional; DefaultParameterValue(null)>] ?Side: StyleParam.Side,
77+
[<Optional; DefaultParameterValue(null)>] ?AutoMargin: bool,
78+
[<Optional; DefaultParameterValue(null)>] ?Pad: Padding,
7479
[<Optional; DefaultParameterValue(null)>] ?X: float,
7580
[<Optional; DefaultParameterValue(null)>] ?XAnchor: StyleParam.XAnchorPosition,
7681
[<Optional; DefaultParameterValue(null)>] ?XRef: string,
7782
[<Optional; DefaultParameterValue(null)>] ?Y: float,
7883
[<Optional; DefaultParameterValue(null)>] ?YAnchor: StyleParam.YAnchorPosition,
79-
[<Optional; DefaultParameterValue(null)>] ?YRef: string
84+
[<Optional; DefaultParameterValue(null)>] ?YRef: string,
85+
// For axis titles
86+
[<Optional; DefaultParameterValue(null)>] ?Standoff: int,
87+
// For colorbar titles
88+
[<Optional; DefaultParameterValue(null)>] ?Side: StyleParam.Side
8089
) =
8190
(fun (title: Title) ->
8291

8392
Text |> DynObj.setValueOpt title "text"
84-
AutoMargin |> DynObj.setValueOpt title "automargin"
8593
Font |> DynObj.setValueOpt title "font"
86-
Standoff |> DynObj.setValueOpt title "standoff"
87-
Side |> DynObj.setValueOptBy title "side" StyleParam.Side.convert
94+
AutoMargin |> DynObj.setValueOpt title "automargin"
95+
Pad |> DynObj.setValueOpt title "pad"
8896
X |> DynObj.setValueOpt title "x"
8997
XAnchor |> DynObj.setValueOptBy title "xanchor" StyleParam.XAnchorPosition.convert
9098
XRef |> DynObj.setValueOpt title "xref"
9199
Y |> DynObj.setValueOpt title "y"
92100
YAnchor |> DynObj.setValueOptBy title "yanchor" StyleParam.YAnchorPosition.convert
93101
YRef |> DynObj.setValueOpt title "yref"
102+
Standoff |> DynObj.setValueOpt title "standoff"
103+
Side |> DynObj.setValueOptBy title "side" StyleParam.Side.convert
94104

95105
title)

src/Plotly.NET/Plotly.NET.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@
5050
<Compile Include="CommonAbstractions\TickFormatStop.fs" />
5151
<Compile Include="CommonAbstractions\Frame.fs" />
5252
<Compile Include="CommonAbstractions\Font.fs" />
53+
<Compile Include="CommonAbstractions\Padding.fs" />
5354
<Compile Include="CommonAbstractions\Title.fs" />
5455
<Compile Include="CommonAbstractions\ColorBar.fs" />
5556
<Compile Include="CommonAbstractions\Line.fs" />
56-
<Compile Include="Layout\ObjectAbstractions\Common\Padding.fs" />
5757
<Compile Include="Layout\ObjectAbstractions\Common\LayoutImage.fs" />
5858
<Compile Include="Layout\ObjectAbstractions\Common\Button.fs" />
5959
<Compile Include="Layout\ObjectAbstractions\Common\RangeSelector.fs" />

0 commit comments

Comments
 (0)