Skip to content

Commit c854600

Browse files
committed
Add LayoutImage object
1 parent 1a35c02 commit c854600

4 files changed

Lines changed: 111 additions & 3 deletions

File tree

src/Plotly.NET/CommonAbstractions/StyleParams.fs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,23 @@ module StyleParam =
11191119
// #L#
11201120
//--------------------------
11211121

1122+
1123+
/// Specifies whether shapes are drawn below or above traces. Default is Above
1124+
[<RequireQualifiedAccess>]
1125+
type LayoutImageSizing =
1126+
| Fill
1127+
| Contain
1128+
| Stretch
11221129

1130+
static member toString = function
1131+
| Fill -> "fill"
1132+
| Contain -> "contain"
1133+
| Stretch -> "stretch"
1134+
1135+
static member convert = LayoutImageSizing.toString >> box
1136+
override this.ToString() = this |> LayoutImageSizing.toString
1137+
member this.Convert() = this |> LayoutImageSizing.convert
1138+
11231139
/// Specifies whether shapes are drawn below or above traces. Default is Above
11241140
[<RequireQualifiedAccess>]
11251141
type Layer =

src/Plotly.NET/Layout/Layout.fs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ type Layout() =
7676
[<Optional;DefaultParameterValue(null)>] ?ExtendIcicleColors : bool,
7777
[<Optional;DefaultParameterValue(null)>] ?IcicleColorWay : Color,
7878
[<Optional;DefaultParameterValue(null)>] ?Annotations : seq<Annotation>,
79-
[<Optional;DefaultParameterValue(null)>] ?Shapes : seq<Shape>
79+
[<Optional;DefaultParameterValue(null)>] ?Shapes : seq<Shape>,
80+
[<Optional;DefaultParameterValue(null)>] ?Images : seq<LayoutImage>
8081
) =
8182
Layout()
8283
|> Layout.style
@@ -145,7 +146,8 @@ type Layout() =
145146
?ExtendIcicleColors = ExtendIcicleColors ,
146147
?IcicleColorWay = IcicleColorWay ,
147148
?Annotations = Annotations ,
148-
?Shapes = Shapes
149+
?Shapes = Shapes ,
150+
?Images = Images
149151
)
150152

151153
// Applies the styles to Layout()
@@ -215,7 +217,8 @@ type Layout() =
215217
[<Optional;DefaultParameterValue(null)>] ?ExtendIcicleColors : bool,
216218
[<Optional;DefaultParameterValue(null)>] ?IcicleColorWay : Color,
217219
[<Optional;DefaultParameterValue(null)>] ?Annotations : seq<Annotation>,
218-
[<Optional;DefaultParameterValue(null)>] ?Shapes : seq<Shape>
220+
[<Optional;DefaultParameterValue(null)>] ?Shapes : seq<Shape>,
221+
[<Optional;DefaultParameterValue(null)>] ?Images : seq<LayoutImage>
219222
) =
220223
(fun (layout:Layout) ->
221224

@@ -284,6 +287,7 @@ type Layout() =
284287
IcicleColorWay |> DynObj.setValueOpt layout "iciclecolorway"
285288
Annotations |> DynObj.setValueOpt layout "annotations"
286289
Shapes |> DynObj.setValueOpt layout "shapes"
290+
Images |> DynObj.setValueOpt layout "images"
287291

288292
layout
289293
)
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
namespace Plotly.NET.LayoutObjects
2+
3+
open Plotly.NET
4+
open DynamicObj
5+
open System
6+
open System.Runtime.InteropServices
7+
8+
/// Dimensions type inherits from dynamic object
9+
type LayoutImage () =
10+
inherit DynamicObj ()
11+
12+
static member init
13+
(
14+
?Layer : StyleParam.Layer,
15+
?Name : string,
16+
?Opacity : float,
17+
?SizeX : int,
18+
?SizeY : int,
19+
?Sizing : StyleParam.LayoutImageSizing,
20+
?Source : string,
21+
?TemplateItemname : string,
22+
?Visible : bool,
23+
?X : #IConvertible,
24+
?XAnchor : StyleParam.XAnchorPosition,
25+
?XRef : string,
26+
?Y : #IConvertible,
27+
?YAnchor : StyleParam.YAnchorPosition,
28+
?YRef : string
29+
) =
30+
LayoutImage ()
31+
|> LayoutImage.style
32+
(
33+
?Layer = Layer ,
34+
?Name = Name ,
35+
?Opacity = Opacity ,
36+
?SizeX = SizeX ,
37+
?SizeY = SizeY ,
38+
?Sizing = Sizing ,
39+
?Source = Source ,
40+
?TemplateItemname = TemplateItemname,
41+
?Visible = Visible ,
42+
?X = X ,
43+
?XAnchor = XAnchor ,
44+
?XRef = XRef ,
45+
?Y = Y ,
46+
?YAnchor = YAnchor ,
47+
?YRef = YRef
48+
)
49+
50+
static member style
51+
(
52+
?Layer : StyleParam.Layer,
53+
?Name : string,
54+
?Opacity : float,
55+
?SizeX : int,
56+
?SizeY : int,
57+
?Sizing : StyleParam.LayoutImageSizing,
58+
?Source : string,
59+
?TemplateItemname : string,
60+
?Visible : bool,
61+
?X : #IConvertible,
62+
?XAnchor : StyleParam.XAnchorPosition,
63+
?XRef : string,
64+
?Y : #IConvertible,
65+
?YAnchor : StyleParam.YAnchorPosition,
66+
?YRef : string
67+
) =
68+
(fun (layoutImage:LayoutImage) ->
69+
70+
Layer |> DynObj.setValueOptBy layoutImage "layer" StyleParam.Layer.convert
71+
Name |> DynObj.setValueOpt layoutImage "name"
72+
Opacity |> DynObj.setValueOpt layoutImage "opacity"
73+
SizeX |> DynObj.setValueOpt layoutImage "sizex"
74+
SizeY |> DynObj.setValueOpt layoutImage "sizey"
75+
Sizing |> DynObj.setValueOptBy layoutImage "sizing" StyleParam.LayoutImageSizing.convert
76+
Source |> DynObj.setValueOpt layoutImage "source"
77+
TemplateItemname |> DynObj.setValueOpt layoutImage "templateitemname"
78+
Visible |> DynObj.setValueOpt layoutImage "visible"
79+
X |> DynObj.setValueOpt layoutImage "x"
80+
XAnchor |> DynObj.setValueOptBy layoutImage "xanchor" StyleParam.XAnchorPosition.convert
81+
XRef |> DynObj.setValueOpt layoutImage "xref"
82+
Y |> DynObj.setValueOpt layoutImage "y"
83+
YAnchor |> DynObj.setValueOptBy layoutImage "yanchor" StyleParam.YAnchorPosition.convert
84+
YRef |> DynObj.setValueOpt layoutImage "yref"
85+
86+
layoutImage
87+
)

src/Plotly.NET/Plotly.NET.fsproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<Compile Include="CommonAbstractions\Font.fs" />
4242
<Compile Include="CommonAbstractions\Title.fs" />
4343
<Compile Include="CommonAbstractions\Line.fs" />
44+
<Compile Include="Layout\ObjectAbstractions\Common\LayoutImage.fs" />
4445
<Compile Include="Layout\ObjectAbstractions\Common\Button.fs" />
4546
<Compile Include="Layout\ObjectAbstractions\Common\RangeSelector.fs" />
4647
<Compile Include="Layout\ObjectAbstractions\Common\RangeSlider.fs" />

0 commit comments

Comments
 (0)