-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plotlyjs 2.21.0: Add texttemplate attribute to shape.label (plotly/pl…
- Loading branch information
Showing
11 changed files
with
89 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
tests/Common/FSharpTestBase/TestCharts/UpstreamFeatures/2.21.fs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module PlotlyJS_2_21_TestCharts | ||
|
||
open Plotly.NET | ||
open Plotly.NET.TraceObjects | ||
open Plotly.NET.LayoutObjects | ||
|
||
|
||
module ShapeLabelTextTemplate = | ||
|
||
let ``Line shape with all template item variables accessed``= | ||
Chart.Point( | ||
[(0,10);(10,10)], | ||
UseDefaults = false | ||
) | ||
|> Chart.withShape( | ||
Shape.init( | ||
X0 = 0, | ||
X1 = 10, | ||
Y0 = 10, | ||
Y1 = 10, | ||
ShapeType = StyleParam.ShapeType.Line, | ||
Label = ShapeLabel.init( | ||
TextTemplate = "Here are the values i can access:<br><b>Raw variables (from shape definition):</b><br><br>x0: %{x0}<br>x1: %{x1}<br>y0: %{y0}<br>y1: %{y1}<br><br><b>Calculated variables:</b><br><br>xcenter (calculated as (x0+x1)/2): %{xcenter}<br>ycenter (calculated as (y0+y1)/2): %{ycenter}<br>dx (calculated as x1-x0): %{dx}<br>dy (calculated as y1-y0): %{dy}<br>width (calculated as abs(x1-x0)): %{width}<br>height (calculated as abs(y1-y0)): %{height}<br>length (calculated as sqrt(dx^2+dy^2)) -- for lines only: %{length}<br>slope (calculated as (y1-y0)/(x1-x0)): %{slope}<br>" | ||
) | ||
) | ||
) | ||
|> Chart.withSize(1000,1000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module CoreTests.UpstreamFeatures.PlotlyJS_2_21 | ||
|
||
open Expecto | ||
open Plotly.NET | ||
open Plotly.NET.LayoutObjects | ||
open Plotly.NET.TraceObjects | ||
open Plotly.NET.GenericChart | ||
|
||
open TestUtils.HtmlCodegen | ||
open PlotlyJS_2_21_TestCharts | ||
|
||
module ShapeLabelTextTemplate = | ||
|
||
[<Tests>] | ||
let ``ShapeLabel TextTemplate chart HTML codegeneration tests`` = | ||
testList "UpstreamFeatures.PlotlyJS_2_21" [ | ||
testList "ShapeLabelTextTemplate" [ | ||
testCase "Line shape with all template item variables accessed data" ( fun () -> | ||
"""var data = [{"type":"scatter","mode":"markers","x":[0,10],"y":[10,10],"marker":{},"line":{}}];""" | ||
|> chartGeneratedContains ShapeLabelTextTemplate.``Line shape with all template item variables accessed`` | ||
) | ||
testCase "Line shape with all template item variables accessed layout" ( fun () -> | ||
"""var layout = {"shapes":[{"label":{"texttemplate":"Here are the values i can access:<br><b>Raw variables (from shape definition):</b><br><br>x0: %{x0}<br>x1: %{x1}<br>y0: %{y0}<br>y1: %{y1}<br><br><b>Calculated variables:</b><br><br>xcenter (calculated as (x0+x1)/2): %{xcenter}<br>ycenter (calculated as (y0+y1)/2): %{ycenter}<br>dx (calculated as x1-x0): %{dx}<br>dy (calculated as y1-y0): %{dy}<br>width (calculated as abs(x1-x0)): %{width}<br>height (calculated as abs(y1-y0)): %{height}<br>length (calculated as sqrt(dx^2+dy^2)) -- for lines only: %{length}<br>slope (calculated as (y1-y0)/(x1-x0)): %{slope}<br>"},"type":"line","x0":0,"x1":10,"y0":10,"y1":10}],"width":1000,"height":1000};""" | ||
|> chartGeneratedContains ShapeLabelTextTemplate.``Line shape with all template item variables accessed`` | ||
) | ||
] | ||
] |