Skip to content

Commit 540307a

Browse files
committed
fix 3d chart tests
1 parent a70e885 commit 540307a

File tree

2 files changed

+29
-24
lines changed

2 files changed

+29
-24
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ let ``Multicharts and subplots`` =
260260
|> chartGeneratedContains multiTraceGrid
261261
);
262262
testCase "MultiTrace Subplot grid layout" ( fun () ->
263-
"""var layout = {"xaxis":{},"yaxis":{},"scene2":{"domain":{"row":0,"column":1}},"polar3":{"domain":{"row":0,"column":2}},"geo4":{"domain":{"row":1,"column":0}},"mapbox":{"style":"open-street-map","domain":{"row":1,"column":1}},"mapbox5":{"style":"open-street-map","domain":{"row":1,"column":1}},"ternary6":{"domain":{"row":1,"column":2}},"xaxis7":{},"yaxis7":{},"smith9":{"domain":{"row":2,"column":2}},"xaxis10":{},"yaxis10":{},"grid":{"rows":4,"columns":3,"pattern":"independent"},"width":1000,"height":1000};"""
263+
"""var layout = {"xaxis":{},"yaxis":{},"scene":{"camera":{"projection":{"type":"perspective"}},"domain":{"row":0,"column":1}},"scene2":{"camera":{"projection":{"type":"perspective"}},"domain":{"row":0,"column":1}},"polar3":{"domain":{"row":0,"column":2}},"geo4":{"domain":{"row":1,"column":0}},"mapbox":{"style":"open-street-map","domain":{"row":1,"column":1}},"mapbox5":{"style":"open-street-map","domain":{"row":1,"column":1}},"ternary6":{"domain":{"row":1,"column":2}},"xaxis7":{},"yaxis7":{},"smith9":{"domain":{"row":2,"column":2}},"xaxis10":{},"yaxis10":{},"grid":{"rows":4,"columns":3,"pattern":"independent"},"width":1000,"height":1000};"""
264264
|> chartGeneratedContains multiTraceGrid
265265
);
266266
testCase "Single Stack data" ( fun () ->
@@ -277,7 +277,7 @@ let ``Multicharts and subplots`` =
277277
|> chartGeneratedContains multiTraceSingleStack
278278
);
279279
testCase "MultiTrace Single Stack layout" ( fun () ->
280-
"""var layout = {"xaxis":{},"yaxis":{},"ternary2":{"domain":{"row":1,"column":0}},"xaxis3":{},"yaxis3":{},"scene4":{"domain":{"row":3,"column":0}},"mapbox":{"style":"open-street-map","domain":{"row":4,"column":0}},"mapbox5":{"style":"open-street-map","domain":{"row":4,"column":0}},"xaxis6":{},"yaxis6":{},"grid":{"rows":6,"columns":1,"pattern":"independent"},"width":1000,"height":1000};"""
280+
"""var layout = {"xaxis":{},"yaxis":{},"ternary2":{"domain":{"row":1,"column":0}},"xaxis3":{},"yaxis3":{},"scene":{"camera":{"projection":{"type":"perspective"}},"domain":{"row":3,"column":0}},"scene4":{"camera":{"projection":{"type":"perspective"}},"domain":{"row":3,"column":0}},"mapbox":{"style":"open-street-map","domain":{"row":4,"column":0}},"mapbox5":{"style":"open-street-map","domain":{"row":4,"column":0}},"xaxis6":{},"yaxis6":{},"grid":{"rows":6,"columns":1,"pattern":"independent"},"width":1000,"height":1000};"""
281281
|> chartGeneratedContains multiTraceSingleStack
282282
);
283283
]

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

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ let ``3D Scatter charts`` =
4646
|> chartGeneratedContains scatterChart
4747
);
4848
testCase "3D Scatter charts layout" ( fun () ->
49-
"""var layout = {"scene":{"xaxis":{"title":{"text":"my x-axis"}},"yaxis":{"title":{"text":"my y-axis"}},"zaxis":{"title":{"text":"my z-axis"}}},"width":800,"height":800};"""
49+
"""var layout = {"scene":{"camera":{"projection":{"type":"perspective"}},"xaxis":{"title":{"text":"my x-axis"}},"yaxis":{"title":{"text":"my y-axis"}},"zaxis":{"title":{"text":"my z-axis"}}},"width":800,"height":800};"""
5050
|> chartGeneratedContains scatterChart
5151
);
5252
]
@@ -70,7 +70,7 @@ let ``3D Point charts`` =
7070
|> chartGeneratedContains pointChart
7171
);
7272
testCase "3D Point charts layout" ( fun () ->
73-
"""var layout = {"scene":{"xaxis":{"title":{"text":"my x-axis"}},"yaxis":{"title":{"text":"my y-axis"}},"zaxis":{"title":{"text":"my z-axis"}}},"width":800,"height":800};"""
73+
"""var layout = {"scene":{"camera":{"projection":{"type":"perspective"}},"xaxis":{"title":{"text":"my x-axis"}},"yaxis":{"title":{"text":"my y-axis"}},"zaxis":{"title":{"text":"my z-axis"}}},"width":800,"height":800};"""
7474
|> chartGeneratedContains pointChart
7575
);
7676
]
@@ -105,7 +105,7 @@ let ``Line charts`` =
105105
|> chartGeneratedContains lineChart
106106
);
107107
testCase "Line layout" ( fun () ->
108-
"""var layout = {"scene":{"xaxis":{"title":{"text":"x-axis"}},"yaxis":{"title":{"text":"y-axis"}},"zaxis":{"title":{"text":"z-axis"}}},"width":800,"height":800};"""
108+
"""var layout = {"scene":{"camera":{"projection":{"type":"perspective"}},"xaxis":{"title":{"text":"x-axis"}},"yaxis":{"title":{"text":"y-axis"}},"zaxis":{"title":{"text":"z-axis"}}},"width":800,"height":800};"""
109109
|> chartGeneratedContains lineChart
110110
);
111111
]
@@ -131,7 +131,7 @@ let ``Bubble charts`` =
131131
|> chartGeneratedContains bubbleChart
132132
);
133133
testCase "Bubble layout" ( fun () ->
134-
"""var layout = {"scene":{"xaxis":{"title":{"text":"x-axis"}},"yaxis":{"title":{"text":"y-axis"}},"zaxis":{"title":{"text":"z-axis"}}}};"""
134+
"""var layout = {"scene":{"camera":{"projection":{"type":"perspective"}},"xaxis":{"title":{"text":"x-axis"}},"yaxis":{"title":{"text":"y-axis"}},"zaxis":{"title":{"text":"z-axis"}}}};"""
135135
|> chartGeneratedContains bubbleChart
136136
);
137137
]
@@ -179,14 +179,16 @@ let ``Surface charts`` =
179179
|> chartGeneratedContainsList firstSurfaceChart
180180
);
181181
testCase "First surface layout" ( fun () ->
182-
emptyLayout firstSurfaceChart
182+
"""var layout = {"scene":{"camera":{"projection":{"type":"perspective"}}}};"""
183+
|> chartGeneratedContains firstSurfaceChart
183184
);
184185
testCase "Second surface data" ( fun () ->
185186
"""var data = [{"type":"surface","opacity":0.5,"x":[0.0,2.5],"y":[0.0,2.5],"z":[[1.0,1.0],[1.0,2.0]],"contours":{"x":{"show":true},"y":{"show":true},"z":{"show":true}}}];"""
186187
|> chartGeneratedContains secondSurfaceChart
187188
);
188189
testCase "Second surface layout" ( fun () ->
189-
emptyLayout secondSurfaceChart
190+
"""var layout = {"scene":{"camera":{"projection":{"type":"perspective"}}}};"""
191+
|> chartGeneratedContains secondSurfaceChart
190192
);
191193
]
192194

@@ -210,26 +212,25 @@ let meshChart =
210212
let b = Array.init 50 (fun _ -> rnd.NextDouble())
211213
let c = Array.init 50 (fun _ -> rnd.NextDouble())
212214

213-
Trace3D.initMesh3D
214-
(fun mesh3d ->
215-
mesh3d?x <- a
216-
mesh3d?y <- b
217-
mesh3d?z <- c
218-
mesh3d?flatshading <- true
219-
mesh3d?contour <- Contours.initXyz(Show=true)
220-
mesh3d
221-
)
222-
|> GenericChart.ofTraceObject false
215+
Chart.Mesh3D(
216+
x = a,
217+
y = b,
218+
z = c,
219+
FlatShading = true,
220+
Contour = Contour.init(Show = true),
221+
UseDefaults = false
222+
)
223223

224224
[<Tests>]
225225
let ``Mesh charts`` =
226226
testList "Charts3D.Mesh charts" [
227227
testCase "Mesh data" ( fun () ->
228-
"var data = [{\"type\":\"mesh3d\",\"x\":[0.33836984091362443,0.2844184475412678,0.2629626417825756,0.6253758443637638,0.46346185284827923,0.9283738280312968,0.1463105539541275,0.9505998873853124,0.5961332552116985,0.11745994590104555,0.975558924477342,0.37088692624628866,0.0699143670824889,0.07078822472635109,0.48201058175508427,0.15297147219673332,0.9641655045394625,0.09534371648698287,0.8125330809562156,0.2506162050415837,0.48126059979259067,0.07473527084790882,0.8369272271343168,0.7793545950107996,0.18997055114711195,0.7421991949631829,0.2328434778530353,0.7856600809775572,0.9278804142623583,0.10790790343094053,0.03301328235911824,0.770361295794305,0.30779169793603556,0.11389689665003536,0.388590590743623,0.9796536713743832,0.17214082375734152,0.7884985966554371,0.1994013894346549,0.7964705586416976,0.3436089406458703,0.10509170037931376,0.9796912223006092,0.8392714871276503,0.5432778380547081,0.1979652751227679,0.038267011306372944,0.5355382620056803,0.6352935864754456,0.8821615948724382],\"y\":[0.9909701128448221,0.9722291035448336,0.2536179266188377,0.5066026125599642,0.19606175189654423,0.2636345700657156,0.447491220406951,0.48360804677177593,0.4354052932166519,0.7212626578850964,0.6955303501782615,0.3606504729765702,0.022719473122954123,0.48822535178075793,0.08444666354192731,0.20519762868303695,0.06309522831025312,0.9560174704324536,0.682197633982728,0.5023569103807011,0.9808306484393918,0.17566690788402545,0.8959423270523279,0.016062522314518,0.9070072643957134,0.37616889941327686,0.0950440485472996,0.9976557400066665,0.2360767569560915,0.9920052760243441,0.70393218365681,0.6973052158473549,0.15036649450211156,0.04571881938992013,0.11693779058611849,0.060784178814284585,0.5167433691754674,0.8011890853760714,0.9178351447534912,0.1249560206779074,0.5321624509674322,0.6885327769855656,0.35309330343878514,0.47813873154955855,0.10094020846343608,0.9829584676693001,0.08237222725635963,0.4914658705198513,0.754824823585723,0.33808020937167116],\"z\":[0.1348700468125148,0.0822495408739194,0.8533406280229523,0.13293667609474466,0.9013309464330463,0.8153032049607966,0.07628677649250569,0.2375554043043197,0.5995953481642508,0.8198928524832674,0.16859052151841603,0.44983548040028454,0.24753128981568445,0.44340001719230787,0.017330474228286406,0.9982251343309065,0.21028397847445868,0.977000653733034,0.37128756119463946,0.023662484727642725,0.6884542595075696,0.2619061429341818,0.03818232567896243,0.5572416133048207,0.9701944594132688,0.29229787145382624,0.8225736044452403,0.4178035955027694,0.9151223138510819,0.9240487967264135,0.29379667215691724,0.6035781780274483,0.24283091642094354,0.8979965475844204,0.8571352292118293,0.6216826427828905,0.8439645878244026,0.0174298184073669,0.1443878729568738,0.30163458562532186,0.9844974023217788,0.2791879648711476,0.20159373721182056,0.09794229227022375,0.9563654991594914,0.0823269705671477,0.44100148716988113,0.9096932862464773,0.4608082573212722,0.10271507413252959],\"flatshading\":true,\"contour\":{\"x\":{\"show\":true},\"y\":{\"show\":true},\"z\":{\"show\":true}}}];"
228+
"""var data = [{"type":"mesh3d","x":[0.33836984091362443,0.2844184475412678,0.2629626417825756,0.6253758443637638,0.46346185284827923,0.9283738280312968,0.1463105539541275,0.9505998873853124,0.5961332552116985,0.11745994590104555,0.975558924477342,0.37088692624628866,0.0699143670824889,0.07078822472635109,0.48201058175508427,0.15297147219673332,0.9641655045394625,0.09534371648698287,0.8125330809562156,0.2506162050415837,0.48126059979259067,0.07473527084790882,0.8369272271343168,0.7793545950107996,0.18997055114711195,0.7421991949631829,0.2328434778530353,0.7856600809775572,0.9278804142623583,0.10790790343094053,0.03301328235911824,0.770361295794305,0.30779169793603556,0.11389689665003536,0.388590590743623,0.9796536713743832,0.17214082375734152,0.7884985966554371,0.1994013894346549,0.7964705586416976,0.3436089406458703,0.10509170037931376,0.9796912223006092,0.8392714871276503,0.5432778380547081,0.1979652751227679,0.038267011306372944,0.5355382620056803,0.6352935864754456,0.8821615948724382],"y":[0.9909701128448221,0.9722291035448336,0.2536179266188377,0.5066026125599642,0.19606175189654423,0.2636345700657156,0.447491220406951,0.48360804677177593,0.4354052932166519,0.7212626578850964,0.6955303501782615,0.3606504729765702,0.022719473122954123,0.48822535178075793,0.08444666354192731,0.20519762868303695,0.06309522831025312,0.9560174704324536,0.682197633982728,0.5023569103807011,0.9808306484393918,0.17566690788402545,0.8959423270523279,0.016062522314518,0.9070072643957134,0.37616889941327686,0.0950440485472996,0.9976557400066665,0.2360767569560915,0.9920052760243441,0.70393218365681,0.6973052158473549,0.15036649450211156,0.04571881938992013,0.11693779058611849,0.060784178814284585,0.5167433691754674,0.8011890853760714,0.9178351447534912,0.1249560206779074,0.5321624509674322,0.6885327769855656,0.35309330343878514,0.47813873154955855,0.10094020846343608,0.9829584676693001,0.08237222725635963,0.4914658705198513,0.754824823585723,0.33808020937167116],"z":[0.1348700468125148,0.0822495408739194,0.8533406280229523,0.13293667609474466,0.9013309464330463,0.8153032049607966,0.07628677649250569,0.2375554043043197,0.5995953481642508,0.8198928524832674,0.16859052151841603,0.44983548040028454,0.24753128981568445,0.44340001719230787,0.017330474228286406,0.9982251343309065,0.21028397847445868,0.977000653733034,0.37128756119463946,0.023662484727642725,0.6884542595075696,0.2619061429341818,0.03818232567896243,0.5572416133048207,0.9701944594132688,0.29229787145382624,0.8225736044452403,0.4178035955027694,0.9151223138510819,0.9240487967264135,0.29379667215691724,0.6035781780274483,0.24283091642094354,0.8979965475844204,0.8571352292118293,0.6216826427828905,0.8439645878244026,0.0174298184073669,0.1443878729568738,0.30163458562532186,0.9844974023217788,0.2791879648711476,0.20159373721182056,0.09794229227022375,0.9563654991594914,0.0823269705671477,0.44100148716988113,0.9096932862464773,0.4608082573212722,0.10271507413252959],"contour":{"show":true},"flatshading":true}];"""
229229
|> chartGeneratedContains meshChart
230230
);
231231
testCase "Mesh layout" ( fun () ->
232-
emptyLayout meshChart
232+
"""var layout = {"scene":{"camera":{"projection":{"type":"perspective"}}}};"""
233+
|> chartGeneratedContains meshChart
233234
);
234235
]
235236

@@ -253,7 +254,8 @@ let ``Cone charts`` =
253254
|> chartGeneratedContains coneChart
254255
);
255256
testCase "Cone layout" ( fun () ->
256-
emptyLayout coneChart
257+
"""var layout = {"scene":{"camera":{"projection":{"type":"perspective"}}}};"""
258+
|> chartGeneratedContains coneChart
257259
);
258260
]
259261

@@ -277,7 +279,8 @@ let ``StreamTube charts`` =
277279
|> chartGeneratedContains streamTubeChart
278280
);
279281
testCase "StreamTube layout" ( fun () ->
280-
emptyLayout streamTubeChart
282+
"""var layout = {"scene":{"camera":{"projection":{"type":"perspective"}}}};"""
283+
|> chartGeneratedContains streamTubeChart
281284
);
282285
]
283286

@@ -300,7 +303,8 @@ let ``Volume charts`` =
300303
|> chartGeneratedContains volumeChart
301304
);
302305
testCase "Volume layout" ( fun () ->
303-
emptyLayout volumeChart
306+
"""var layout = {"scene":{"camera":{"projection":{"type":"perspective"}}}};"""
307+
|> chartGeneratedContains volumeChart
304308
);
305309
]
306310

@@ -323,6 +327,7 @@ let ``IsoSurface charts`` =
323327
|> chartGeneratedContains isoSurfaceChart
324328
);
325329
testCase "IsoSurface layout" ( fun () ->
326-
emptyLayout isoSurfaceChart
330+
"""var layout = {"scene":{"camera":{"projection":{"type":"perspective"}}}};"""
331+
|> chartGeneratedContains isoSurfaceChart
327332
);
328333
]

0 commit comments

Comments
 (0)