Skip to content

Commit

Permalink
various final adjustments to source, typos, and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Oct 16, 2024
1 parent bc31d9b commit dbdf8b6
Show file tree
Hide file tree
Showing 18 changed files with 121 additions and 106 deletions.
71 changes: 37 additions & 34 deletions src/Plotly.NET/ChartAPI/Chart.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1751,7 +1751,7 @@ type Chart =
let currentAxis =
polar |> Polar.getAngularAxis

let updatedAxis = DynObj.combine currentAxis angularAxis
let updatedAxis = DynObj.combine currentAxis angularAxis |> unbox<AngularAxis>

let updatedPolar =
polar |> Polar.setAngularAxis updatedAxis
Expand Down Expand Up @@ -1810,7 +1810,7 @@ type Chart =
polar |> Polar.getRadialAxis

let updatedAxis =
DynObj.combine currentAxis radialAxis
DynObj.combine currentAxis radialAxis |> unbox<RadialAxis>

let updatedPolar =
polar |> Polar.setRadialAxis updatedAxis
Expand Down Expand Up @@ -1925,10 +1925,10 @@ type Chart =
let currentAxis =
smith |> Smith.getImaginaryAxis

let updatedAxis = DynObj.combine currentAxis imaginaryAxis
let updatedAxis = DynObj.combine currentAxis imaginaryAxis |> unbox<ImaginaryAxis>

let updatedSmith =
smith |> Smith.setImaginaryAxis updatedAxis
smith |> Smith.setImaginaryAxis updatedAxis

layout |> Layout.updateSmithById (id, updatedSmith)

Expand Down Expand Up @@ -1982,10 +1982,10 @@ type Chart =
if combine then
let currentAxis = smith |> Smith.getRealAxis

let updatedAxis = DynObj.combine currentAxis realAxis
let updatedAxis = DynObj.combine currentAxis realAxis |> unbox<RealAxis>

let updatedSmith =
smith |> Smith.setRealAxis updatedAxis
smith |> Smith.setRealAxis updatedAxis

layout |> Layout.updateSmithById (id, updatedSmith)

Expand Down Expand Up @@ -2364,10 +2364,10 @@ type Chart =
let currentAxis =
ternary |> Ternary.getAAxis

let updatedAxis = DynObj.combine currentAxis aAxis
let updatedAxis = DynObj.combine currentAxis aAxis |> unbox<LinearAxis>

let updatedTernary =
ternary |> Ternary.setAAxis updatedAxis
ternary |> Ternary.setAAxis updatedAxis

layout |> Layout.updateTernaryById (id, updatedTernary)

Expand Down Expand Up @@ -2423,7 +2423,7 @@ type Chart =
let currentAxis =
ternary |> Ternary.getBAxis

let updatedAxis = DynObj.combine currentAxis bAxis
let updatedAxis = DynObj.combine currentAxis bAxis |> unbox<LinearAxis>

let updatedTernary =
ternary |> Ternary.setBAxis updatedAxis
Expand Down Expand Up @@ -2482,7 +2482,7 @@ type Chart =
let currentAxis =
ternary |> Ternary.getCAxis

let updatedAxis = DynObj.combine currentAxis cAxis
let updatedAxis = DynObj.combine currentAxis cAxis |> unbox<LinearAxis>

let updatedTernary =
ternary |> Ternary.setCAxis updatedAxis
Expand Down Expand Up @@ -3176,8 +3176,9 @@ type Chart =
calculateSubplotTitlePositions 0. 1. xGap yGap nRows nCols reversed

titles
|> Seq.zip positions[0 .. (Seq.length titles) - 1]
|> Seq.map (fun (((rowIndex, colIndex), (x, y)), title) ->
|> Array.ofSeq
|> Array.zip positions[0 .. (Seq.length titles) - 1]
|> Array.map (fun (((rowIndex, colIndex), (x, y)), title) ->
Annotation.init(
X = x,
XRef = "paper",
Expand All @@ -3199,7 +3200,8 @@ type Chart =

gCharts
|> Seq.zip gridCoordinates
|> Seq.mapi (fun i ((rowIndex, colIndex), gChart) ->
|> Array.ofSeq
|> Array.mapi (fun i ((rowIndex, colIndex), gChart) ->

let layout =
gChart |> GenericChart.getLayout
Expand All @@ -3217,35 +3219,36 @@ type Chart =
let yAxis =
layout.TryGetTypedPropertyValue<LinearAxis> "yaxis" |> Option.defaultValue (LinearAxis.init ())

let allXAxes = Layout.getXAxes layout |> Seq.map fst
let allYAxes = Layout.getYAxes layout |> Seq.map fst
let allXAxes = Layout.getXAxes layout |> Array.map fst
let allYAxes = Layout.getYAxes layout |> Array.map fst

// 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.
allXAxes |> Seq.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)
allYAxes |> Seq.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)
allXAxes |> Array.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)
allYAxes |> Array.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)

let xAnchor, yAnchor =
if hasSharedAxes then
colIndex, rowIndex //set axis anchors according to grid coordinates
else
i + 1, i + 1

gChart
|> Chart.withAxisAnchor (xAnchor, yAnchor) // set adapted axis anchors
|> Chart.withXAxis (xAxis, (StyleParam.SubPlotId.XAxis(i + 1))) // set previous axis with adapted id (one individual axis for each subplot, whether or not they will be used later)
|> Chart.withYAxis (yAxis, (StyleParam.SubPlotId.YAxis(i + 1))) // set previous axis with adapted id (one individual axis for each subplot, whether or not they will be used later)

let lol =
gChart
|> Chart.withAxisAnchor (xAnchor, yAnchor) // set adapted axis anchors
|> Chart.withXAxis (xAxis, (StyleParam.SubPlotId.XAxis(i + 1))) // set previous axis with adapted id (one individual axis for each subplot, whether or not they will be used later)
|> Chart.withYAxis (yAxis, (StyleParam.SubPlotId.YAxis(i + 1))) // set previous axis with adapted id (one individual axis for each subplot, whether or not they will be used later)
lol
| TraceID.Cartesian3D ->

let scene =
layout.TryGetTypedPropertyValue<Scene> "scene"
|> Option.defaultValue (Scene.init ())
|> Scene.style (Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1))

let allScenes = Layout.getScenes layout |> Seq.map fst
let allScenes = Layout.getScenes layout |> Array.map fst

// 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.
allScenes |> Seq.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)
allScenes |> Array.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)

let sceneAnchor =
StyleParam.SubPlotId.Scene(i + 1)
Expand All @@ -3260,10 +3263,10 @@ type Chart =
|> Option.defaultValue (Polar.init ())
|> Polar.style (Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1))

let allPolars = Layout.getPolars layout |> Seq.map fst
let allPolars = Layout.getPolars layout |> Array.map fst

// 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.
allPolars |> Seq.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)
allPolars |> Array.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)

let polarAnchor =
StyleParam.SubPlotId.Polar(i + 1)
Expand All @@ -3280,10 +3283,10 @@ type Chart =
|> Option.defaultValue (Smith.init ())
|> Smith.style (Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1))

let allSmiths = Layout.getSmiths layout |> Seq.map fst
let allSmiths = Layout.getSmiths layout |> Array.map fst

// 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.
allSmiths |> Seq.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)
allSmiths |> Array.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)

let polarAnchor =
StyleParam.SubPlotId.Smith(i + 1)
Expand All @@ -3299,10 +3302,10 @@ type Chart =
|> Option.defaultValue (Geo.init ())
|> Geo.style (Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1))

let allGeos = Layout.getGeos layout |> Seq.map fst
let allGeos = Layout.getGeos layout |> Array.map fst

// 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.
allGeos |> Seq.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)
allGeos |> Array.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)

let geoAnchor =
StyleParam.SubPlotId.Geo(i + 1)
Expand All @@ -3319,10 +3322,10 @@ type Chart =
Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1)
)

let allMapboxes = Layout.getMapboxes layout |> Seq.map fst
let allMapboxes = Layout.getMapboxes layout |> Array.map fst

// 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.
allMapboxes |> Seq.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)
allMapboxes |> Array.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)

let geoAnchor =
StyleParam.SubPlotId.Geo(i + 1)
Expand All @@ -3344,10 +3347,10 @@ type Chart =
Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1)
)

let allTernaries = Layout.getTernaries layout |> Seq.map fst
let allTernaries = Layout.getTernaries layout |> Array.map fst

// 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.
allTernaries |> Seq.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)
allTernaries |> Array.iter (fun propName -> layout.RemoveProperty(propName) |> ignore)

let ternaryAnchor =
StyleParam.SubPlotId.Ternary(i + 1)
Expand Down
2 changes: 1 addition & 1 deletion src/Plotly.NET/Config/Config.fs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ type Config() =
(second.TryGetTypedPropertyValue<seq<seq<string>>>("modeBarButtons"))

DynObj.combine first second
|> unbox
|> unbox<Config>
|> Config.style (
?ModeBarButtonsToRemove = (modeBarButtonsToRemove |> Option.map (Seq.map StyleParam.ModeBarButton.ofString)),
?ModeBarButtonsToAdd = (modeBarButtonsToAdd |> Option.map (Seq.map StyleParam.ModeBarButton.ofString)),
Expand Down
2 changes: 1 addition & 1 deletion src/Plotly.NET/DisplayOptions/DisplayOptions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ type DisplayOptions() =
(second.TryGetTypedPropertyValue<XmlNode list>("ChartDescription"))

DynObj.combine first second
|> unbox
|> unbox<DisplayOptions>
|> DisplayOptions.style (?AdditionalHeadTags = additionalHeadTags, ?ChartDescription = description)

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions src/Plotly.NET/Globals.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ let LOGO_BASE64 =
"""iVBORw0K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
JsonSerializerSettings(ReferenceLoopHandling = ReferenceLoopHandling.Serialize)

/// the mathjax v2 tags to add to html docs for rendering latex
let internal MATHJAX_V2_TAGS =
let MATHJAX_V2_TAGS =
[
script
[
Expand All @@ -76,7 +76,7 @@ let internal MATHJAX_V2_TAGS =
]

/// the mathjax v3 tags to add to html docs for rendering latex
let internal MATHJAX_V3_TAGS =
let MATHJAX_V3_TAGS =
[
script
[]
Expand Down
Loading

0 comments on commit dbdf8b6

Please sign in to comment.