-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from mipt-npm/dev
0.3.0 release
- Loading branch information
Showing
47 changed files
with
3,940 additions
and
425 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Run script | ||
|
||
`plotlykt-script customPage.plotly.kts` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} |
Oops, something went wrong.