Skip to content

Commit bdcbd52

Browse files
committed
Add Image trace style
1 parent d94ffa7 commit bdcbd52

2 files changed

Lines changed: 109 additions & 0 deletions

File tree

src/Plotly.NET/CommonAbstractions/StyleParams.fs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,44 @@ module StyleParam =
314314
// #C#
315315
//--------------------------
316316

317+
318+
[<RequireQualifiedAccess>]
319+
type ColorModel =
320+
| RGB
321+
| RGBA
322+
| RGBA256
323+
| HSL
324+
| HSLA
325+
326+
static member toString = function
327+
| RGB -> "rgb"
328+
| RGBA -> "rgba"
329+
| RGBA256 -> "rgba256"
330+
| HSL -> "hsl"
331+
| HSLA -> "hsla"
332+
333+
static member convert = ColorModel.toString >> box
334+
override this.ToString() = this |> ColorModel.toString
335+
member this.Convert() = this |> ColorModel.convert
336+
337+
[<RequireQualifiedAccess>]
338+
type ColorComponentBound =
339+
| RGB of R:int * G:int * B:int
340+
| RGBA of R:int * G:int * B:int * A:int
341+
| RGBA256 of int*int*int*int
342+
| HSL of H:int * S:int * L:int
343+
| HSLA of H:int * S:int * L:int * A:int
344+
345+
static member convert = function
346+
| RGB (r,g,b) -> [r;g;b] |> box
347+
| RGBA (r,g,b,a) -> [r;g;b;a] |> box
348+
| RGBA256 (i,d,k,m) -> [i;d;k;m] |> box
349+
| HSL (h,s,l) -> [h;s;l] |> box
350+
| HSLA (h,s,l,a) -> [h;s;l;a] |> box
351+
352+
member this.Convert() = this |> ColorComponentBound.convert
353+
354+
317355
[<RequireQualifiedAccess>]
318356
type ClickToShow =
319357
| False | OnOff | OnOut

src/Plotly.NET/Traces/Trace2D.fs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,77 @@ type Trace2DStyle() =
946946
// out ->
947947
heatmap
948948
)
949+
950+
// Applies the styles of heatmap to TraceObjects
951+
static member Image
952+
(
953+
[<Optional;DefaultParameterValue(null)>] ?Name : string,
954+
[<Optional;DefaultParameterValue(null)>] ?Visible : StyleParam.Visible,
955+
[<Optional;DefaultParameterValue(null)>] ?ShowLegend : bool,
956+
[<Optional;DefaultParameterValue(null)>] ?LegendRank : int,
957+
[<Optional;DefaultParameterValue(null)>] ?LegendGroup : string,
958+
[<Optional;DefaultParameterValue(null)>] ?LegendGroupTitle : Title,
959+
[<Optional;DefaultParameterValue(null)>] ?Opacity : float,
960+
[<Optional;DefaultParameterValue(null)>] ?Ids : seq<#IConvertible>,
961+
[<Optional;DefaultParameterValue(null)>] ?X : seq<#IConvertible>,
962+
[<Optional;DefaultParameterValue(null)>] ?X0 : #IConvertible,
963+
[<Optional;DefaultParameterValue(null)>] ?DX : #IConvertible,
964+
[<Optional;DefaultParameterValue(null)>] ?Y : seq<#IConvertible>,
965+
[<Optional;DefaultParameterValue(null)>] ?Y0 : #IConvertible,
966+
[<Optional;DefaultParameterValue(null)>] ?DY : #IConvertible,
967+
[<Optional;DefaultParameterValue(null)>] ?Z : seq<#seq<#IConvertible>>,
968+
[<Optional;DefaultParameterValue(null)>] ?Source : string,
969+
[<Optional;DefaultParameterValue(null)>] ?Text : seq<#IConvertible>,
970+
[<Optional;DefaultParameterValue(null)>] ?HoverText : string,
971+
[<Optional;DefaultParameterValue(null)>] ?HoverInfo : StyleParam.HoverInfo,
972+
[<Optional;DefaultParameterValue(null)>] ?HoverTemplate : string,
973+
[<Optional;DefaultParameterValue(null)>] ?Meta : string,
974+
[<Optional;DefaultParameterValue(null)>] ?CustomData : seq<#IConvertible>,
975+
[<Optional;DefaultParameterValue(null)>] ?XAxis : StyleParam.LinearAxisId,
976+
[<Optional;DefaultParameterValue(null)>] ?YAxis : StyleParam.LinearAxisId,
977+
[<Optional;DefaultParameterValue(null)>] ?ColorModel : StyleParam.ColorModel,
978+
[<Optional;DefaultParameterValue(null)>] ?ZMax : StyleParam.ColorComponentBound,
979+
[<Optional;DefaultParameterValue(null)>] ?ZMin : StyleParam.ColorComponentBound,
980+
[<Optional;DefaultParameterValue(null)>] ?ZSmooth : StyleParam.SmoothAlg,
981+
[<Optional;DefaultParameterValue(null)>] ?HoverLabel : Hoverlabel,
982+
[<Optional;DefaultParameterValue(null)>] ?UIRevision : string
983+
) =
984+
(fun (image: ('T :> Trace)) ->
985+
986+
Name |> DynObj.setValueOpt image "name"
987+
Visible |> DynObj.setValueOptBy image "visible" StyleParam.Visible.convert
988+
ShowLegend |> DynObj.setValueOpt image "showlegend"
989+
LegendRank |> DynObj.setValueOpt image "legendrank"
990+
LegendGroup |> DynObj.setValueOpt image "legendgroup"
991+
LegendGroupTitle |> DynObj.setValueOpt image "legendgrouptitle"
992+
Opacity |> DynObj.setValueOpt image "opacity"
993+
Ids |> DynObj.setValueOpt image "ids"
994+
X |> DynObj.setValueOpt image "x"
995+
X0 |> DynObj.setValueOpt image "x0"
996+
DX |> DynObj.setValueOpt image "dx"
997+
Y |> DynObj.setValueOpt image "y"
998+
Y0 |> DynObj.setValueOpt image "y0"
999+
DY |> DynObj.setValueOpt image "dy"
1000+
Z |> DynObj.setValueOpt image "z"
1001+
Source |> DynObj.setValueOpt image "source"
1002+
Text |> DynObj.setValueOpt image "text"
1003+
HoverText |> DynObj.setValueOpt image "hovertext"
1004+
HoverInfo |> DynObj.setValueOptBy image "hoverinfo" StyleParam.HoverInfo.convert
1005+
HoverTemplate |> DynObj.setValueOpt image "hovertemplate"
1006+
Meta |> DynObj.setValueOpt image "meta"
1007+
CustomData |> DynObj.setValueOpt image "customdata"
1008+
XAxis |> DynObj.setValueOptBy image "xaxis" StyleParam.LinearAxisId.convert
1009+
YAxis |> DynObj.setValueOptBy image "yaxis" StyleParam.LinearAxisId.convert
1010+
ColorModel |> DynObj.setValueOptBy image "colormodel" StyleParam.ColorModel.convert
1011+
ZMax |> DynObj.setValueOptBy image "zmax" StyleParam.ColorComponentBound.convert
1012+
ZMin |> DynObj.setValueOptBy image "zmin" StyleParam.ColorComponentBound.convert
1013+
ZSmooth |> DynObj.setValueOptBy image "zsmooth" StyleParam.SmoothAlg.convert
1014+
HoverLabel |> DynObj.setValueOpt image "hoverlabel"
1015+
UIRevision |> DynObj.setValueOpt image "uirevision"
1016+
1017+
// out ->
1018+
image
1019+
)
9491020

9501021

9511022
static member Contour

0 commit comments

Comments
 (0)