Skip to content

Commit f97a2a6

Browse files
authored
Merge pull request #52 from mipt-npm/dev
0.3.0 release
2 parents 476ca93 + 48deaa1 commit f97a2a6

47 files changed

Lines changed: 3940 additions & 425 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1616

1717
### Fixed
1818

19+
### Security
20+
21+
## [0.3.0]
22+
### Added
23+
-Support for `plotly.kts` in IDEA
24+
25+
### Changed
26+
- Serialization API is encapsulated (not longer exposed) in order to provide compatibility with new serialization.
27+
- Migration to Kotlin 1.4
28+
- Minor breaking change in Plot to encapsulate serialization usage
29+
30+
### Deprecated
31+
32+
### Removed
33+
34+
### Fixed
35+
1936
### Security
2037
## [0.2.0]
2138

build.gradle.kts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,26 @@
11
plugins {
2-
val toolsVersion = "0.5.2"
3-
id("scientifik.mpp") version toolsVersion apply false
4-
id("scientifik.jvm") version toolsVersion apply false
5-
id("scientifik.publish") version toolsVersion apply false
6-
id("org.jetbrains.changelog") version "0.4.0"
2+
kotlin("js") apply false
3+
id("ru.mipt.npm.project")
74
}
85

9-
val ktorVersion by extra("1.3.2")
10-
val dataforgeVersion by extra("0.1.8")
11-
val htmlVersion by extra("0.7.1")
6+
val ktorVersion by extra("1.4.1")
7+
val dataforgeVersion by extra("0.2.0")
8+
val htmlVersion by extra("0.7.2")
129

1310
val bintrayRepo by extra("kscience")
1411
val githubProject by extra("plotly.kt")
1512

1613
allprojects {
1714
group = "kscience.plotlykt"
18-
version = "0.2.0"
15+
version = "0.3.0"
16+
17+
repositories {
18+
mavenLocal()
19+
maven("https://dl.bintray.com/kotlin/kotlin-eap")
20+
maven("https://kotlin.bintray.com/kotlinx")
21+
}
22+
}
23+
24+
apiValidation {
25+
ignoredProjects.addAll(listOf("examples", "fx-demo", "js-demo"))
1926
}

docs/Dependency structure.vsdx

23.7 KB
Binary file not shown.

docs/overview.html

Lines changed: 467 additions & 0 deletions
Large diffs are not rendered by default.

examples/build.gradle.kts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ repositories {
66
mavenLocal()
77
jcenter()
88
maven("https://dl.bintray.com/mipt-npm/dataforge")
9-
maven("https://dl.bintray.com/mipt-npm/scientifik")
9+
maven("https://dl.bintray.com/mipt-npm/kscience")
1010
maven("https://dl.bintray.com/mipt-npm/dev")
11-
maven("https://dl.bintray.com/kotlin/ktor/")
12-
maven("https://dl.bintray.com/kotlin/kotlin-eap")
13-
maven("https://kotlin.bintray.com/kotlinx")
1411
}
1512

1613
dependencies {
1714
implementation(project(":plotlykt-server"))
1815
implementation(kotlin("script-runtime"))
16+
implementation(project(":plotlykt-script"))
1917
implementation("de.mpicbg.scicomp:krangl:0.13")
2018
implementation("org.apache.commons:commons-csv:1.8")
2119
}

examples/src/main/kotlin/contour/BasicContour.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fun main() {
2424
val x1 = listOf(-9, -6, -5, -3, -1)
2525
val y1 = listOf(0, 1, 4, 5, 7)
2626

27-
val contour = Contour {
27+
val contour = Contour{
2828
x.numbers = x1
2929
y.numbers = y1
3030
z(values)

examples/src/main/kotlin/contour/ConnectNullGaps.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ fun main() {
2222
listOf<Number?>(null, null, null, 27, null, null, null, 21),
2323
listOf<Number?>(null, null, null, 26, 25, 24, 23, 22))
2424

25-
val contour1 = Contour {
25+
val contour1 = Contour{
2626
x.set(x1)
2727
y.set(y2)
2828
z.set(z1)

examples/src/main/kotlin/customPage.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import kotlin.math.PI
88
import kotlin.math.cos
99
import kotlin.math.sin
1010

11-
@UnstablePlotlyAPI
1211
fun main() {
1312

1413
val x1 = (0..100).map { it.toDouble() / 100.0 }

examples/src/main/kotlin/downloadChartAsSVG.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import kscience.plotly.models.ScatterMode
88
*/
99
fun main() {
1010
val fragment = Plotly.fragment {
11-
val plotConfig = PlotlyConfig {
11+
val plotConfig = PlotlyConfig{
1212
saveAsSvg()
1313
}
1414

examples/src/main/kotlin/dynamicServer.kt

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import hep.dataforge.meta.invoke
12
import kotlinx.coroutines.GlobalScope
23
import kotlinx.coroutines.delay
34
import kotlinx.coroutines.isActive
45
import kotlinx.coroutines.launch
56
import kotlinx.html.a
67
import kotlinx.html.h1
78
import kscience.plotly.Plotly
8-
import kscience.plotly.layout
99
import kscience.plotly.models.Trace
1010
import kscience.plotly.models.invoke
1111
import kscience.plotly.plot
@@ -14,25 +14,30 @@ import kscience.plotly.server.pushUpdates
1414
import kscience.plotly.server.serve
1515
import kscience.plotly.server.show
1616
import kotlin.math.PI
17+
import kotlin.math.cos
1718
import kotlin.math.sin
1819

1920

2021
fun main() {
2122

22-
val server = Plotly.serve(port = 3872) {
23+
val freq = 1.0 / 1000
24+
val oscillationFreq = 1.0 / 10000
2325

24-
val x = (0..100).map { it.toDouble() / 100.0 }
25-
val y = x.map { sin(2.0 * PI * it) }
26+
val x = (0..100).map { it.toDouble() / 100.0 }
27+
val sinY = x.map { sin(2.0 * PI * it) }
28+
val cosY = x.map { cos(2.0 * PI * it) }
2629

27-
val trace = Trace.invoke(x, y) { name = "sin" }
30+
val sinTrace = Trace(x, sinY) { name = "sin" }
31+
val cosTrace = Trace(x, cosY) { name = "cos" }
2832

33+
val server = Plotly.serve(port = 3872) {
2934

3035
//root level plots go to default page
3136
page { plotly ->
3237
h1 { +"This is the plot page" }
3338
a("/other") { +"The other page" }
3439
plot(renderer = plotly) {
35-
traces(trace)
40+
traces(sinTrace, cosTrace)
3641
layout {
3742
title = "Other dynamic plot"
3843
xaxis.title = "x axis name"
@@ -45,7 +50,7 @@ fun main() {
4550
h1 { +"This is the other plot page" }
4651
a("/") { +"Back to the main page" }
4752
plot(renderer = plotly) {
48-
traces(trace)
53+
traces(sinTrace)
4954
layout {
5055
title = "Dynamic plot"
5156
xaxis.title = "x axis name"
@@ -54,20 +59,24 @@ fun main() {
5459
}
5560
}
5661

57-
GlobalScope.launch {
58-
var time: Long = 0
59-
while (isActive) {
60-
delay(10)
61-
time += 10
62-
val dynamicY = x.map { sin(2.0 * PI * (it + time.toDouble() / 1000.0)) }
63-
trace.y.set(dynamicY)
64-
}
65-
}
6662
pushUpdates(50) // start sending updates via websocket to the front-end
6763
}
6864

6965
server.show()
7066

67+
//Start pushing updates
68+
GlobalScope.launch {
69+
var time: Long = 0
70+
71+
while (isActive) {
72+
delay(10)
73+
time += 10
74+
sinTrace.y.numbers = x.map { sin(2.0 * PI * (it + time.toDouble() * freq)) }
75+
val cosAmp = cos(2.0 * PI * oscillationFreq * time)
76+
cosTrace.y.numbers = x.map { cos(2.0 * PI * (it + time.toDouble() * freq)) * cosAmp }
77+
}
78+
}
79+
7180
println("Press Enter to close server")
7281
readLine()
7382

0 commit comments

Comments
 (0)