Skip to content

Commit

Permalink
Merge pull request #52 from mipt-npm/dev
Browse files Browse the repository at this point in the history
0.3.0 release
  • Loading branch information
altavir authored Nov 28, 2020
2 parents 476ca93 + 48deaa1 commit f97a2a6
Show file tree
Hide file tree
Showing 47 changed files with 3,940 additions and 425 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

### Security

## [0.3.0]
### Added
-Support for `plotly.kts` in IDEA

### Changed
- Serialization API is encapsulated (not longer exposed) in order to provide compatibility with new serialization.
- Migration to Kotlin 1.4
- Minor breaking change in Plot to encapsulate serialization usage

### Deprecated

### Removed

### Fixed

### Security
## [0.2.0]

Expand Down
25 changes: 16 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
plugins {
val toolsVersion = "0.5.2"
id("scientifik.mpp") version toolsVersion apply false
id("scientifik.jvm") version toolsVersion apply false
id("scientifik.publish") version toolsVersion apply false
id("org.jetbrains.changelog") version "0.4.0"
kotlin("js") apply false
id("ru.mipt.npm.project")
}

val ktorVersion by extra("1.3.2")
val dataforgeVersion by extra("0.1.8")
val htmlVersion by extra("0.7.1")
val ktorVersion by extra("1.4.1")
val dataforgeVersion by extra("0.2.0")
val htmlVersion by extra("0.7.2")

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

allprojects {
group = "kscience.plotlykt"
version = "0.2.0"
version = "0.3.0"

repositories {
mavenLocal()
maven("https://dl.bintray.com/kotlin/kotlin-eap")
maven("https://kotlin.bintray.com/kotlinx")
}
}

apiValidation {
ignoredProjects.addAll(listOf("examples", "fx-demo", "js-demo"))
}
Binary file added docs/Dependency structure.vsdx
Binary file not shown.
467 changes: 467 additions & 0 deletions docs/overview.html

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,14 @@ repositories {
mavenLocal()
jcenter()
maven("https://dl.bintray.com/mipt-npm/dataforge")
maven("https://dl.bintray.com/mipt-npm/scientifik")
maven("https://dl.bintray.com/mipt-npm/kscience")
maven("https://dl.bintray.com/mipt-npm/dev")
maven("https://dl.bintray.com/kotlin/ktor/")
maven("https://dl.bintray.com/kotlin/kotlin-eap")
maven("https://kotlin.bintray.com/kotlinx")
}

dependencies {
implementation(project(":plotlykt-server"))
implementation(kotlin("script-runtime"))
implementation(project(":plotlykt-script"))
implementation("de.mpicbg.scicomp:krangl:0.13")
implementation("org.apache.commons:commons-csv:1.8")
}
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/kotlin/contour/BasicContour.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fun main() {
val x1 = listOf(-9, -6, -5, -3, -1)
val y1 = listOf(0, 1, 4, 5, 7)

val contour = Contour {
val contour = Contour{
x.numbers = x1
y.numbers = y1
z(values)
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/kotlin/contour/ConnectNullGaps.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fun main() {
listOf<Number?>(null, null, null, 27, null, null, null, 21),
listOf<Number?>(null, null, null, 26, 25, 24, 23, 22))

val contour1 = Contour {
val contour1 = Contour{
x.set(x1)
y.set(y2)
z.set(z1)
Expand Down
1 change: 0 additions & 1 deletion examples/src/main/kotlin/customPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin

@UnstablePlotlyAPI
fun main() {

val x1 = (0..100).map { it.toDouble() / 100.0 }
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/kotlin/downloadChartAsSVG.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import kscience.plotly.models.ScatterMode
*/
fun main() {
val fragment = Plotly.fragment {
val plotConfig = PlotlyConfig {
val plotConfig = PlotlyConfig{
saveAsSvg()
}

Expand Down
41 changes: 25 additions & 16 deletions examples/src/main/kotlin/dynamicServer.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import hep.dataforge.meta.invoke
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlinx.html.a
import kotlinx.html.h1
import kscience.plotly.Plotly
import kscience.plotly.layout
import kscience.plotly.models.Trace
import kscience.plotly.models.invoke
import kscience.plotly.plot
Expand All @@ -14,25 +14,30 @@ import kscience.plotly.server.pushUpdates
import kscience.plotly.server.serve
import kscience.plotly.server.show
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin


fun main() {

val server = Plotly.serve(port = 3872) {
val freq = 1.0 / 1000
val oscillationFreq = 1.0 / 10000

val x = (0..100).map { it.toDouble() / 100.0 }
val y = x.map { sin(2.0 * PI * it) }
val x = (0..100).map { it.toDouble() / 100.0 }
val sinY = x.map { sin(2.0 * PI * it) }
val cosY = x.map { cos(2.0 * PI * it) }

val trace = Trace.invoke(x, y) { name = "sin" }
val sinTrace = Trace(x, sinY) { name = "sin" }
val cosTrace = Trace(x, cosY) { name = "cos" }

val server = Plotly.serve(port = 3872) {

//root level plots go to default page
page { plotly ->
h1 { +"This is the plot page" }
a("/other") { +"The other page" }
plot(renderer = plotly) {
traces(trace)
traces(sinTrace, cosTrace)
layout {
title = "Other dynamic plot"
xaxis.title = "x axis name"
Expand All @@ -45,7 +50,7 @@ fun main() {
h1 { +"This is the other plot page" }
a("/") { +"Back to the main page" }
plot(renderer = plotly) {
traces(trace)
traces(sinTrace)
layout {
title = "Dynamic plot"
xaxis.title = "x axis name"
Expand All @@ -54,20 +59,24 @@ fun main() {
}
}

GlobalScope.launch {
var time: Long = 0
while (isActive) {
delay(10)
time += 10
val dynamicY = x.map { sin(2.0 * PI * (it + time.toDouble() / 1000.0)) }
trace.y.set(dynamicY)
}
}
pushUpdates(50) // start sending updates via websocket to the front-end
}

server.show()

//Start pushing updates
GlobalScope.launch {
var time: Long = 0

while (isActive) {
delay(10)
time += 10
sinTrace.y.numbers = x.map { sin(2.0 * PI * (it + time.toDouble() * freq)) }
val cosAmp = cos(2.0 * PI * oscillationFreq * time)
cosTrace.y.numbers = x.map { cos(2.0 * PI * (it + time.toDouble() * freq)) * cosAmp }
}
}

println("Press Enter to close server")
readLine()

Expand Down
71 changes: 71 additions & 0 deletions examples/src/main/kotlin/misc/dynamicBars.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import hep.dataforge.meta.invoke
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kscience.plotly.Plotly
import kscience.plotly.models.Bar
import kscience.plotly.plot
import kscience.plotly.server.close
import kscience.plotly.server.pushUpdates
import kscience.plotly.server.serve
import kscience.plotly.server.show
import kotlin.random.Random


fun main() {
val initialValue = (1..10).toList()

val traces = (0..2).associate { i ->
val name = "Series $i"

name to Bar {
x.strings = initialValue.map { "Column: $it" }
y.numbers = initialValue
this.name = name
}
}

val server = Plotly.serve(port = 3872) {

//root level plots go to default page
page { plotly ->
plot(renderer = plotly) {
traces(traces.values)
layout {
title = "Other dynamic plot"
xaxis.title = "x axis name"
yaxis.title = "y axis name"
}
}
}

pushUpdates(100) // start sending updates via websocket to the front-end
}

server.show()

//Start pushing updates
GlobalScope.launch {
delay(1000)
while (isActive) {
repeat(10) { columnIndex ->
repeat(3) { seriesIndex ->
delay(200)
traces["Series $seriesIndex"]?.let {bar->
println("Updating ${bar.name}, Column $columnIndex")
//TODO replace with dynamic data API
val yValues = bar.y.doubles
yValues[columnIndex] = Random.nextInt(0,100).toDouble()
bar.y.doubles = yValues
}
}
}
}
}

println("Press Enter to close server")
readLine()

server.close()
}
2 changes: 1 addition & 1 deletion examples/src/main/kotlin/scatter/LogAxisScale.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package scatter

import hep.dataforge.meta.invoke
import kscience.plotly.Plotly
import kscience.plotly.layout
import kscience.plotly.makeFile
import kscience.plotly.models.AxisType
import kscience.plotly.models.Scatter
Expand Down
3 changes: 3 additions & 0 deletions examples/src/main/kotlin/script/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Run script

`plotlykt-script customPage.plotly.kts`
29 changes: 29 additions & 0 deletions examples/src/main/kotlin/script/customPage.plotly.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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" }


plot {
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"
}
}
}
6 changes: 1 addition & 5 deletions fx-demo/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
// Apply the Kotlin JVM plugin to add support for Kotlin on the JVM.
kotlin("jvm")
application
id("org.openjfx.javafxplugin") version "0.0.9"
Expand All @@ -11,11 +10,8 @@ repositories {
mavenLocal()
jcenter()
maven("https://dl.bintray.com/mipt-npm/dataforge")
maven("https://dl.bintray.com/mipt-npm/scientifik")
maven("https://dl.bintray.com/mipt-npm/kscience")
maven("https://dl.bintray.com/mipt-npm/dev")
maven("https://dl.bintray.com/kotlin/ktor/")
maven("https://dl.bintray.com/kotlin/kotlin-eap")
maven("https://kotlin.bintray.com/kotlinx")
}

dependencies {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
30 changes: 14 additions & 16 deletions js-demo/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
plugins {
kotlin("js")
kotlin("js")
}

repositories {
mavenLocal()
jcenter()
maven("https://dl.bintray.com/mipt-npm/dataforge")
maven("https://dl.bintray.com/mipt-npm/scientifik")
maven("https://dl.bintray.com/mipt-npm/dev")
maven("https://dl.bintray.com/kotlin/ktor/")
maven("https://dl.bintray.com/kotlin/kotlin-wrappers")
maven("https://kotlin.bintray.com/kotlinx")
mavenLocal()
jcenter()
maven("https://dl.bintray.com/mipt-npm/dataforge")
maven("https://dl.bintray.com/mipt-npm/kscience")
maven("https://dl.bintray.com/mipt-npm/dev")
}

kotlin{
target {
browser()
}
kotlin {
js(IR) {
browser()
binaries.executable()
}
}

dependencies{
implementation(project(":plotlykt-core"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.3.7")
dependencies {
implementation(project(":plotlykt-core"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.3.9")
}
Loading

0 comments on commit f97a2a6

Please sign in to comment.