Skip to content

Commit 78cf1ba

Browse files
committed
Fix heatmap tests, add annotated heatmap tests
1 parent 6c24bed commit 78cf1ba

File tree

3 files changed

+37
-11
lines changed

3 files changed

+37
-11
lines changed

src/Plotly.NET/Playground.fsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ Chart.AnnotatedHeatmap(
184184
],
185185
X = ["C1";"C2";"C3"],
186186
Y = ["R1";"R2";"R3"],
187-
ReverseYAxis = true
187+
ReverseYAxis = true,
188+
UseDefaults = false
188189
)
189190
|> Chart.show
190191

@@ -783,7 +784,7 @@ let seq2 = [1 ..4 ] |> Seq.map(fun _-> z1) |> Seq.toArray
783784
let marker = Marker.init(Size= 25,Colorscale=StyleParam.Colorscale.Viridis, ShowScale=false);
784785

785786
let heatmap1=
786-
Chart.Heatmap(data=seq1)
787+
Chart.Heatmap(zData=seq1)
787788
|> Chart.withMarker(marker)
788789
|> Chart.withColorAxisAnchor(1)
789790

@@ -800,7 +801,7 @@ let heatmap2=
800801
[
801802
Chart.Point([1,2; 2,3])
802803
Chart.PointTernary([1,2,3; 2,3,4])
803-
Chart.Heatmap([[1; 2];[3; 4]], Showscale=false)
804+
Chart.Heatmap([[1; 2];[3; 4]], ShowScale=false)
804805
Chart.Point3d([1,3,2])
805806
Chart.PointMapbox([1,2]) |> Chart.withMapbox(Mapbox.init(Style = StyleParam.MapboxStyle.OpenStreetMap))
806807
[

tests/Plotly.NET.Tests/HtmlCodegen/ChartLayout.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ let multiTraceGrid =
162162
[
163163
Chart.Point([1,2; 2,3], UseDefaults = false)
164164
Chart.PointTernary([1,2,3; 2,3,4], UseDefaults = false)
165-
Chart.Heatmap([[1; 2];[3; 4]], Showscale=false, UseDefaults = false)
165+
Chart.Heatmap([[1; 2];[3; 4]], ShowScale=false, UseDefaults = false)
166166
Chart.Point3d([1,3,2], UseDefaults = false)
167167
Chart.PointMapbox([1,2], UseDefaults = false) |> Chart.withMapbox(Mapbox.init(Style = StyleParam.MapboxStyle.OpenStreetMap))
168168
[
@@ -181,7 +181,7 @@ let multiTraceSingleStack =
181181
[
182182
Chart.Point([1,2; 2,3], UseDefaults = false)
183183
Chart.PointTernary([1,2,3; 2,3,4], UseDefaults = false)
184-
Chart.Heatmap([[1; 2];[3; 4]], Showscale=false, UseDefaults = false)
184+
Chart.Heatmap([[1; 2];[3; 4]], ShowScale=false, UseDefaults = false)
185185
Chart.Point3d([1,3,2], UseDefaults = false)
186186
Chart.PointMapbox([1,2], UseDefaults = false) |> Chart.withMapbox(Mapbox.init(Style = StyleParam.MapboxStyle.OpenStreetMap))
187187
[

tests/Plotly.NET.Tests/HtmlCodegen/SimpleCharts.fs

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,8 @@ let heatmap1Chart =
468468

469469
Chart.Heatmap(
470470
matrix,colnames,rownames,
471-
Colorscale=colorscaleValue,
472-
Showscale=true,
471+
ColorScale=colorscaleValue,
472+
ShowScale=true,
473473
UseDefaults = false
474474
)
475475
|> Chart.withSize(700,500)
@@ -489,8 +489,8 @@ let heatmapStyledChart =
489489

490490
Chart.Heatmap(
491491
matrix,colnames,rownames,
492-
Colorscale=colorscaleValue,
493-
Showscale=true,
492+
ColorScale=colorscaleValue,
493+
ShowScale=true,
494494
UseDefaults = false
495495
)
496496
|> Chart.withSize(700.,500.)
@@ -501,26 +501,51 @@ let heatmapStyledChart =
501501
)
502502
)
503503

504+
let annotatedheatmap =
505+
Chart.AnnotatedHeatmap(
506+
zData = [
507+
[1..5]
508+
[6..10]
509+
[11..15]
510+
],
511+
annotationText = [
512+
["1,1";"1,2";"1,3"]
513+
["2,1";"2,2";"2,3"]
514+
["3,1";"3,2";"3,3"]
515+
],
516+
X = ["C1";"C2";"C3"],
517+
Y = ["R1";"R2";"R3"],
518+
ReverseYAxis = true,
519+
UseDefaults = false
520+
)
504521

505522
[<Tests>]
506523
let ``Heatmap charts`` =
507524
testList "SimpleCharts.Heatmap charts" [
508525
testCase "Heatmap data" ( fun () ->
509-
"var data = [{\"type\":\"heatmap\",\"z\":[[1.0,1.5,0.7,2.7],[2.0,0.5,1.2,1.4],[0.1,2.6,2.4,3.0]],\"x\":[\"Tp0\",\"Tp30\",\"Tp60\",\"Tp160\"],\"y\":[\"p3\",\"p2\",\"p1\"],\"colorscale\":[[0.0,\"#3D9970\"],[1.0,\"#001f3f\"]],\"showscale\":true}];"
526+
"""var data = [{"type":"heatmap","x":["Tp0","Tp30","Tp60","Tp160"],"y":["p3","p2","p1"],"z":[[1.0,1.5,0.7,2.7],[2.0,0.5,1.2,1.4],[0.1,2.6,2.4,3.0]],"colorscale":[[0.0,"#3D9970"],[1.0,"#001f3f"]],"showscale":true}];"""
510527
|> chartGeneratedContains heatmap1Chart
511528
);
512529
testCase "Heatmap layout" ( fun () ->
513530
"var layout = {\"width\":700,\"height\":500,\"margin\":{\"l\":200.0}};"
514531
|> chartGeneratedContains heatmap1Chart
515532
);
516533
testCase "Heatmap styled data" ( fun () ->
517-
"""var data = [{"type":"heatmap","z":[[1.0,1.5,0.7,2.7],[2.0,0.5,1.2,1.4],[0.1,2.6,2.4,3.0]],"x":["Tp0","Tp30","Tp60","Tp160"],"y":["p3","p2","p1"],"colorscale":[[0.0,"#3D9970"],[1.0,"#001f3f"]],"showscale":true,"colorbar":{"title":{"text":"Im the Colorbar"}}}]"""
534+
"""var data = [{"type":"heatmap","x":["Tp0","Tp30","Tp60","Tp160"],"y":["p3","p2","p1"],"z":[[1.0,1.5,0.7,2.7],[2.0,0.5,1.2,1.4],[0.1,2.6,2.4,3.0]],"colorscale":[[0.0,"#3D9970"],[1.0,"#001f3f"]],"showscale":true,"colorbar":{"title":{"text":"Im the Colorbar"}}}];"""
518535
|> chartGeneratedContains heatmapStyledChart
519536
);
520537
testCase "Heatmap styled layout" ( fun () ->
521538
"var layout = {\"width\":700,\"height\":500,\"margin\":{\"l\":200.0}};"
522539
|> chartGeneratedContains heatmapStyledChart
523540
);
541+
testCase "Annotated heatmap data" ( fun () ->
542+
"""var data = [{"type":"heatmap","x":["C1","C2","C3"],"y":["R1","R2","R3"],"z":[[1,2,3,4,5],[6,7,8,9,10],[11,12,13,14,15]]}];"""
543+
|> chartGeneratedContains annotatedheatmap
544+
);
545+
testCase "Annotated heatmap layout" ( fun () ->
546+
"""var layout = {"yaxis":{"autorange":"reversed"},"annotations":[{"x":0,"y":0,"showarrow":false,"text":"1,1"},{"x":1,"y":0,"showarrow":false,"text":"1,2"},{"x":2,"y":0,"showarrow":false,"text":"1,3"},{"x":0,"y":1,"showarrow":false,"text":"2,1"},{"x":1,"y":1,"showarrow":false,"text":"2,2"},{"x":2,"y":1,"showarrow":false,"text":"2,3"},{"x":0,"y":2,"showarrow":false,"text":"3,1"},{"x":1,"y":2,"showarrow":false,"text":"3,2"},{"x":2,"y":2,"showarrow":false,"text":"3,3"}]};"""
547+
|> chartGeneratedContains annotatedheatmap
548+
);
524549
]
525550

526551

0 commit comments

Comments
 (0)