Skip to content

Commit c1d30b2

Browse files
committed
Add Smith Layout objects
1 parent f18b6bf commit c1d30b2

File tree

5 files changed

+491
-0
lines changed

5 files changed

+491
-0
lines changed

src/Plotly.NET/CommonAbstractions/StyleParams.fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ module StyleParam =
172172
| Ternary of int
173173
| Scene of int
174174
| Carpet of string
175+
| Smith of int
175176

176177
static member toString =
177178
function
@@ -216,6 +217,11 @@ module StyleParam =
216217
"scene"
217218
else
218219
sprintf "scene%i" id
220+
| Smith id ->
221+
if id < 2 then
222+
"smith"
223+
else
224+
sprintf "smith%i" id
219225
| Carpet id -> id
220226

221227
static member convert = SubPlotId.toString >> box

src/Plotly.NET/Layout/Layout.fs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,51 @@ type Layout() =
676676

677677
layout)
678678

679+
/// <summary>
680+
/// Returns Some(smith) if there is a smith object set on the layout with the given id, and None otherwise.
681+
/// </summary>
682+
/// <param name="id">the target Smith id</param>
683+
static member tryGetSmithById(id: StyleParam.SubPlotId) =
684+
(fun (layout: Layout) -> layout.TryGetTypedValue<Smith>(StyleParam.SubPlotId.toString id))
685+
686+
/// <summary>
687+
/// Combines the given Smith object with the one already present on the layout.
688+
/// </summary>
689+
/// <param name="id">The target smith id</param>
690+
/// <param name="smith">The updated smith object.</param>
691+
static member updateSmithById(id: StyleParam.SubPlotId, smith: Smith) =
692+
(fun (layout: Layout) ->
693+
694+
let smith' =
695+
match layout |> Layout.tryGetPolarById (id) with
696+
| Some a -> (DynObj.combine a smith) :?> Smith
697+
| None -> smith
698+
699+
smith' |> DynObj.setValue layout (StyleParam.SubPlotId.toString id)
700+
701+
layout)
702+
703+
/// <summary>
704+
/// Returns the Smith object of the layout with the given id.
705+
///
706+
/// If there is no smith set, returns an empty Smith object.
707+
/// </summary>
708+
/// <param name="id">The target smith id</param>
709+
static member getSmithById(id: StyleParam.SubPlotId) =
710+
(fun (layout: Layout) -> layout |> Layout.tryGetSmithById id |> Option.defaultValue (Smith.init ()))
711+
712+
/// <summary>
713+
/// Sets a smith object on the layout as a dynamic property with the given smith id.
714+
/// </summary>
715+
/// <param name="id">The scene id of the new geo</param>
716+
/// <param name="smith">The smith to add to the layout.</param>
717+
static member setSmith(id: StyleParam.SubPlotId, smith: Smith) =
718+
(fun (layout: Layout) ->
719+
720+
smith |> DynObj.setValue layout (StyleParam.SubPlotId.toString id)
721+
722+
layout)
723+
679724
/// <summary>
680725
/// Returns Some(ColorAxis) if there is a ColorAxis object set on the layout with the given id, and None otherwise.
681726
/// </summary>
Lines changed: 165 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,165 @@
1+
namespace Plotly.NET.LayoutObjects
2+
3+
open Plotly.NET
4+
open DynamicObj
5+
open System
6+
open System.Runtime.InteropServices
7+
8+
9+
/// <summary>Angular axes can be used as a scale for the angular coordinates in polar plots.</summary>
10+
type ImaginaryAxis() =
11+
inherit DynamicObj()
12+
13+
/// <summary>
14+
/// Initialize an ImaginaryAxis object that can be used as a imaginary scale for smith coordinates.
15+
/// </summary>
16+
/// <param name="Color">Sets default for all colors associated with this axis all at once: line, font, tick, and grid colors. Grid color is lightened by blending this with the plot background Individual pieces can override this.</param>
17+
/// <param name="GridColor">Sets the color of the grid lines.</param>
18+
/// <param name="GridWidth">Sets the width (in px) of the grid lines.</param>
19+
/// <param name="HoverFormat">Sets the hover text formatting rule 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"</param>
20+
/// <param name="Layer">Sets the layer on which this axis is displayed. If "above traces", this axis is displayed above all the subplot's traces If "below traces", this axis is displayed below all the subplot's traces, but above the grid lines. Useful when used together with scatter-like traces with `cliponaxis` set to "false" to show markers and/or text nodes above this axis.</param>
21+
/// <param name="LineColor">Sets the axis line color.</param>
22+
/// <param name="LineWidth">Sets the width (in px) of the axis line.</param>
23+
/// <param name="ShowGrid">Determines whether or not grid lines are drawn. If "true", the grid lines are drawn at every tick mark.</param>
24+
/// <param name="ShowLine">Determines whether or not a line bounding this axis is drawn.</param>
25+
/// <param name="ShowTickLabels">Determines whether or not the tick labels are drawn.</param>
26+
/// <param name="ShowTickSuffix">If "all", all tick labels are displayed with a prefix. If "first", only the first tick is displayed with a prefix. If "last", only the last tick is displayed with a suffix. If "none", tick prefixes are hidden.</param>
27+
/// <param name="ShowTickPrefix">Same as `showtickprefix` but for tick suffixes.</param>
28+
/// <param name="TickColor">Sets the tick color.</param>
29+
/// <param name="TickFont">Sets the tick font.</param>
30+
/// <param name="TickFormat">Sets the tick label formatting rule 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"</param>
31+
/// <param name="TickLen">Sets the tick length (in px).</param>
32+
/// <param name="TickPrefix">Sets a tick label prefix.</param>
33+
/// <param name="Ticks">Determines whether ticks are drawn or not. If "", this axis' ticks are not drawn. If "outside" ("inside"), this axis' are drawn outside (inside) the axis lines.</param>
34+
/// <param name="TickSuffix">Sets a tick label suffix.</param>
35+
/// <param name="TickVals">Sets the values at which ticks on this axis appear. Defaults to `realaxis.tickvals` plus the same as negatives and zero.</param>
36+
/// <param name="TickWidth">Sets the tick width (in px).</param>
37+
/// <param name="Visible">A single toggle to hide the axis while preserving interaction like dragging. Default is true when a cheater plot is present on the axis, otherwise false</param>
38+
static member init
39+
(
40+
[<Optional; DefaultParameterValue(null)>] ?Color: Color,
41+
[<Optional; DefaultParameterValue(null)>] ?GridColor: Color,
42+
[<Optional; DefaultParameterValue(null)>] ?GridWidth: int,
43+
[<Optional; DefaultParameterValue(null)>] ?HoverFormat: string,
44+
[<Optional; DefaultParameterValue(null)>] ?Layer: StyleParam.Layer,
45+
[<Optional; DefaultParameterValue(null)>] ?LineColor: Color,
46+
[<Optional; DefaultParameterValue(null)>] ?LineWidth: int,
47+
[<Optional; DefaultParameterValue(null)>] ?ShowGrid: bool,
48+
[<Optional; DefaultParameterValue(null)>] ?ShowLine: bool,
49+
[<Optional; DefaultParameterValue(null)>] ?ShowTickLabels: bool,
50+
[<Optional; DefaultParameterValue(null)>] ?ShowTickSuffix: StyleParam.ShowTickOption,
51+
[<Optional; DefaultParameterValue(null)>] ?ShowTickPrefix: StyleParam.ShowTickOption,
52+
[<Optional; DefaultParameterValue(null)>] ?TickColor: Color,
53+
[<Optional; DefaultParameterValue(null)>] ?TickFont: Font,
54+
[<Optional; DefaultParameterValue(null)>] ?TickFormat: string,
55+
[<Optional; DefaultParameterValue(null)>] ?TickLen: int,
56+
[<Optional; DefaultParameterValue(null)>] ?TickPrefix: string,
57+
[<Optional; DefaultParameterValue(null)>] ?Ticks: StyleParam.TickLabelPosition,
58+
[<Optional; DefaultParameterValue(null)>] ?TickSuffix: string,
59+
[<Optional; DefaultParameterValue(null)>] ?TickVals: seq<#IConvertible>,
60+
[<Optional; DefaultParameterValue(null)>] ?TickWidth: int,
61+
[<Optional; DefaultParameterValue(null)>] ?Visible: bool
62+
) =
63+
ImaginaryAxis()
64+
|> ImaginaryAxis.style (
65+
?Color = Color,
66+
?GridColor = GridColor,
67+
?GridWidth = GridWidth,
68+
?HoverFormat = HoverFormat,
69+
?Layer = Layer,
70+
?LineColor = LineColor,
71+
?LineWidth = LineWidth,
72+
?ShowGrid = ShowGrid,
73+
?ShowLine = ShowLine,
74+
?ShowTickLabels = ShowTickLabels,
75+
?ShowTickSuffix = ShowTickSuffix,
76+
?ShowTickPrefix = ShowTickPrefix,
77+
?TickColor = TickColor,
78+
?TickFont = TickFont,
79+
?TickFormat = TickFormat,
80+
?TickLen = TickLen,
81+
?TickPrefix = TickPrefix,
82+
?Ticks = Ticks,
83+
?TickSuffix = TickSuffix,
84+
?TickVals = TickVals,
85+
?TickWidth = TickWidth,
86+
?Visible = Visible
87+
88+
)
89+
90+
/// <summary>
91+
/// Creates a function that applies the given style parameters to a ImaginaryAxis object
92+
/// </summary>
93+
/// <param name="Color">Sets default for all colors associated with this axis all at once: line, font, tick, and grid colors. Grid color is lightened by blending this with the plot background Individual pieces can override this.</param>
94+
/// <param name="GridColor">Sets the color of the grid lines.</param>
95+
/// <param name="GridWidth">Sets the width (in px) of the grid lines.</param>
96+
/// <param name="HoverFormat">Sets the hover text formatting rule 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"</param>
97+
/// <param name="Layer">Sets the layer on which this axis is displayed. If "above traces", this axis is displayed above all the subplot's traces If "below traces", this axis is displayed below all the subplot's traces, but above the grid lines. Useful when used together with scatter-like traces with `cliponaxis` set to "false" to show markers and/or text nodes above this axis.</param>
98+
/// <param name="LineColor">Sets the axis line color.</param>
99+
/// <param name="LineWidth">Sets the width (in px) of the axis line.</param>
100+
/// <param name="ShowGrid">Determines whether or not grid lines are drawn. If "true", the grid lines are drawn at every tick mark.</param>
101+
/// <param name="ShowLine">Determines whether or not a line bounding this axis is drawn.</param>
102+
/// <param name="ShowTickLabels">Determines whether or not the tick labels are drawn.</param>
103+
/// <param name="ShowTickSuffix">If "all", all tick labels are displayed with a prefix. If "first", only the first tick is displayed with a prefix. If "last", only the last tick is displayed with a suffix. If "none", tick prefixes are hidden.</param>
104+
/// <param name="ShowTickPrefix">Same as `showtickprefix` but for tick suffixes.</param>
105+
/// <param name="TickColor">Sets the tick color.</param>
106+
/// <param name="TickFont">Sets the tick font.</param>
107+
/// <param name="TickFormat">Sets the tick label formatting rule 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"</param>
108+
/// <param name="TickLen">Sets the tick length (in px).</param>
109+
/// <param name="TickPrefix">Sets a tick label prefix.</param>
110+
/// <param name="Ticks">Determines whether ticks are drawn or not. If "", this axis' ticks are not drawn. If "outside" ("inside"), this axis' are drawn outside (inside) the axis lines.</param>
111+
/// <param name="TickSuffix">Sets a tick label suffix.</param>
112+
/// <param name="TickVals">Sets the values at which ticks on this axis appear. Defaults to `realaxis.tickvals` plus the same as negatives and zero.</param>
113+
/// <param name="TickWidth">Sets the tick width (in px).</param>
114+
/// <param name="Visible">A single toggle to hide the axis while preserving interaction like dragging. Default is true when a cheater plot is present on the axis, otherwise false</param>
115+
static member style
116+
(
117+
[<Optional; DefaultParameterValue(null)>] ?Color: Color,
118+
[<Optional; DefaultParameterValue(null)>] ?GridColor: Color,
119+
[<Optional; DefaultParameterValue(null)>] ?GridWidth: int,
120+
[<Optional; DefaultParameterValue(null)>] ?HoverFormat: string,
121+
[<Optional; DefaultParameterValue(null)>] ?Layer: StyleParam.Layer,
122+
[<Optional; DefaultParameterValue(null)>] ?LineColor: Color,
123+
[<Optional; DefaultParameterValue(null)>] ?LineWidth: int,
124+
[<Optional; DefaultParameterValue(null)>] ?ShowGrid: bool,
125+
[<Optional; DefaultParameterValue(null)>] ?ShowLine: bool,
126+
[<Optional; DefaultParameterValue(null)>] ?ShowTickLabels: bool,
127+
[<Optional; DefaultParameterValue(null)>] ?ShowTickSuffix: StyleParam.ShowTickOption,
128+
[<Optional; DefaultParameterValue(null)>] ?ShowTickPrefix: StyleParam.ShowTickOption,
129+
[<Optional; DefaultParameterValue(null)>] ?TickColor: Color,
130+
[<Optional; DefaultParameterValue(null)>] ?TickFont: Font,
131+
[<Optional; DefaultParameterValue(null)>] ?TickFormat: string,
132+
[<Optional; DefaultParameterValue(null)>] ?TickLen: int,
133+
[<Optional; DefaultParameterValue(null)>] ?TickPrefix: string,
134+
[<Optional; DefaultParameterValue(null)>] ?Ticks: StyleParam.TickLabelPosition,
135+
[<Optional; DefaultParameterValue(null)>] ?TickSuffix: string,
136+
[<Optional; DefaultParameterValue(null)>] ?TickVals: seq<#IConvertible>,
137+
[<Optional; DefaultParameterValue(null)>] ?TickWidth: int,
138+
[<Optional; DefaultParameterValue(null)>] ?Visible: bool
139+
) =
140+
fun (imaginaryAxis: ImaginaryAxis) ->
141+
142+
Color |> DynObj.setValueOpt imaginaryAxis "color"
143+
GridColor |> DynObj.setValueOpt imaginaryAxis "gridcolor"
144+
GridWidth |> DynObj.setValueOpt imaginaryAxis "gridwidth"
145+
HoverFormat |> DynObj.setValueOpt imaginaryAxis "hoverformat"
146+
Layer |> DynObj.setValueOptBy imaginaryAxis "layer" StyleParam.Layer.convert
147+
LineColor |> DynObj.setValueOpt imaginaryAxis "linecolor"
148+
LineWidth |> DynObj.setValueOpt imaginaryAxis "linewidth"
149+
ShowGrid |> DynObj.setValueOpt imaginaryAxis "showgrid"
150+
ShowLine |> DynObj.setValueOpt imaginaryAxis "showline"
151+
ShowTickLabels |> DynObj.setValueOpt imaginaryAxis "showticklabels"
152+
ShowTickSuffix |> DynObj.setValueOptBy imaginaryAxis "showticksuffix" StyleParam.ShowTickOption.convert
153+
ShowTickPrefix |> DynObj.setValueOptBy imaginaryAxis "showtickprefix" StyleParam.ShowTickOption.convert
154+
TickColor |> DynObj.setValueOpt imaginaryAxis "tickcolor"
155+
TickFont |> DynObj.setValueOpt imaginaryAxis "tickfont"
156+
TickFormat |> DynObj.setValueOpt imaginaryAxis "tickformat"
157+
TickLen |> DynObj.setValueOpt imaginaryAxis "ticklen"
158+
TickPrefix |> DynObj.setValueOpt imaginaryAxis "tickprefix"
159+
Ticks |> DynObj.setValueOptBy imaginaryAxis "ticks" StyleParam.TickLabelPosition.convert
160+
TickSuffix |> DynObj.setValueOpt imaginaryAxis "ticksuffix"
161+
TickVals |> DynObj.setValueOpt imaginaryAxis "tickvals"
162+
TickWidth |> DynObj.setValueOpt imaginaryAxis "tickwidth"
163+
Visible |> DynObj.setValueOpt imaginaryAxis "visible"
164+
165+
imaginaryAxis

0 commit comments

Comments
 (0)