-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathSimpleTestSpecs.kt
65 lines (57 loc) · 2.02 KB
/
SimpleTestSpecs.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* Copyright (c) 2020. JetBrains s.r.o.
* Use of this source code is governed by the MIT license that can be found in the LICENSE file.
*/
package demoAndTestShared
import org.jetbrains.letsPlot.core.plot.base.Aes
import org.jetbrains.letsPlot.core.spec.Option.GeomName
import org.jetbrains.letsPlot.core.spec.Option.Layer
import org.jetbrains.letsPlot.core.spec.Option.Meta
import org.jetbrains.letsPlot.core.spec.Option.Meta.Kind
import org.jetbrains.letsPlot.core.spec.Option.Plot
import org.jetbrains.letsPlot.core.spec.Option.PlotBase
import org.jetbrains.letsPlot.core.spec.Option.SubPlots
object SimpleTestSpecs {
fun simplePointLayer(): MutableMap<String, Any> {
return mutableMapOf(
Layer.GEOM to GeomName.POINT,
PlotBase.MAPPING to mapOf(
Aes.X.name to List(50) { 1.0 },
Aes.Y.name to List(50) { 1.0 }
)
)
}
fun simplePlot(geoms: List<Map<String, Any?>>?): MutableMap<String, Any> {
val specs: MutableMap<String, Any> = mutableMapOf(
Meta.KIND to Kind.PLOT,
PlotBase.MAPPING to emptyMap<Any, Any>()
)
if (geoms != null) {
specs[Plot.LAYERS] = geoms
}
return specs
}
fun simpleBunch(geoms: List<Map<String, Any?>>): MutableMap<String, Any> {
val figures = geoms.map { geom ->
// Single-layer plot
mutableMapOf(
Meta.KIND to Kind.PLOT,
PlotBase.MAPPING to emptyMap<Any, Any>(),
Plot.LAYERS to listOf(
geom
)
)
}
val ggBunch = mutableMapOf<String, Any>(
Meta.KIND to Kind.SUBPLOTS,
SubPlots.FIGURES to figures,
SubPlots.LAYOUT to mapOf(
Meta.NAME to SubPlots.Layout.SUBPLOTS_FREE,
SubPlots.Free.REGIONS to listOf(
listOf(0, 0, 0.5, 0.5) // 'regions' are optional
),
),
)
return ggBunch
}
}