Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to DynamicObj v4 #472

Merged
merged 18 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
port trace2d to dynobj v4
- adjust some Dynobj usage
- fix some unused function args
  • Loading branch information
kMutagene committed Oct 15, 2024
commit 58d270c64f5c6316f802516da54c55493fe76fd6
26 changes: 13 additions & 13 deletions docs/index.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -290,25 +290,25 @@ double[] x = new double[] { 1, 2 };
double[] y = new double[] { 5, 10 };

LinearAxis xAxis = new LinearAxis();
xAxis.SetValue("title", "xAxis");
xAxis.SetValue("showgrid", false);
xAxis.SetValue("showline", true);
xAxis.SetProperty("title", "xAxis");
xAxis.SetProperty("showgrid", false);
xAxis.SetProperty("showline", true);

LinearAxis yAxis = new LinearAxis();
yAxis.SetValue("title", "yAxis");
yAxis.SetValue("showgrid", false);
yAxis.SetValue("showline", true);
yAxis.SetProperty("title", "yAxis");
yAxis.SetProperty("showgrid", false);
yAxis.SetProperty("showline", true);

Layout layout = new Layout();
layout.SetValue("xaxis", xAxis);
layout.SetValue("yaxis", yAxis);
layout.SetValue("showlegend", true);
layout.SetProperty("xaxis", xAxis);
layout.SetProperty("yaxis", yAxis);
layout.SetProperty("showlegend", true);

Trace trace = new Trace("scatter");
trace.SetValue("x", x);
trace.SetValue("y", y);
trace.SetValue("mode", "markers");
trace.SetValue("name", "Hello from C#");
trace.SetProperty("x", x);
trace.SetProperty("y", y);
trace.SetProperty("mode", "markers");
trace.SetProperty("name", "Hello from C#");

GenericChart
.ofTraceObject(true, trace)
Expand Down
6 changes: 3 additions & 3 deletions src/Plotly.NET.ImageExport/PuppeteerSharpRenderer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ type PuppeteerSharpRenderer() =

gChart
|> GenericChart.mapConfig (fun c ->
DynObj.setValue c "responsive" true
DynObj.SetProperty c "responsive" true
c)
|> GenericChart.mapLayout (fun l ->
DynObj.setValue l "width" "100%"
DynObj.setValue l "height" "100%"
DynObj.SetProperty l "width" "100%"
DynObj.SetProperty l "height" "100%"
l)
|> GenericChart.toEmbeddedHTML
// this should be done via regex, as this only captures the default width and height.
Expand Down
6 changes: 3 additions & 3 deletions src/Plotly.NET/Layout/ObjectAbstractions/3D/Scene.fs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ type Scene() =
/// <param name="xAxis">The new x axis object</param>
static member setXAxis(xAxis: LinearAxis) =
(fun (scene: Scene) ->
scene.SetValue("xaxis", xAxis)
scene.SetProperty("xaxis", xAxis)
scene)

/// <summary>
Expand All @@ -143,7 +143,7 @@ type Scene() =
/// <param name="yAxis">The new y axis object</param>
static member setYAxis(yAxis: LinearAxis) =
(fun (scene: Scene) ->
scene.SetValue("yaxis", yAxis)
scene.SetProperty("yaxis", yAxis)
scene)

/// <summary>
Expand All @@ -161,5 +161,5 @@ type Scene() =
/// <param name="zAxis">The new z axis object</param>
static member setZAxis(zAxis: LinearAxis) =
(fun (scene: Scene) ->
scene.SetValue("zaxis", zAxis)
scene.SetProperty("zaxis", zAxis)
scene)
4 changes: 2 additions & 2 deletions src/Plotly.NET/Layout/ObjectAbstractions/Polar/Polar.fs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ type Polar() =
/// <param name="angularAxis">The new AngularAxis object</param>
static member setAngularAxis(angularAxis: AngularAxis) =
(fun (polar: Polar) ->
polar.SetValue("angularaxis", angularAxis)
polar.SetProperty("angularaxis", angularAxis)
polar)

/// <summary>
Expand All @@ -124,5 +124,5 @@ type Polar() =
/// <param name="radialAxis">The new RadialAxis object</param>
static member setRadialAxis(radialAxis: RadialAxis) =
(fun (polar: Polar) ->
polar.SetValue("radialaxis", radialAxis)
polar.SetProperty("radialaxis", radialAxis)
polar)
4 changes: 2 additions & 2 deletions src/Plotly.NET/Layout/ObjectAbstractions/Smith/Smith.fs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type Smith() =
/// <param name="imaginaryAxis">The new ImaginaryAxis object</param>
static member setImaginaryAxis(imaginaryAxis: ImaginaryAxis) =
(fun (smith: Smith) ->
smith.SetValue("imaginaryaxis", imaginaryAxis)
smith.SetProperty("imaginaryaxis", imaginaryAxis)
smith)

/// <summary>
Expand All @@ -95,5 +95,5 @@ type Smith() =
/// <param name="realAxis">The new RealAxis object</param>
static member setRealAxis(realAxis: RealAxis) =
(fun (smith: Smith) ->
smith.SetValue("realaxis", realAxis)
smith.SetProperty("realaxis", realAxis)
smith)
6 changes: 3 additions & 3 deletions src/Plotly.NET/Layout/ObjectAbstractions/Ternary/Ternary.fs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ type Ternary() =
/// <param name="aAxis">The new a axis object</param>
static member setAAxis(aAxis: LinearAxis) =
(fun (ternary: Ternary) ->
ternary.SetValue("aaxis", aAxis)
ternary.SetProperty("aaxis", aAxis)
ternary)

/// <summary>
Expand All @@ -106,7 +106,7 @@ type Ternary() =
/// <param name="bAxis">The new b axis object</param>
static member setBAxis(bAxis: LinearAxis) =
(fun (ternary: Ternary) ->
ternary.SetValue("baxis", bAxis)
ternary.SetProperty("baxis", bAxis)
ternary)

/// <summary>
Expand All @@ -124,5 +124,5 @@ type Ternary() =
/// <param name="cAxis">The new c axis object</param>
static member setCAxis(cAxis: LinearAxis) =
(fun (ternary: Ternary) ->
ternary.SetValue("caxis", cAxis)
ternary.SetProperty("caxis", cAxis)
ternary)
87 changes: 39 additions & 48 deletions src/Plotly.NET/Traces/Trace.fs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type Trace(traceTypeName: string) =
/// <param name="marker">The new marker object</param>
static member setMarker(marker: Marker) =
(fun (trace: ('T :> Trace)) ->
trace.SetValue("marker", marker)
trace.SetProperty("marker", marker)
trace)

/// <summary>
Expand All @@ -49,7 +49,7 @@ type Trace(traceTypeName: string) =
static member updateMarker(marker: Marker) =
(fun (trace: #Trace) ->
let combined =
(DynObj.combine (trace |> Trace.getMarker) marker) :?> Marker
(DynObj.combine (trace |> Trace.getMarker) marker)

trace |> Trace.setMarker combined)

Expand All @@ -68,7 +68,7 @@ type Trace(traceTypeName: string) =
/// <param name="line">The new line object</param>
static member setLine(line: Line) =
(fun (trace: #Trace) ->
trace.SetValue("line", line)
trace.SetProperty("line", line)
trace)

/// <summary>
Expand All @@ -78,7 +78,7 @@ type Trace(traceTypeName: string) =
static member updateLine(line: Line) =
(fun (trace: #Trace) ->
let combined =
(DynObj.combine (trace |> Trace.getLine) line) :?> Line
(DynObj.combine (trace |> Trace.getLine) line)

trace |> Trace.setLine combined)

Expand All @@ -97,7 +97,7 @@ type Trace(traceTypeName: string) =
/// <param name="error">The new error object</param>
static member setXError(error: Error) =
(fun (trace: #Trace) ->
trace.SetValue("error_x", error)
trace.SetProperty("error_x", error)
trace)

/// <summary>
Expand All @@ -107,7 +107,7 @@ type Trace(traceTypeName: string) =
static member updateXError(error: Error) =
(fun (trace: #Trace) ->
let combined =
(DynObj.combine (trace |> Trace.getXError) error) :?> Error
(DynObj.combine (trace |> Trace.getXError) error)

trace |> Trace.setXError combined)

Expand All @@ -126,7 +126,7 @@ type Trace(traceTypeName: string) =
/// <param name="error">The new error object</param>
static member setYError(error: Error) =
(fun (trace: #Trace) ->
trace.SetValue("error_y", error)
trace.SetProperty("error_y", error)
trace)

/// <summary>
Expand All @@ -136,7 +136,7 @@ type Trace(traceTypeName: string) =
static member updateYError(error: Error) =
(fun (trace: #Trace) ->
let combined =
(DynObj.combine (trace |> Trace.getYError) error) :?> Error
(DynObj.combine (trace |> Trace.getYError) error)

trace |> Trace.setYError combined)

Expand All @@ -155,7 +155,7 @@ type Trace(traceTypeName: string) =
/// <param name="error">The new error object</param>
static member setZError(error: Error) =
(fun (trace: #Trace) ->
trace.SetValue("error_z", error)
trace.SetProperty("error_z", error)
trace)

/// <summary>
Expand All @@ -165,7 +165,7 @@ type Trace(traceTypeName: string) =
static member updateZError(error: Error) =
(fun (trace: #Trace) ->
let combined =
(DynObj.combine (trace |> Trace.getZError) error) :?> Error
(DynObj.combine (trace |> Trace.getZError) error)

trace |> Trace.setZError combined)

Expand Down Expand Up @@ -193,7 +193,7 @@ type Trace(traceTypeName: string) =
StyleParam.SubPlotId.ColorAxis colorAxisId

(fun (trace: #Trace) ->
trace.SetValue("coloraxis", StyleParam.SubPlotId.convert id)
trace.SetProperty("coloraxis", StyleParam.SubPlotId.convert id)
trace)

/// <summary>
Expand All @@ -220,7 +220,7 @@ type Trace(traceTypeName: string) =
StyleParam.SubPlotId.Legend legendId

(fun (trace: #Trace) ->
trace.SetValue("legend", StyleParam.SubPlotId.convert id)
trace.SetProperty("legend", StyleParam.SubPlotId.convert id)
trace)

/// <summary>
Expand All @@ -238,7 +238,7 @@ type Trace(traceTypeName: string) =
/// <param name="domain">The new domain</param>
static member setDomain(domain: Domain) =
(fun (trace: ('T :> Trace)) ->
trace.SetValue("domain", domain)
trace.SetProperty("domain", domain)
trace)

/// <summary>
Expand All @@ -248,7 +248,7 @@ type Trace(traceTypeName: string) =
static member updateDomain(domain: Domain) =
(fun (trace: #Trace) ->
let combined =
(DynObj.combine (trace |> Trace.getDomain) domain) :?> Domain
(DynObj.combine (trace |> Trace.getDomain) domain)

trace |> Trace.setDomain combined)

Expand All @@ -267,7 +267,7 @@ type Trace(traceTypeName: string) =
/// <param name="stackgroup">The new stackgroup</param>
static member setStackGroup(stackgroup: string) =
(fun (trace: ('T :> Trace)) ->
trace.SetValue("stackgroup", stackgroup)
trace.SetProperty("stackgroup", stackgroup)
trace)

/// <summary>
Expand All @@ -286,7 +286,7 @@ type Trace(traceTypeName: string) =
static member setColorBar(colorBar: ColorBar) =
(fun (trace: ('T :> Trace)) ->

trace.SetValue("colorbar", colorBar)
trace.SetProperty("colorbar", colorBar)
trace)

/// <summary>
Expand All @@ -296,7 +296,7 @@ type Trace(traceTypeName: string) =
static member updateColorBar(colorBar: ColorBar) =
(fun (trace: #Trace) ->
let combined =
(DynObj.combine (trace |> Trace.getColorBar) colorBar) :?> ColorBar
DynObj.combine (trace |> Trace.getColorBar) colorBar

trace |> Trace.setColorBar combined)

Expand Down Expand Up @@ -327,16 +327,14 @@ type TraceStyle() =
[<Optional; DefaultParameterValue(null)>] ?LegendGroup: string,
[<Optional; DefaultParameterValue(null)>] ?LegendGroupTitle: Title
) =
(fun (trace: ('T :> Trace)) ->

Name |> DynObj.setOptionalProperty trace "name"
Visible |> DynObj.setOptionalPropertyBy trace "visible" StyleParam.Visible.convert
ShowLegend |> DynObj.setOptionalProperty trace "showlegend"
LegendRank |> DynObj.setOptionalProperty trace "legendrank"
LegendGroup |> DynObj.setOptionalProperty trace "legendgroup"
LegendGroupTitle |> DynObj.setOptionalProperty trace "legendgrouptitle"

trace)
fun (trace: #Trace) ->
trace
|> DynObj.withOptionalProperty "name" Name
|> DynObj.withOptionalPropertyBy "visible" Visible StyleParam.Visible.convert
|> DynObj.withOptionalProperty "showlegend" ShowLegend
|> DynObj.withOptionalProperty "legendrank" LegendRank
|> DynObj.withOptionalProperty "legendgroup" LegendGroup
|> DynObj.withOptionalProperty "legendgrouptitle" LegendGroupTitle

/// <summary>
/// Returns a function that applies the given styles to the trace's marker object. Overwrites attributes with the same name that are already set.
Expand Down Expand Up @@ -704,13 +702,11 @@ type TraceStyle() =
[<Optional; DefaultParameterValue(null)>] ?Selected: TraceSelection,
[<Optional; DefaultParameterValue(null)>] ?Unselected: TraceSelection
) =
(fun (trace: ('T :> Trace)) ->

SelectedPoints |> DynObj.setOptionalProperty trace "selectedpoints"
Selected |> DynObj.setOptionalProperty trace "selected"
Unselected |> DynObj.setOptionalProperty trace "unselected"

trace)
fun (trace: #Trace) ->
trace
|> DynObj.withOptionalProperty "selectedpoints" SelectedPoints
|> DynObj.withOptionalProperty "selected" Selected
|> DynObj.withOptionalProperty "unselected" Unselected

/// <summary>
/// Returns a function that applies the given styles to the trace's text items.
Expand Down Expand Up @@ -742,20 +738,15 @@ type TraceStyle() =
[<Optional; DefaultParameterValue(null)>] ?MultiHoverTemplate: seq<string>,
[<Optional; DefaultParameterValue(null)>] ?TextFont: Font
) =
(fun (trace: ('T :> Trace)) ->
(Text, MultiText) |> DynObj.setOptionalSingleOrMultiProperty trace "text"

(TextPosition, MultiTextPosition)
|> DynObj.setSingleOrMultiOptBy trace "textposition" StyleParam.TextPosition.convert

(TextTemplate, MultiTextTemplate) |> DynObj.setOptionalSingleOrMultiProperty trace "texttemplate"
(HoverText, MultiHoverText) |> DynObj.setOptionalSingleOrMultiProperty trace "hovertext"
HoverInfo |> DynObj.setOptionalPropertyBy trace "hoverinfo" StyleParam.HoverInfo.convert
(HoverTemplate, MultiHoverTemplate) |> DynObj.setOptionalSingleOrMultiProperty trace "hovertemplate"

TextFont |> DynObj.setOptionalProperty trace "textfont"

trace)
fun (trace: #Trace) ->
trace
|> DynObj.withOptionalSingleOrMultiProperty "text" (Text, MultiText)
|> DynObj.withOptionalSingleOrMultiPropertyBy "textposition" (TextPosition, MultiTextPosition) StyleParam.TextPosition.convert
|> DynObj.withOptionalSingleOrMultiProperty "texttemplate" (TextTemplate, MultiTextTemplate)
|> DynObj.withOptionalSingleOrMultiProperty "hovertext" (HoverText, MultiHoverText)
|> DynObj.withOptionalPropertyBy "hoverinfo" HoverInfo StyleParam.HoverInfo.convert
|> DynObj.withOptionalSingleOrMultiProperty "hovertemplate" (HoverTemplate, MultiHoverTemplate)
|> DynObj.withOptionalProperty "textfont" TextFont

// <summary>
/// Returns a function that applies the given styles to the trace's domain object.
Expand Down
Loading
Loading