-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathcustomPage.kt
43 lines (39 loc) · 1.12 KB
/
customPage.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
import kotlinx.html.div
import kotlinx.html.h1
import kotlinx.html.hr
import space.kscience.plotly.*
import space.kscience.plotly.models.Trace
import space.kscience.plotly.models.invoke
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin
fun main() {
val x1 = (0..100).map { it.toDouble() / 100.0 }
val y1 = x1.map { sin(2.0 * PI * it) }
val y2 = x1.map { cos(2.0 * PI * it) }
val trace1 = Trace(x1, y1) { name = "sin" }
val trace2 = Trace(x1, y2) { name = "cos" }
Plotly.page { container ->
plot(renderer = container) {
traces(trace1, trace2)
layout {
title = "The plot above"
xaxis.title = "x axis name"
yaxis.title = "y axis name"
}
}
hr()
h1 { +"A custom separator" }
hr()
div {
plot {
traces(trace1, trace2)
layout {
title = "The plot below"
xaxis.title = "x axis name"
yaxis.title = "y axis name"
}
}
}
}.makeFile()
}