Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 831b59d

Browse files
committedOct 15, 2024·
port the rest of plotly.net core project to dynobj v4
1 parent 5064b7b commit 831b59d

File tree

11 files changed

+119
-140
lines changed

11 files changed

+119
-140
lines changed
 

‎src/Plotly.NET/CSharpLayer/GenericChartExtensions.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ module GenericChartExtensions =
426426
member this.withColorBar(colorbar: ColorBar) =
427427
this
428428
|> GenericChart.mapTrace (fun t ->
429-
colorbar |> DynObj.withProperty t "colorbar"
430-
t)
429+
t |> DynObj.withProperty "colorbar" colorbar
430+
)
431431

432432
[<CompiledName("WithColorbar")>]
433433
[<Extension>]
@@ -913,8 +913,8 @@ module GenericChartExtensions =
913913
member this.WithTemplate(template: Template) =
914914
this
915915
|> GenericChart.mapLayout (fun l ->
916-
template |> DynObj.withProperty l "template"
917-
l)
916+
l |> DynObj.withProperty "template" template
917+
)
918918

919919
// TODO: Include withLegend & withLegendStyle
920920

‎src/Plotly.NET/ChartAPI/Chart.fs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ type Chart =
6868
LinearAxis.init (ShowGrid = false, ShowLine = false, ShowTickLabels = false, ZeroLine = false)
6969

7070
let trace = Trace2D.initScatter (id)
71-
trace.Remove("type") |> ignore
71+
trace.RemoveProperty("type") |> ignore
7272

7373
GenericChart.ofTraceObject false trace
7474
|> GenericChart.mapLayout (fun l ->
@@ -3228,8 +3228,8 @@ type Chart =
32283228
let allYAxes = Layout.getYAxes layout |> Seq.map fst
32293229

32303230
// remove all axes from layout. Only cartesian axis in each dimension is supported per grid cell, and leaving anything else on this layout may lead to property name clashes on combine.
3231-
allXAxes |> Seq.iter (fun propName -> layout.Remove(propName) |> ignore)
3232-
allYAxes |> Seq.iter (fun propName -> layout.Remove(propName) |> ignore)
3231+
allXAxes |> Seq.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)
3232+
allYAxes |> Seq.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)
32333233

32343234
let xAnchor, yAnchor =
32353235
if hasSharedAxes then
@@ -3252,7 +3252,7 @@ type Chart =
32523252
let allScenes = Layout.getScenes layout |> Seq.map fst
32533253

32543254
// remove all scenes from layout. Only one scene is supported per grid cell, and leaving anything else on this layout may lead to property name clashes on combine.
3255-
allScenes |> Seq.iter (fun propName -> layout.Remove(propName) |> ignore)
3255+
allScenes |> Seq.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)
32563256

32573257
let sceneAnchor =
32583258
StyleParam.SubPlotId.Scene(i + 1)
@@ -3270,7 +3270,7 @@ type Chart =
32703270
let allPolars = Layout.getPolars layout |> Seq.map fst
32713271

32723272
// remove all polar subplots from layout. Only one polar subplot is supported per grid cell, and leaving anything else on this layout may lead to property name clashes on combine.
3273-
allPolars |> Seq.iter (fun propName -> layout.Remove(propName) |> ignore)
3273+
allPolars |> Seq.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)
32743274

32753275
let polarAnchor =
32763276
StyleParam.SubPlotId.Polar(i + 1)
@@ -3290,7 +3290,7 @@ type Chart =
32903290
let allSmiths = Layout.getSmiths layout |> Seq.map fst
32913291

32923292
// remove all smith subplots from layout. Only one smith subplot is supported per grid cell, and leaving anything else on this layout may lead to property name clashes on combine.
3293-
allSmiths |> Seq.iter (fun propName -> layout.Remove(propName) |> ignore)
3293+
allSmiths |> Seq.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)
32943294

32953295
let polarAnchor =
32963296
StyleParam.SubPlotId.Smith(i + 1)
@@ -3309,7 +3309,7 @@ type Chart =
33093309
let allGeos = Layout.getGeos layout |> Seq.map fst
33103310

33113311
// remove all geo subplots from layout. Only one geo subplot is supported per grid cell, and leaving anything else on this layout may lead to property name clashes on combine.
3312-
allGeos |> Seq.iter (fun propName -> layout.Remove(propName) |> ignore)
3312+
allGeos |> Seq.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)
33133313

33143314
let geoAnchor =
33153315
StyleParam.SubPlotId.Geo(i + 1)
@@ -3329,7 +3329,7 @@ type Chart =
33293329
let allMapboxes = Layout.getMapboxes layout |> Seq.map fst
33303330

33313331
// remove all mapbox subplots from layout. Only one mapbox subplot is supported per grid cell, and leaving anything else on this layout may lead to property name clashes on combine.
3332-
allMapboxes |> Seq.iter (fun propName -> layout.Remove(propName) |> ignore)
3332+
allMapboxes |> Seq.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)
33333333

33343334
let geoAnchor =
33353335
StyleParam.SubPlotId.Geo(i + 1)
@@ -3354,7 +3354,7 @@ type Chart =
33543354
let allTernaries = Layout.getTernaries layout |> Seq.map fst
33553355

33563356
// remove all ternary subplots from layout. Only one ternary subplot is supported per grid cell, and leaving anything else on this layout may lead to property name clashes on combine.
3357-
allTernaries |> Seq.iter (fun propName -> layout.Remove(propName) |> ignore)
3357+
allTernaries |> Seq.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)
33583358

33593359
let ternaryAnchor =
33603360
StyleParam.SubPlotId.Ternary(i + 1)

‎src/Plotly.NET/Config/Config.fs

Lines changed: 39 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -262,57 +262,46 @@ type Config() =
262262
) =
263263
fun (config: Config) ->
264264

265-
StaticPlot |> DynObj.setOptionalProperty config "staticPlot"
266-
TypesetMath |> DynObj.setOptionalProperty config "typesetMath"
267-
PlotlyServerUrl |> DynObj.setOptionalProperty config "plotlyServerUrl"
268-
Editable |> DynObj.setOptionalProperty config "editable"
269-
Edits |> DynObj.setOptionalProperty config "edits"
270-
EditSelection |> DynObj.setOptionalProperty config "editSelection"
271-
Autosizable |> DynObj.setOptionalProperty config "autosizable"
272-
Responsive |> DynObj.setOptionalProperty config "responsive"
273-
FillFrame |> DynObj.setOptionalProperty config "fillFrame"
274-
FrameMargins |> DynObj.setOptionalProperty config "frameMargins"
275-
ScrollZoom |> DynObj.setOptionalPropertyBy config "scrollZoom" StyleParam.ScrollZoom.convert
276-
DoubleClick |> DynObj.setOptionalPropertyBy config "doubleClick" StyleParam.DoubleClick.convert
277-
DoubleClickDelay |> DynObj.setOptionalProperty config "doubleClickDelay"
278-
ShowAxisDragHandles |> DynObj.setOptionalProperty config "showAxisDragHandles"
279-
ShowAxisRangeEntryBoxes |> DynObj.setOptionalProperty config "showAxisRangeEntryBoxes"
280-
ShowTips |> DynObj.setOptionalProperty config "showTips"
281-
ShowLink |> DynObj.setOptionalProperty config "showLink"
282-
LinkText |> DynObj.setOptionalProperty config "linkText"
283-
SendData |> DynObj.setOptionalProperty config "sendData"
284-
ShowSources |> DynObj.setOptionalProperty config "showSources"
285-
DisplayModeBar |> DynObj.setOptionalProperty config "displayModeBar"
286-
ShowSendToCloud |> DynObj.setOptionalProperty config "showSendToCloud"
287-
ShowEditInChartStudio |> DynObj.setOptionalProperty config "showEditInChartStudio"
288-
289-
ModeBarButtonsToRemove
290-
|> DynObj.setOptionalPropertyBy config "modeBarButtonsToRemove" (fun x ->
291-
x |> Seq.map StyleParam.ModeBarButton.toString)
292-
293-
ModeBarButtonsToAdd
294-
|> DynObj.setOptionalPropertyBy config "modeBarButtonsToAdd" (fun x ->
295-
x |> Seq.map StyleParam.ModeBarButton.toString)
296-
297-
ModeBarButtons
298-
|> DynObj.setOptionalPropertyBy config "modeBarButtons" (fun x ->
299-
x |> Seq.map (Seq.map StyleParam.ModeBarButton.toString))
300-
301-
ToImageButtonOptions |> DynObj.setOptionalProperty config "toImageButtonOptions"
302-
Displaylogo |> DynObj.setOptionalProperty config "displaylogo"
303-
Watermark |> DynObj.setOptionalProperty config "watermark"
304-
plotGlPixelRatio |> DynObj.setOptionalProperty config "plotGlPixelRatio"
305-
SetBackground |> DynObj.setOptionalProperty config "setBackground"
306-
TopojsonURL |> DynObj.setOptionalProperty config "topojsonURL"
307-
MapboxAccessToken |> DynObj.setOptionalProperty config "mapboxAccessToken"
308-
Logging |> DynObj.setOptionalProperty config "logging"
309-
NotifyOnLogging |> DynObj.setOptionalProperty config "notifyOnLogging"
310-
QueueLength |> DynObj.setOptionalProperty config "queueLength"
311-
GlobalTransforms |> DynObj.setOptionalProperty config "globalTransforms"
312-
Locale |> DynObj.setOptionalProperty config "locale"
313-
Locales |> DynObj.setOptionalProperty config "locales"
314-
315265
config
266+
|> DynObj.withOptionalProperty "staticPlot" StaticPlot
267+
|> DynObj.withOptionalProperty "typesetMath" TypesetMath
268+
|> DynObj.withOptionalProperty "plotlyServerUrl" PlotlyServerUrl
269+
|> DynObj.withOptionalProperty "editable" Editable
270+
|> DynObj.withOptionalProperty "edits" Edits
271+
|> DynObj.withOptionalProperty "editSelection" EditSelection
272+
|> DynObj.withOptionalProperty "autosizable" Autosizable
273+
|> DynObj.withOptionalProperty "responsive" Responsive
274+
|> DynObj.withOptionalProperty "fillFrame" FillFrame
275+
|> DynObj.withOptionalProperty "frameMargins" FrameMargins
276+
|> DynObj.withOptionalPropertyBy "scrollZoom" ScrollZoom StyleParam.ScrollZoom.convert
277+
|> DynObj.withOptionalPropertyBy "doubleClick" DoubleClick StyleParam.DoubleClick.convert
278+
|> DynObj.withOptionalProperty "doubleClickDelay" DoubleClickDelay
279+
|> DynObj.withOptionalProperty "showAxisDragHandles" ShowAxisDragHandles
280+
|> DynObj.withOptionalProperty "showAxisRangeEntryBoxes"ShowAxisRangeEntryBoxes
281+
|> DynObj.withOptionalProperty "showTips" ShowTips
282+
|> DynObj.withOptionalProperty "showLink" ShowLink
283+
|> DynObj.withOptionalProperty "linkText" LinkText
284+
|> DynObj.withOptionalProperty "sendData" SendData
285+
|> DynObj.withOptionalProperty "showSources" ShowSources
286+
|> DynObj.withOptionalProperty "displayModeBar" DisplayModeBar
287+
|> DynObj.withOptionalProperty "showSendToCloud" ShowSendToCloud
288+
|> DynObj.withOptionalProperty "showEditInChartStudio" ShowEditInChartStudio
289+
|> DynObj.withOptionalPropertyBy "modeBarButtonsToRemove" ModeBarButtonsToRemove (fun x -> x |> Seq.map StyleParam.ModeBarButton.toString)
290+
|> DynObj.withOptionalPropertyBy "modeBarButtonsToAdd" ModeBarButtonsToAdd (fun x -> x |> Seq.map StyleParam.ModeBarButton.toString)
291+
|> DynObj.withOptionalPropertyBy "modeBarButtons" ModeBarButtons (fun x -> x |> Seq.map (Seq.map StyleParam.ModeBarButton.toString))
292+
|> DynObj.withOptionalProperty "toImageButtonOptions" ToImageButtonOptions
293+
|> DynObj.withOptionalProperty "displaylogo" Displaylogo
294+
|> DynObj.withOptionalProperty "watermark" Watermark
295+
|> DynObj.withOptionalProperty "plotGlPixelRatio" plotGlPixelRatio
296+
|> DynObj.withOptionalProperty "setBackground" SetBackground
297+
|> DynObj.withOptionalProperty "topojsonURL" TopojsonURL
298+
|> DynObj.withOptionalProperty "mapboxAccessToken" MapboxAccessToken
299+
|> DynObj.withOptionalProperty "logging" Logging
300+
|> DynObj.withOptionalProperty "notifyOnLogging" NotifyOnLogging
301+
|> DynObj.withOptionalProperty "queueLength" QueueLength
302+
|> DynObj.withOptionalProperty "globalTransforms" GlobalTransforms
303+
|> DynObj.withOptionalProperty "locale" Locale
304+
|> DynObj.withOptionalProperty "locales" Locales
316305

317306
/// <summary>
318307
/// Combines two Config objects.

‎src/Plotly.NET/Config/ObjectAbstractions/Edits.fs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,14 @@ type Edits() =
7878
[<Optional; DefaultParameterValue(null)>] ?TitleText: bool
7979
) =
8080
fun (edits: Edits) ->
81-
AnnotationPosition |> DynObj.setOptionalProperty edits "annotationPosition"
82-
AnnotationTail |> DynObj.setOptionalProperty edits "annotationTail"
83-
AnnotationText |> DynObj.setOptionalProperty edits "annotationText"
84-
AxisTitleText |> DynObj.setOptionalProperty edits "axisTitleText"
85-
ColorbarPosition |> DynObj.setOptionalProperty edits "colorbarPosition"
86-
ColorbarTitleText |> DynObj.setOptionalProperty edits "colorbarTitleText"
87-
LegendPosition |> DynObj.setOptionalProperty edits "legendPosition"
88-
LegendText |> DynObj.setOptionalProperty edits "legendText"
89-
ShapePosition |> DynObj.setOptionalProperty edits "shapePosition"
90-
TitleText |> DynObj.setOptionalProperty edits "titleText"
91-
9281
edits
82+
|> DynObj.withOptionalProperty "annotationPosition" AnnotationPosition
83+
|> DynObj.withOptionalProperty "annotationTail" AnnotationTail
84+
|> DynObj.withOptionalProperty "annotationText" AnnotationText
85+
|> DynObj.withOptionalProperty "axisTitleText" AxisTitleText
86+
|> DynObj.withOptionalProperty "colorbarPosition" ColorbarPosition
87+
|> DynObj.withOptionalProperty "colorbarTitleText" ColorbarTitleText
88+
|> DynObj.withOptionalProperty "legendPosition" LegendPosition
89+
|> DynObj.withOptionalProperty "legendText" LegendText
90+
|> DynObj.withOptionalProperty "shapePosition" ShapePosition
91+
|> DynObj.withOptionalProperty "titleText" TitleText

‎src/Plotly.NET/Config/ObjectAbstractions/ToImageButtonOptions.fs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ type ToImageButtonOptions() =
3535
[<Optional; DefaultParameterValue(null)>] ?Scale
3636
) =
3737
fun (btnConf: ToImageButtonOptions) ->
38-
Format |> Option.map StyleParam.ImageFormat.toString |> DynObj.setOptionalProperty btnConf "format"
39-
Filename |> DynObj.setOptionalProperty btnConf "filename"
40-
Width |> DynObj.setOptionalProperty btnConf "width"
41-
Height |> DynObj.setOptionalProperty btnConf "height"
42-
Scale |> DynObj.setOptionalProperty btnConf "scale"
4338
btnConf
39+
|> DynObj.withOptionalPropertyBy "format" Format StyleParam.ImageFormat.toString
40+
|> DynObj.withOptionalProperty "filename" Filename
41+
|> DynObj.withOptionalProperty "width" Width
42+
|> DynObj.withOptionalProperty "height" Height
43+
|> DynObj.withOptionalProperty "scale" Scale

‎src/Plotly.NET/Defaults.fs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ open Plotly.NET
44
open Plotly.NET.LayoutObjects
55

66
open DynamicObj
7-
open DynamicObj.Operators
87
open System.Runtime.InteropServices
98

109
open Giraffe.ViewEngine
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Please sign in to comment.