Skip to content

Commit 9f7edb8

Browse files
committed
WIP for plotlyjs 2.17: restructure html scaffold, add linear axis shift
1 parent 046e3c4 commit 9f7edb8

File tree

6 files changed

+42
-26
lines changed

6 files changed

+42
-26
lines changed

src/Plotly.NET/ChartAPI/Chart.fs

+6
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,8 @@ type Chart =
12571257
/// <param name="Anchor">If set to an opposite-letter axis id (e.g. `x2`, `y`), this axis is bound to the corresponding opposite-letter axis. If set to "free", this axis' position is determined by `position`.</param>
12581258
/// <param name="Side">Determines whether a x (y) axis is positioned at the "bottom" ("left") or "top" ("right") of the plotting area.</param>
12591259
/// <param name="Overlaying">If set a same-letter axis id, this axis is overlaid on top of the corresponding same-letter axis, with traces and axes visible for both axes. If "false", this axis does not overlay any same-letter axes. In this case, for axes with overlapping domains only the highest-numbered axis will be visible.</param>
1260+
/// <param name="AutoShift">Automatically reposition the axis to avoid overlap with other axes with the same `overlaying` value. This repositioning will account for any `shift` amount applied to other axes on the same side with `autoshift` is set to true. Only has an effect if `anchor` is set to "free".</param>
1261+
/// <param name="Shift">Moves the axis a given number of pixels from where it would have been otherwise. Accepts both positive and negative values, which will shift the axis either right or left, respectively. If `autoshift` is set to true, then this defaults to a padding of -3 if `side` is set to "left". and defaults to +3 if `side` is set to "right". Defaults to 0 if `autoshift` is set to false. Only has an effect if `anchor` is set to "free".</param>
12601262
/// <param name="Domain">Tuple of (X*Y fractions). Sets the domain of this axis (in plot fraction).</param>
12611263
/// <param name="Position">Sets the position of this axis in the plotting space (in normalized coordinates). Only has an effect if `anchor` is set to "free".</param>
12621264
/// <param name="CategoryOrder">Specifies the ordering logic for the case of categorical variables. By default, plotly uses "trace", which specifies the order that is present in the data supplied. Set `categoryorder` to "category ascending" or "category descending" if order should be determined by the alphanumerical order of the category names. Set `categoryorder` to "array" to derive the ordering from the attribute `categoryarray`. If a category is not found in the `categoryarray` array, the sorting behavior for that attribute will be identical to the "trace" mode. The unspecified categories will follow the categories in `categoryarray`. Set `categoryorder` to "total ascending" or "total descending" if order should be determined by the numerical order of the values. Similarly, the order can be determined by the min, max, sum, mean or median of all the values.</param>
@@ -1290,6 +1292,8 @@ type Chart =
12901292
[<Optional; DefaultParameterValue(null)>] ?Anchor: StyleParam.LinearAxisId,
12911293
[<Optional; DefaultParameterValue(null)>] ?Side: StyleParam.Side,
12921294
[<Optional; DefaultParameterValue(null)>] ?Overlaying: StyleParam.LinearAxisId,
1295+
[<Optional; DefaultParameterValue(null)>] ?AutoShift: bool,
1296+
[<Optional; DefaultParameterValue(null)>] ?Shift: int,
12931297
[<Optional; DefaultParameterValue(null)>] ?Domain: float * float,
12941298
[<Optional; DefaultParameterValue(null)>] ?Position: float,
12951299
[<Optional; DefaultParameterValue(null)>] ?CategoryOrder: StyleParam.CategoryOrder,
@@ -1332,6 +1336,8 @@ type Chart =
13321336
?Anchor = Anchor,
13331337
?Side = Side,
13341338
?Overlaying = Overlaying,
1339+
?AutoShift = AutoShift,
1340+
?Shift = Shift,
13351341
?Position = Position,
13361342
?CategoryOrder = CategoryOrder,
13371343
?CategoryArray = CategoryArray,

src/Plotly.NET/ChartAPI/GenericChart.fs

+5-17
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module HTML =
1515
<head>
1616
<!-- Plotly.js -->
1717
<meta http-equiv="X-UA-Compatible" content="IE=11" >
18-
<script src="https://cdn.plot.ly/plotly-2.16.5.min.js"></script>
18+
<script src="https://cdn.plot.ly/plotly-2.17.1.min.js"></script>
1919
[ADDITIONAL_HEAD_TAGS]
2020
<style>
2121
.container {
@@ -57,9 +57,7 @@ module HTML =
5757

5858
newScript.AppendLine(
5959
@"
60-
var renderPlotly_[SCRIPTID] = function() {
61-
var fsharpPlotlyRequire = requirejs.config({context:'fsharp-plotly',paths:{plotly:'https://cdn.plot.ly/plotly-2.16.5.min'}}) || require;
62-
fsharpPlotlyRequire(['plotly'], function(Plotly) {"
60+
var renderPlotly_[SCRIPTID] = function() {"
6361
)
6462
|> ignore
6563

@@ -73,19 +71,9 @@ module HTML =
7371
|> ignore
7472

7573
newScript.AppendLine(
76-
"""});
77-
};
78-
if ((typeof(requirejs) !== typeof(Function)) || (typeof(requirejs.config) !== typeof(Function))) {
79-
var script = document.createElement("script");
80-
script.setAttribute("src", "https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js");
81-
script.onload = function(){
82-
renderPlotly_[SCRIPTID]();
83-
};
84-
document.getElementsByTagName("head")[0].appendChild(script);
85-
}
86-
else {
87-
renderPlotly_[SCRIPTID]();
88-
}"""
74+
"""};
75+
renderPlotly_[SCRIPTID]();
76+
"""
8977
)
9078
|> ignore
9179

src/Plotly.NET/CommonAbstractions/StyleParams.fs

+2
Original file line numberDiff line numberDiff line change
@@ -189,11 +189,13 @@ module StyleParam =
189189

190190
[<RequireQualifiedAccess>]
191191
type LinearAxisId =
192+
| Free
192193
| X of int
193194
| Y of int
194195

195196
static member toString =
196197
function
198+
| Free -> "free"
197199
| X id -> if id < 2 then "x" else sprintf "x%i" id
198200
| Y id -> if id < 2 then "y" else sprintf "y%i" id
199201

0 commit comments

Comments
 (0)