Skip to content

Commit

Permalink
plotlyjs v2.8.0: add horizontal color bar options (plotly/plotly.js#6024
Browse files Browse the repository at this point in the history
)
  • Loading branch information
kMutagene committed Feb 1, 2023
1 parent b76bf18 commit f51c611
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Plotly.NET/ChartAPI/GenericChart.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module HTML =
<head>
<!-- Plotly.js -->
<meta http-equiv="X-UA-Compatible" content="IE=11" >
<script src="https://cdn.plot.ly/plotly-2.7.0.min.js"></script>
<script src="https://cdn.plot.ly/plotly-2.8.3.min.js"></script>
[ADDITIONAL_HEAD_TAGS]
<style>
.container {
Expand Down Expand Up @@ -58,7 +58,7 @@ module HTML =
newScript.AppendLine(
@"
var renderPlotly_[SCRIPTID] = function() {
var fsharpPlotlyRequire = requirejs.config({context:'fsharp-plotly',paths:{plotly:'https://cdn.plot.ly/plotly-2.7.0.min'}}) || require;
var fsharpPlotlyRequire = requirejs.config({context:'fsharp-plotly',paths:{plotly:'https://cdn.plot.ly/plotly-2.8.3.min'}}) || require;
fsharpPlotlyRequire(['plotly'], function(Plotly) {"
)
|> ignore
Expand Down
14 changes: 9 additions & 5 deletions src/Plotly.NET/CommonAbstractions/ColorBar.fs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ type ColorBar() =
[<Optional; DefaultParameterValue(null)>] ?LenMode: StyleParam.UnitMode,
[<Optional; DefaultParameterValue(null)>] ?MinExponent: float,
[<Optional; DefaultParameterValue(null)>] ?NTicks: int,
[<Optional; DefaultParameterValue(null)>] ?Orientation: StyleParam.Orientation,
[<Optional; DefaultParameterValue(null)>] ?OutlineColor: Color,
[<Optional; DefaultParameterValue(null)>] ?OutlineWidth: float,
[<Optional; DefaultParameterValue(null)>] ?SeparateThousands: bool,
Expand Down Expand Up @@ -108,6 +109,7 @@ type ColorBar() =
?LenMode = LenMode,
?MinExponent = MinExponent,
?NTicks = NTicks,
?Orientation = Orientation,
?OutlineColor = OutlineColor,
?OutlineWidth = OutlineWidth,
?SeparateThousands = SeparateThousands,
Expand Down Expand Up @@ -171,7 +173,7 @@ type ColorBar() =
/// <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>
/// <param name="TickFormatStops">Set rules for customizing TickFormat on different zoom levels</param>
/// <param name="TickLabelOverflow">Determines how we handle tick labels that would overflow either the graph div or the domain of the axis. The default value for inside tick labels is "hide past domain". In other cases the default is "hide past div".</param>
/// <param name="TickLabelPosition">Determines where tick labels are drawn.</param>
/// <param name="TickLabelPosition">Determines where tick labels are drawn relative to the ticks. Left and right options are used when `orientation` is *h*, top and bottom when `orientation` is *v*.</param>
/// <param name="TickLen">Sets the tick length (in px).</param>
/// <param name="TickMode">Sets the tick mode for this axis. If "auto", the number of ticks is set via `nticks`. If "linear", the placement of the ticks is determined by a starting position `tick0` and a tick step `dtick` ("linear" is the default value if `tick0` and `dtick` are provided). If "array", the placement of the ticks is set via `tickvals` and the tick text is `ticktext`. ("array" is the default value if `tickvals` is provided).</param>
/// <param name="TickPrefix">Sets a tick label prefix.</param>
Expand All @@ -181,11 +183,11 @@ type ColorBar() =
/// <param name="TickVals">Sets the values at which ticks on this axis appear. Only has an effect if `tickmode` is set to "array". Used with `ticktext`.</param>
/// <param name="TickWidth">Sets the tick width (in px).</param>
/// <param name="Title">Sets the ColorBar title.</param>
/// <param name="X">Sets the x position of the color bar (in plot fraction).</param>
/// <param name="XAnchor">Sets this color bar's horizontal position anchor. This anchor binds the `x` position to the "left", "center" or "right" of the color bar.</param>
/// <param name="X">Sets the x position of the color bar (in plot fraction). Defaults to 1.02 when `orientation` is *v* and 0.5 when `orientation` is *h*.</param>
/// <param name="XAnchor">'Sets this color bar's horizontal position anchor. This anchor binds the `x` position to the *left*, *center*, or *right* of the color bar. Defaults to *left* when `orientation` is *v* and *center* when `orientation` is *h*.</param>
/// <param name="XPad">Sets the amount of padding (in px) along the x direction.</param>
/// <param name="Y">Sets the y position of the color bar (in plot fraction).</param>
/// <param name="YAnchor">Sets this color bar's vertical position anchor This anchor binds the `y` position to the "top", "middle" or "bottom" of the color bar.</param>
/// <param name="Y">Sets the y position of the color bar (in plot fraction).Defaults to 0.5 when `orientation` is *v* and 1.02 when `orientation` is *h*.'</param>
/// <param name="YAnchor">'Sets this color bar\'s vertical position anchor. This anchor binds the `y` position to the *top*, *middle* or *bottom* of the color bar.Defaults to *middle* when `orientation` is *v* and *bottom* when `orientation` is *h*.'</param>
/// <param name="YPad">Sets the amount of padding (in px) along the y direction.</param>
static member style
(
Expand All @@ -198,6 +200,7 @@ type ColorBar() =
[<Optional; DefaultParameterValue(null)>] ?LenMode: StyleParam.UnitMode,
[<Optional; DefaultParameterValue(null)>] ?MinExponent: float,
[<Optional; DefaultParameterValue(null)>] ?NTicks: int,
[<Optional; DefaultParameterValue(null)>] ?Orientation: StyleParam.Orientation,
[<Optional; DefaultParameterValue(null)>] ?OutlineColor: Color,
[<Optional; DefaultParameterValue(null)>] ?OutlineWidth: float,
[<Optional; DefaultParameterValue(null)>] ?SeparateThousands: bool,
Expand Down Expand Up @@ -243,6 +246,7 @@ type ColorBar() =
LenMode |> DynObj.setValueOptBy colorBar "lenmode" StyleParam.UnitMode.convert
MinExponent |> DynObj.setValueOpt colorBar "min3xponent"
NTicks |> DynObj.setValueOpt colorBar "nticks"
Orientation |> DynObj.setValueOptBy colorBar "orientation" StyleParam.Orientation.convert
OutlineColor |> DynObj.setValueOpt colorBar "outlinecolor"
OutlineWidth |> DynObj.setValueOpt colorBar "outlinewidth"
SeparateThousands |> DynObj.setValueOpt colorBar "separatethousands"
Expand Down
4 changes: 2 additions & 2 deletions tests/Plotly.NET.Tests/HtmlCodegen/SimpleTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let simpleChart =
let ``Html layout tests`` =
testList "SimpleTests.Simple tests" [
testCase "Expecting plotly js" ( fun () ->
"https://cdn.plot.ly/plotly-2.7.0.min"
"https://cdn.plot.ly/plotly-2.8.3.min"
|> chartGeneratedContains simpleChart
);
testCase "Expecting data" ( fun () ->
Expand All @@ -36,7 +36,7 @@ let ``Html layout tests`` =
|> chartGeneratedContains simpleChart
);
testCase "Expecting require config" (fun () ->
"var fsharpPlotlyRequire = requirejs.config({context:'fsharp-plotly',paths:{plotly:'https://cdn.plot.ly/plotly-2.7.0.min'}}) || require;"
"var fsharpPlotlyRequire = requirejs.config({context:'fsharp-plotly',paths:{plotly:'https://cdn.plot.ly/plotly-2.8.3.min'}}) || require;"
|> chartGeneratedContains simpleChart
);
testCase "Expecting html tags in embedded page only" (fun () ->
Expand Down

0 comments on commit f51c611

Please sign in to comment.