Refactor plotly

This commit is contained in:
2025-02-09 15:53:01 +03:00
parent 2c2dcd45f8
commit 82538ad70c
146 changed files with 898 additions and 759 deletions

View File

@@ -1,3 +1,4 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import space.kscience.gradle.useApache2Licence
import space.kscience.gradle.useSPCTeam
@@ -6,7 +7,8 @@ plugins {
alias(spclibs.plugins.kotlinx.kover)
}
val dataforgeVersion by extra("0.10.0")
val dataforgeVersion by extra("0.10.1-dev-1")
val plotlyVersion by extra("0.8.0")
allprojects {
group = "space.kscience"
@@ -24,9 +26,9 @@ subprojects {
maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
tasks.withType<KotlinCompile> {
compilerOptions {
freeCompilerArgs.addAll("-Xcontext-receivers")
freeCompilerArgs.addAll("-Xcontext-parameters")
}
}
@@ -43,7 +45,7 @@ ksciencePublish {
useApache2Licence()
useSPCTeam()
}
repository("spc","https://maven.sciprog.center/kscience")
repository("spc", "https://maven.sciprog.center/kscience")
central()
}

View File

@@ -1,13 +1,11 @@
import org.jetbrains.compose.web.css.*
import org.jetbrains.compose.web.dom.Div
import org.jetbrains.compose.web.renderComposable
import org.w3c.dom.Document
import space.kscience.dataforge.context.Context
import space.kscience.plotly.PlotlyPlugin
import space.kscience.plotly.models.Trace
import space.kscience.plotly.models.scatter
import space.kscience.visionforge.Colors
import space.kscience.visionforge.html.Application
import space.kscience.visionforge.html.Tabs
import space.kscience.visionforge.html.VisionForgeStyles
import space.kscience.visionforge.html.startApplication
@@ -24,15 +22,13 @@ fun Trace.appendXYLatest(x: Number, y: Number, history: Int = 400, xErr: Number?
yErr?.let { error_y.array = (error_y.array + yErr).takeLast(history) }
}
private class JsPlaygroundApp : Application {
public fun main() {
val playgroundContext = Context {
plugin(ThreePlugin)
plugin(PlotlyPlugin)
plugin(MarkupPlugin)
}
override fun start(document: Document, state: Map<String, Any>) {
startApplication { document ->
// val solids = playgroundContext.request(Solids)
// val client = playgroundContext.request(JsVisionClient)
@@ -98,9 +94,4 @@ private class JsPlaygroundApp : Application {
}
}
}
}
public fun main() {
startApplication(::JsPlaygroundApp)
}

View File

@@ -1,8 +1,8 @@
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.remember
import bootstrap.Column
import bootstrap.Row
import app.softwork.bootstrapcompose.Column
import app.softwork.bootstrapcompose.Row
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import org.jetbrains.compose.web.css.*
@@ -14,6 +14,7 @@ import space.kscience.dataforge.meta.Meta
import space.kscience.plotly.Plot
import space.kscience.plotly.layout
import space.kscience.plotly.models.Trace
import space.kscience.plotly.models.invoke
import space.kscience.visionforge.Colors
import space.kscience.visionforge.html.VisionDiv
import space.kscience.visionforge.html.zIndex

View File

@@ -2,7 +2,6 @@ plugins {
id("space.kscience.gradle.mpp")
alias(spclibs.plugins.compose.compiler)
alias(spclibs.plugins.compose.jb)
// alias(spclibs.plugins.ktor)
}
group = "ru.mipt.npm"
@@ -11,7 +10,7 @@ group = "ru.mipt.npm"
kscience {
fullStack(
"muon-monitor.js",
development = true,
development = false,
jvmConfig = {
binaries {
executable {
@@ -49,11 +48,7 @@ kscience {
implementation(projects.visionforgeThreejs)
}
}
kotlin {
explicitApi = null
}
//application {
// mainClass.set("ru.mipt.npm.muon.monitor.MMServerKt")
//}
}

View File

@@ -12,7 +12,7 @@ repositories {
}
kotlin {
jvmToolchain(11)
jvmToolchain(17)
js(IR) {
browser {
webpackTask {
@@ -31,7 +31,7 @@ kotlin {
jvm {
// withJava()
compilerOptions {
freeCompilerArgs.addAll("-Xjvm-default=all", "-Xopt-in=kotlin.RequiresOptIn", "-Xlambdas=indy", "-Xcontext-receivers")
freeCompilerArgs.addAll("-Xjvm-default=all", "-Xcontext-parameters")
}
testRuns["test"].executionTask.configure {

View File

@@ -5,11 +5,11 @@ import space.kscience.dataforge.meta.ValueType
import space.kscience.plotly.layout
import space.kscience.plotly.models.ScatterMode
import space.kscience.plotly.models.TextPosition
import space.kscience.plotly.scatter
import space.kscience.plotly.models.scatter
import space.kscience.plotly.plotly
import space.kscience.tables.ColumnHeader
import space.kscience.visionforge.html.ResourceLocation
import space.kscience.visionforge.markup.markdown
import space.kscience.visionforge.plotly.plotly
import space.kscience.visionforge.solid.axes
import space.kscience.visionforge.solid.box
import space.kscience.visionforge.solid.solid

View File

@@ -5,15 +5,21 @@ import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import space.kscience.dataforge.meta.configure
import space.kscience.kmath.complex.Quaternion
import space.kscience.kmath.complex.QuaternionField
import space.kscience.kmath.complex.QuaternionAlgebra
import space.kscience.kmath.complex.conjugate
import space.kscience.kmath.geometry.*
import space.kscience.kmath.geometry.Angle
import space.kscience.kmath.geometry.degrees
import space.kscience.kmath.geometry.euclidean3d.Float64Space3D
import space.kscience.kmath.geometry.euclidean3d.RotationOrder
import space.kscience.kmath.geometry.euclidean3d.fromEuler
import space.kscience.kmath.geometry.euclidean3d.fromRotation
import space.kscience.visionforge.Colors
import space.kscience.visionforge.solid.*
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin
fun main() = serve {
suspend fun main() = serve {
// val azimuth = 60.degrees
// val inclination = 15.degrees
@@ -37,7 +43,9 @@ fun main() = serve {
rotationX = -PI / 2
rotationZ = PI
//axes(200)
ambientLight()
ambientLight {
color(Colors.white)
}
val platform = solidGroup("platform") {
cylinder(50, 5, name = "base")
solidGroup("frame") {
@@ -72,20 +80,20 @@ fun main() = serve {
val xPeriod = 5000 //ms
val yPeriod = 7000 //ms
val incRot = Quaternion.fromRotation(30.degrees, Euclidean3DSpace.zAxis)
val incRot = Quaternion.fromRotation(30.degrees, Float64Space3D.zAxis)
context.launch {
var time: Long = 0L
while (isActive) {
with(QuaternionField) {
with(QuaternionAlgebra) {
delay(200)
platform.quaternion = Quaternion.fromRotation(
15.degrees * sin(time.toDouble() * 2 * PI / xPeriod),
Euclidean3DSpace.xAxis
Float64Space3D.xAxis
) * Quaternion.fromRotation(
15.degrees * cos(time * 2 * PI / yPeriod),
Euclidean3DSpace.yAxis
Float64Space3D.yAxis
)
val qi = platform.quaternion * incRot

View File

@@ -1,6 +1,6 @@
package space.kscience.visionforge.examples
import space.kscience.kmath.geometry.Euclidean3DSpace
import space.kscience.kmath.geometry.euclidean3d.Float64Space3D
import space.kscience.kmath.geometry.radians
import space.kscience.visionforge.html.ResourceLocation
import space.kscience.visionforge.solid.*
@@ -13,7 +13,7 @@ fun main() = makeVisionFile(resourceLocation = ResourceLocation.SYSTEM) {
axes(100, "root-axes")
solidGroup("group") {
z = 100
rotate((PI / 4).radians, Euclidean3DSpace.vector(1, 1, 1))
rotate((PI / 4).radians, Float64Space3D.vector(1, 1, 1))
axes(100, "local-axes")
box(50, 50, 50, "box")
}

View File

@@ -11,7 +11,7 @@ import space.kscience.visionforge.onSubmit
import kotlin.time.Duration.Companion.seconds
fun main() = serve {
suspend fun main() = serve {
val events = ArrayDeque<VisionControlEvent>(10)

View File

@@ -14,16 +14,16 @@ import space.kscience.dataforge.context.request
import space.kscience.plotly.PlotlyPlugin
import space.kscience.plotly.layout
import space.kscience.plotly.models.Trace
import space.kscience.plotly.models.invoke
import space.kscience.plotly.plotly
import space.kscience.visionforge.html.VisionPage
import space.kscience.visionforge.server.close
import space.kscience.visionforge.server.openInBrowser
import space.kscience.visionforge.server.visionPage
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin
fun main() {
suspend fun main() {
val plotlyPlugin = Global.request(PlotlyPlugin)
val visionManager = plotlyPlugin.visionManager
@@ -105,5 +105,5 @@ fun main() {
}
server.close()
server.stop()
}

View File

@@ -27,7 +27,7 @@ suspend fun main() {
}
val form = VisionOfHtmlForm("form").apply {
onPropertyChange(visionManager.context) {
onPropertyChange(visionManager.context) { _, _ ->
println(values)
}
}

View File

@@ -1,10 +1,10 @@
package space.kscience.visionforge.examples
import space.kscience.dataforge.meta.Value
import space.kscience.plotly.Plotly
import space.kscience.plotly.layout
import space.kscience.plotly.models.*
import space.kscience.visionforge.html.ResourceLocation
import space.kscience.visionforge.plotly.plotly
fun main() = makeVisionFile(resourceLocation = ResourceLocation.SYSTEM) {
vision {
@@ -39,9 +39,11 @@ fun main() = makeVisionFile(resourceLocation = ResourceLocation.SYSTEM) {
}
name = "F"
x(10.07, 34.83, 10.65, 12.43, 24.08, 13.42, 12.48, 29.8, 14.52, 11.38,
x(
10.07, 34.83, 10.65, 12.43, 24.08, 13.42, 12.48, 29.8, 14.52, 11.38,
20.27, 11.17, 12.26, 18.26, 8.51, 10.33, 14.15, 13.16, 17.47, 27.05, 16.43,
8.35, 18.64, 11.87, 19.81, 43.11, 13.0, 12.74, 13.0, 16.4, 16.47, 18.78)
8.35, 18.64, 11.87, 19.81, 43.11, 13.0, 12.74, 13.0, 16.4, 16.47, 18.78
)
}
val trace2 = Violin {
@@ -76,12 +78,14 @@ fun main() = makeVisionFile(resourceLocation = ResourceLocation.SYSTEM) {
}
name = "M"
x(27.2, 22.76, 17.29, 19.44, 16.66, 32.68, 15.98, 13.03, 18.28, 24.71,
x(
27.2, 22.76, 17.29, 19.44, 16.66, 32.68, 15.98, 13.03, 18.28, 24.71,
21.16, 11.69, 14.26, 15.95, 8.52, 22.82, 19.08, 16.0, 34.3, 41.19, 9.78,
7.51, 28.44, 15.48, 16.58, 7.56, 10.34, 13.51, 18.71, 20.53)
7.51, 28.44, 15.48, 16.58, 7.56, 10.34, 13.51, 18.71, 20.53
)
}
plotly {
Plotly.plot {
traces(trace1, trace2)
layout {
width = 800

View File

@@ -46,7 +46,7 @@ internal class VariableBox(val xSize: Number, val ySize: Number) : ThreeJsVision
mesh.scale.z = properties.getValue(VALUE)?.number?.toDouble() ?: 1.0
//add listener to object properties
onPropertyChange(three.context) { name ->
onPropertyChange(three.context) { name, _ ->
when {
name == VALUE -> {
val value = properties.getValue(VALUE)?.int ?: 0

View File

@@ -9,6 +9,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
### Changed
- Moved plotly implementation on top of VisionForge framework.
- `Plot` and `Trace` now inherit `Vision`.
- `Trace` no longer inherit `Scheme`. It requires `Trace.Factory` and import of `space.kscience.plotly.models.invoke` to be automatically created.
- `makeFile` -> `show`
- `PlotlyFragment` -> `HtmlVisionFragment`, `PlotlyPage` -> `HtmlVisionPage`
- Explicitly passing renderer in fragments is no longer necessary
- `Plotly.serve` is replaced by `embeddedServer(...){ plotlyPage(...) }`
- KTor 3.x
### Deprecated

View File

@@ -2,10 +2,11 @@ plugins{
id("org.jetbrains.changelog")
}
val plotlyVersion: String by rootProject.extra
allprojects {
group = "space.kscience"
version = "0.8.0"
version = plotlyVersion
}
readme {

View File

@@ -8,23 +8,23 @@ repositories {
}
dependencies {
implementation(projects.plotly.plotlyktCore)
implementation(projects.plotly.plotlyktServer)
implementation(projects.plotly.plotlyktScript)
implementation(kotlin("script-runtime"))
implementation("org.jetbrains.kotlinx:dataframe:0.13.1")
}
kotlin{
jvmToolchain(11)
jvmToolchain(17)
}
// A workaround for https://youtrack.jetbrains.com/issue/KT-44101
val copyPlotlyResources by tasks.creating(Copy::class){
dependsOn(":plotly:plotlykt-core:jvmProcessResources")
mustRunAfter(":plotly:plotlykt-core:jvmTestProcessResources")
from(project(":plotly:plotlykt-core").layout.buildDirectory.file("processedResources/jvm"))
into(layout.buildDirectory.file("resources"))
dependsOn(":plotly:plotlykt-server:jvmProcessResources")
mustRunAfter(":plotly:plotlykt-server:jvmTestProcessResources")
from(project(":plotly:plotlykt-server").layout.buildDirectory.file("processedResources/jvm/main"))
into(layout.buildDirectory.file("resources/main"))
}
tasks.getByName("classes").dependsOn(copyPlotlyResources)

View File

@@ -16,13 +16,14 @@ kotlin {
sourceSets {
jvmMain {
dependencies {
implementation(projects.plotly.plotlyktCore)
implementation(projects.plotly.plotlyktServer)
api("io.ktor:ktor-server-cio")
implementation(compose.runtime)
implementation(compose.foundation)
implementation(compose.material)
implementation(compose.desktop.currentOs)
implementation("io.github.kevinnzou:compose-webview-multiplatform:1.9.8")
implementation("io.github.kevinnzou:compose-webview-multiplatform:1.9.40")
implementation(spclibs.logback.classic)
}
}

View File

@@ -12,7 +12,10 @@ import com.multiplatform.webview.web.WebView
import com.multiplatform.webview.web.rememberWebViewNavigator
import com.multiplatform.webview.web.rememberWebViewStateWithHTMLData
import dev.datlag.kcef.KCEF
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.withContext
import java.io.File
private val allowedPages = listOf(
"Static",
@@ -68,19 +71,50 @@ fun App() {
}
fun main() = application {
KCEF.initBlocking(
builder = {
progress {
onDownloading {
println("Download progress: $it%")
}
}
release(true)
}
)
Window(onCloseRequest = ::exitApplication) {
MaterialTheme {
App()
var downloadProgress by remember { mutableStateOf(-1F) }
var initialized by remember { mutableStateOf(false) } // if true, KCEF can be used to create clients, browsers etc
val bundleLocation = System.getProperty("compose.application.resources.dir")?.let { File(it) } ?: File(".")
LaunchedEffect(Unit) {
withContext(Dispatchers.IO) { // IO scope recommended but not required
KCEF.init(
builder = {
installDir(File(bundleLocation, "kcef-bundle")) // recommended, but not necessary
progress {
onDownloading {
downloadProgress = it
println("Downloading $it")
// use this if you want to display a download progress for example
}
onInitialized {
initialized = true
}
}
},
onError = {
// error during initialization
it?.printStackTrace()
},
onRestartRequired = {
// all required CEF packages downloaded but the application needs a restart to load them (unlikely to happen)
println("Restart required")
}
)
}
}
if (initialized) {
MaterialTheme {
App()
}
}
DisposableEffect(Unit) {
onDispose {
KCEF.disposeBlocking()
}
}
}
}

View File

@@ -1,6 +1,8 @@
package space.kscience.plotly.compose
import io.ktor.server.engine.ApplicationEngine
import io.ktor.server.cio.CIO
import io.ktor.server.engine.EmbeddedServer
import io.ktor.server.engine.embeddedServer
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.StateFlow
@@ -8,14 +10,27 @@ import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import space.kscience.plotly.*
import space.kscience.plotly.models.Scatter
import space.kscience.plotly.models.invoke
import space.kscience.plotly.server.pushUpdates
import space.kscience.plotly.server.serve
import space.kscience.plotly.models.Trace
import space.kscience.visionforge.html.makeString
import space.kscience.visionforge.plotly.plotlyPage
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin
public fun Scatter(
xs: Any,
ys: Any? = null,
zs: Any? = null,
block: Trace.() -> Unit,
): Scatter = Scatter().apply {
x.set(xs)
if (ys != null) y.set(ys)
if (zs != null) z.set(zs)
block()
}
fun staticPlot(): String = Plotly.page {
val x = (0..100).map { it.toDouble() / 100.0 }.toDoubleArray()
val y1 = x.map { sin(2.0 * PI * it) }.toDoubleArray()
@@ -38,9 +53,11 @@ fun staticPlot(): String = Plotly.page {
}
}.makeString()
fun CoroutineScope.servePlots(scale: StateFlow<Number>): ApplicationEngine = Plotly.serve(this, port = 7778) {
page("Static") { container ->
val x = (0..100).map { it.toDouble() / 100.0 }.toDoubleArray()
fun CoroutineScope.servePlots(scale: StateFlow<Number>): EmbeddedServer<*, *> = embeddedServer(CIO, port = 7777) {
val x = (0..100).map { it.toDouble() / 100.0 }.toDoubleArray()
plotlyPage("Static") {
val y1 = x.map { sin(2.0 * PI * it) }.toDoubleArray()
val y2 = x.map { cos(2.0 * PI * it) }.toDoubleArray()
val trace1 = Scatter(x, y1) {
@@ -49,7 +66,8 @@ fun CoroutineScope.servePlots(scale: StateFlow<Number>): ApplicationEngine = Plo
val trace2 = Scatter(x, y2) {
name = "cos"
}
plotly(renderer = container) {//static plot
plot {
traces(trace1, trace2)
layout {
title = "First graph, row: 1, size: 8/12"
@@ -59,37 +77,35 @@ fun CoroutineScope.servePlots(scale: StateFlow<Number>): ApplicationEngine = Plo
}
}
page("Dynamic") { container ->
val x = (0..100).map { it.toDouble() / 100.0 }
plotlyPage("Dynamic") {
val y = x.map { sin(2.0 * PI * it) }
val trace = Scatter(x, y) { name = "sin" }
val plot = plotly("dynamic", config = PlotlyConfig { responsive = true }, renderer = container) {
plot {
traces(trace)
layout {
title = "Dynamic plot"
xaxis.title = "x axis name"
yaxis.title = "y axis name"
}
}
launch {
var time: Long = 0
while (isActive) {
delay(10)
time += 10
val frequency = scale.value.toDouble()
val dynamicY = x.map { sin(2.0 * PI * frequency * (it + time.toDouble() / 1000.0)) }
//trace.y.numbers = dynamicY
plot.data[0].y.numbers = dynamicY
plot.layout {
xaxis.title = "x axis name (t = $time)"
launch {
var time: Long = 0
while (isActive) {
delay(10)
time += 10
val frequency = scale.value.toDouble()
val dynamicY = x.map { sin(2.0 * PI * frequency * (it + time.toDouble() / 1000.0)) }
//trace.y.numbers = dynamicY
data[0].y.numbers = dynamicY
layout {
xaxis.title = "x axis name (t = $time)"
}
}
}
}
}
pushUpdates(100)
}

View File

@@ -1,4 +1,3 @@
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.models.ScatterMode
import space.kscience.plotly.scatter

View File

@@ -1,7 +1,11 @@
package annotation
import space.kscience.plotly.*
import space.kscience.plotly.Plotly
import space.kscience.plotly.layout
import space.kscience.plotly.models.ScatterMode
import space.kscience.plotly.models.scatter
import space.kscience.plotly.openInBrowser
import space.kscience.plotly.text
fun main() {
val plot = Plotly.plot {
@@ -26,5 +30,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,8 +2,8 @@ package bar
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.bar
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.bar
import space.kscience.plotly.openInBrowser
/**
@@ -16,8 +16,10 @@ fun main() {
bar {
x("Liam", "Sophie", "Jacob", "Mia", "William", "Olivia")
y(8.0, 8.0, 12.0, 12.0, 13.0, 20.0)
text("4.17 below the mean", "4.17 below the mean", "0.17 below the mean",
"0.17 below the mean", "0.83 above the mean", "7.83 above the mean")
text(
"4.17 below the mean", "4.17 below the mean", "0.17 below the mean",
"0.17 below the mean", "0.83 above the mean", "7.83 above the mean"
)
marker {
color("rgb(142, 124, 195)")
}
@@ -41,5 +43,5 @@ fun main() {
bargap = 0.05
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,9 +2,10 @@ package bar
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.Bar
import space.kscience.plotly.models.BarMode
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
/**
@@ -68,5 +69,5 @@ fun main() {
bargroupgap = 0.1
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,9 +2,10 @@ package bar
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.Bar
import space.kscience.plotly.models.BarMode
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
import space.kscience.plotly.palettes.Xkcd
@@ -39,5 +40,5 @@ fun main() {
barmode = BarMode.group
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,9 +2,10 @@ package bar
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.Bar
import space.kscience.plotly.models.TextPosition
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
/**
@@ -58,5 +59,5 @@ fun main() {
title = "January 2013 Sales Report"
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,9 +2,10 @@ package bar
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.Bar
import space.kscience.plotly.models.Orientation
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
import kotlin.random.Random
@@ -57,5 +58,5 @@ fun main() {
}
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,8 +2,9 @@ package bar
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.Bar
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
/**
@@ -37,5 +38,5 @@ fun main() {
title = "Customizing individual bar base"
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,8 +2,8 @@ package bar
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.bar
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.bar
import space.kscience.plotly.openInBrowser
/**
@@ -19,8 +19,12 @@ fun main() {
y(20, 14, 23, 25, 22)
widthList = listOf<Number>(0.8, 0.8, 0.9, 0.6, 0.8)
marker {
colors(listOf("rgba(204, 204, 204, 1)", "rgba(222, 45, 38, 0.8)", "rgba(204, 204, 204, 1)",
"rgba(204, 204, 204, 1)", "rgba(204, 204, 204, 1)"))
colors(
listOf(
"rgba(204, 204, 204, 1)", "rgba(222, 45, 38, 0.8)", "rgba(204, 204, 204, 1)",
"rgba(204, 204, 204, 1)", "rgba(204, 204, 204, 1)"
)
)
}
}
@@ -28,5 +32,5 @@ fun main() {
title = "Least Used Feature"
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,11 +2,11 @@ package bar
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.bar
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.BarMode
import space.kscience.plotly.models.XAnchor
import space.kscience.plotly.models.YAnchor
import space.kscience.plotly.models.bar
import space.kscience.plotly.openInBrowser
/**
@@ -58,5 +58,5 @@ fun main() {
}
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,9 +2,10 @@ package box
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.Box
import space.kscience.plotly.models.BoxPoints
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
import kotlin.random.Random
@@ -42,5 +43,5 @@ fun main() {
title = "Basic Box Plot"
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,10 +2,11 @@ package box
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.Box
import space.kscience.plotly.models.BoxPoints
import space.kscience.plotly.models.Trace
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
import kotlin.random.Random
@@ -84,5 +85,5 @@ fun main() {
plot_bgcolor("rgb(243, 243, 243)")
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,11 +2,8 @@ package box
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.Box
import space.kscience.plotly.models.BoxMean
import space.kscience.plotly.models.BoxMode
import space.kscience.plotly.models.Orientation
import space.kscience.plotly.models.*
import space.kscience.plotly.openInBrowser
/**
@@ -63,5 +60,5 @@ fun main() {
boxmode = BoxMode.group
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,9 +2,10 @@ package box
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.Box
import space.kscience.plotly.models.BoxMean
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
import space.kscience.plotly.palettes.Xkcd
fun main() {
@@ -36,5 +37,5 @@ fun main() {
title = "Box Plot Styling Mean and Standard Deviation"
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,9 +2,10 @@ package box
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.Box
import space.kscience.plotly.models.BoxPoints
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
fun main() {
val y1 = listOf<Number>(0.75, 5.25, 5.5, 6, 6.2, 6.6, 6.80, 7.0, 7.2, 7.5, 7.5, 7.75, 8.15, 8.15,
@@ -62,5 +63,5 @@ fun main() {
title = "Box Plot Styling Outliers"
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -3,10 +3,11 @@ package candlestick
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.layout
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.AxisType
import space.kscience.plotly.models.CandleStick
import space.kscience.plotly.models.DragMode
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
internal val candleStickTrace = CandleStick {
x.strings = listOf(
@@ -211,5 +212,5 @@ fun main() {
type = AxisType.linear
}
}
}.makeFile()
}.openInBrowser()
}

View File

@@ -1,24 +1,22 @@
package candlestick
import io.ktor.server.cio.CIO
import io.ktor.server.engine.embeddedServer
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import space.kscience.plotly.Plotly
import space.kscience.plotly.Plotly.plot
import space.kscience.plotly.layout
import space.kscience.plotly.models.AxisType
import space.kscience.plotly.models.DragMode
import space.kscience.plotly.plotly
import space.kscience.plotly.server.close
import space.kscience.plotly.server.pushUpdates
import space.kscience.plotly.server.serve
import space.kscience.plotly.server.show
import space.kscience.visionforge.plotly.plotlyPage
import space.kscience.visionforge.server.openInBrowser
import kotlin.random.Random
fun main() {
val server = Plotly.serve {
pushUpdates(50)
page { plotly ->
plotly(renderer = plotly) {
suspend fun main() {
val server = embeddedServer(CIO, 7777) {
plotlyPage {
plot {
traces(candleStickTrace)
layout {
dragmode = DragMode.zoom
@@ -43,17 +41,18 @@ fun main() {
launch {
while (isActive) {
delay(400)
candleStickTrace.open.numbers = candleStickTrace.open.doubles.map { it + Random.nextDouble() - 0.5 }
candleStickTrace.open.numbers =
candleStickTrace.open.doubles.map { it + Random.nextDouble() - 0.5 }
}
}
}
}
}
server.show()
server.openInBrowser()
println("Enter 'exit' to close server")
while (readLine()?.trim() != "exit") {
//wait
}
server.close()
server.stop()
}

View File

@@ -1,3 +1,5 @@
import io.ktor.server.cio.CIO
import io.ktor.server.engine.embeddedServer
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
@@ -5,14 +7,12 @@ import kotlinx.coroutines.flow.zip
import kotlinx.coroutines.launch
import kotlinx.html.div
import kotlinx.html.link
import space.kscience.plotly.Plotly
import space.kscience.plotly.layout
import space.kscience.plotly.models.Trace
import space.kscience.plotly.plotly
import space.kscience.plotly.server.pushUpdates
import space.kscience.plotly.server.serve
import space.kscience.plotly.server.show
import space.kscience.plotly.plot
import space.kscience.plotly.trace
import space.kscience.visionforge.plotly.plotlyPage
import space.kscience.visionforge.server.openInBrowser
import java.time.Instant
import java.util.concurrent.ConcurrentLinkedQueue
import kotlin.math.cos
@@ -48,8 +48,8 @@ suspend fun Trace.updateXYFrom(flow: Flow<Iterable<Pair<Double, Double>>>) {
}
}
fun main() {
val server = Plotly.serve {
suspend fun main() {
val server = embeddedServer(CIO, port = 7777) {
val sinFlow = flow {
while (true) {
delay(40)
@@ -67,7 +67,7 @@ fun main() {
val sinCosFlow = sinFlow.zip(cosFlow) { sin, cos ->
sin to cos
}
page { renderer ->
plotlyPage("/") {
link {
rel = "stylesheet"
href = "https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css"
@@ -76,7 +76,7 @@ fun main() {
}
div("row") {
div("col-6") {
plotly(renderer = renderer) {
plot {
layout {
title = "sin property"
xaxis.title = "point index"
@@ -91,7 +91,7 @@ fun main() {
}
}
div("col-6") {
plotly(renderer = renderer) {
plot {
layout {
title = "cos property"
xaxis.title = "point index"
@@ -108,7 +108,7 @@ fun main() {
}
div("row") {
div("col-12") {
plotly(renderer = renderer) {
plot {
layout {
title = "cos vs sin"
xaxis.title = "sin"
@@ -126,13 +126,13 @@ fun main() {
}
}
pushUpdates(100) // start sending updates via websocket to the front-end
// pushUpdates(100) // start sending updates via websocket to the front-end
}
server.show()
server.openInBrowser()
println("Press Enter to close server")
readLine()
server.stop(1000, 5000)
server.stop()
}

View File

@@ -2,9 +2,10 @@ package contour
import space.kscience.plotly.Plotly
import space.kscience.plotly.layout
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.Contour
import space.kscience.plotly.models.MeasureMode
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
/**
@@ -15,16 +16,16 @@ import space.kscience.plotly.models.MeasureMode
*/
fun main() {
val values: List<List<Number>> = listOf(
listOf<Number>(10, 10.625, 12.5, 15.625, 20.0),
listOf<Number>(5.625, 6.25, 8.125, 11.25, 15.625),
listOf<Number>(2.5, 3.125, 5.0, 8.125, 12.5),
listOf<Number>(0.625, 1.25, 3.125, 6.25, 10.625),
listOf<Number>(0.0, 0.625, 2.5, 5.625, 10)
listOf<Number>(10, 10.625, 12.5, 15.625, 20.0),
listOf<Number>(5.625, 6.25, 8.125, 11.25, 15.625),
listOf<Number>(2.5, 3.125, 5.0, 8.125, 12.5),
listOf<Number>(0.625, 1.25, 3.125, 6.25, 10.625),
listOf<Number>(0.0, 0.625, 2.5, 5.625, 10)
)
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)
@@ -56,5 +57,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -3,8 +3,9 @@ package contour
import space.kscience.dataforge.meta.Value
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.Contour
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
import kotlin.math.cos
import kotlin.math.pow
import kotlin.math.sin
@@ -55,5 +56,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -1,7 +1,12 @@
package contour
import space.kscience.plotly.*
import space.kscience.plotly.Plotly
import space.kscience.plotly.layout
import space.kscience.plotly.models.Contour
import space.kscience.plotly.models.invoke
import space.kscience.plotly.page
import space.kscience.plotly.plot
import space.kscience.visionforge.html.openInBrowser
/**
@@ -14,15 +19,16 @@ fun main() {
val y2 = (0..6)
val z1 = listOf(
listOf<Number?>(null, null, null, 12, 13, 14, 15, 16),
listOf<Number?>(null, 1, null, 11, null, null, null, 17),
listOf<Number?>(null, 2, 6, 7, null, null, null, 18),
listOf<Number?>(null, 3, null, 8, null, null, null, 19),
listOf<Number?>(5, 4, 10, 9, null, null, null, 20),
listOf<Number?>(null, null, null, 27, null, null, null, 21),
listOf<Number?>(null, null, null, 26, 25, 24, 23, 22))
listOf<Number?>(null, null, null, 12, 13, 14, 15, 16),
listOf<Number?>(null, 1, null, 11, null, null, null, 17),
listOf<Number?>(null, 2, 6, 7, null, null, null, 18),
listOf<Number?>(null, 3, null, 8, null, null, null, 19),
listOf<Number?>(5, 4, 10, 9, null, null, null, 20),
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)
@@ -37,7 +43,7 @@ fun main() {
connectgaps = true
}
Plotly.fragment {
Plotly.page {
plot {
traces(contour1)
layout {
@@ -55,5 +61,5 @@ fun main() {
title = "Connected Gaps"
}
}
}.makeFile()
}.openInBrowser()
}

View File

@@ -3,9 +3,9 @@ package contour
import space.kscience.dataforge.meta.Value
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.contour
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.ContoursColoring
import space.kscience.plotly.models.contour
import space.kscience.plotly.openInBrowser
import kotlin.math.exp
import kotlin.math.pow
@@ -61,5 +61,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -3,8 +3,9 @@ package contour
import space.kscience.dataforge.meta.Value
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.Contour
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
fun main() {
val z1 = listOf(
@@ -31,5 +32,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -3,10 +3,10 @@ package contour
import space.kscience.dataforge.meta.Value
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.contour
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.ContoursColoring
import space.kscience.plotly.models.Dash
import space.kscience.plotly.models.contour
import space.kscience.plotly.openInBrowser
import kotlin.math.exp
import kotlin.math.pow
@@ -89,5 +89,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -3,8 +3,8 @@ package contour
import space.kscience.dataforge.meta.asValue
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.contour
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.contour
import space.kscience.plotly.openInBrowser
import kotlin.math.cos
import kotlin.math.ln
import kotlin.math.sin
@@ -48,5 +48,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -1,9 +1,13 @@
import kotlinx.html.div
import kotlinx.html.h1
import kotlinx.html.hr
import space.kscience.plotly.*
import space.kscience.plotly.Plotly
import space.kscience.plotly.layout
import space.kscience.plotly.models.Trace
import space.kscience.plotly.models.invoke
import space.kscience.plotly.page
import space.kscience.plotly.staticPlot
import space.kscience.visionforge.html.openInBrowser
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin
@@ -17,8 +21,8 @@ fun main() {
val trace1 = Trace(x1, y1) { name = "sin" }
val trace2 = Trace(x1, y2) { name = "cos" }
Plotly.page { container ->
plot(renderer = container) {
Plotly.page {
staticPlot{
traces(trace1, trace2)
layout {
title = "The plot above"
@@ -30,7 +34,7 @@ fun main() {
h1 { +"A custom separator" }
hr()
div {
plot {
staticPlot {
traces(trace1, trace2)
layout {
title = "The plot below"
@@ -39,5 +43,5 @@ fun main() {
}
}
}
}.makeFile()
}.openInBrowser()
}

View File

@@ -1,5 +1,7 @@
import space.kscience.plotly.*
import space.kscience.plotly.models.ScatterMode
import space.kscience.plotly.models.scatter
import space.kscience.visionforge.html.openInBrowser
/**
@@ -7,7 +9,7 @@ import space.kscience.plotly.models.ScatterMode
* - Download plot as SVG using configuration button
*/
fun main() {
val fragment = Plotly.fragment {
val fragment = Plotly.page {
val plotConfig = PlotlyConfig{
saveAsSvg()
}
@@ -32,5 +34,5 @@ fun main() {
}
}
}
fragment.makeFile()
fragment.openInBrowser()
}

View File

@@ -1,22 +1,21 @@
import io.ktor.server.cio.CIO
import io.ktor.server.engine.embeddedServer
import kotlinx.coroutines.*
import kotlinx.html.a
import kotlinx.html.h1
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.layout
import space.kscience.plotly.models.Trace
import space.kscience.plotly.models.invoke
import space.kscience.plotly.plotly
import space.kscience.plotly.server.close
import space.kscience.plotly.server.pushUpdates
import space.kscience.plotly.server.serve
import space.kscience.plotly.server.show
import space.kscience.plotly.plot
import space.kscience.visionforge.plotly.plotlyPage
import space.kscience.visionforge.server.openInBrowser
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin
@OptIn(DelicateCoroutinesApi::class)
fun main() {
suspend fun main() {
val freq = 1.0 / 1000
val oscillationFreq = 1.0 / 10000
@@ -28,14 +27,13 @@ fun main() {
val sinTrace = Trace(x, sinY) { name = "sin" }
val cosTrace = Trace(x, cosY) { name = "cos" }
val server = Plotly.serve(port = 7878) {
embedData = true
val server = embeddedServer(CIO, port = 7878) {
//root level plots go to default page
page { plotly ->
plotlyPage {
h1 { +"This is the plot page" }
a("/other") { +"The other page" }
plotly(renderer = plotly) {
plot {
traces(sinTrace, cosTrace)
layout {
title = "Other dynamic plot"
@@ -45,10 +43,10 @@ fun main() {
}
}
page("other") { plotly ->
plotlyPage("other") {
h1 { +"This is the other plot page" }
a("/") { +"Back to the main page" }
plotly(renderer = plotly) {
plot {
traces(sinTrace)
layout {
title = "Dynamic plot"
@@ -57,10 +55,9 @@ fun main() {
}
}
}
pushUpdates(50) // start sending updates via websocket to the front-end
}
}.start(false)
server.show()
server.openInBrowser()
//Start pushing updates
GlobalScope.launch {
@@ -76,9 +73,9 @@ fun main() {
}
println("Press Enter to close server")
while (readLine()?.trim() != "exit"){
while (readLine()?.trim() != "exit") {
//wait
}
server.close()
server.stop()
}

View File

@@ -1,7 +1,7 @@
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.ResourceLocation
import space.kscience.plotly.makeFile
import space.kscience.plotly.openInBrowser
import space.kscience.plotly.trace
import kotlin.math.PI
import kotlin.math.sin
@@ -28,5 +28,5 @@ fun main() {
}
}
plot.makeFile(resourceLocation = ResourceLocation.EMBED)
plot.openInBrowser(resourceLocation = ResourceLocation.EMBED)
}

View File

@@ -2,12 +2,8 @@ package errorPlots
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.ErrorType
import space.kscience.plotly.models.TraceOrder
import space.kscience.plotly.models.XAnchor
import space.kscience.plotly.models.YAnchor
import space.kscience.plotly.scatter
import space.kscience.plotly.models.*
import space.kscience.plotly.openInBrowser
/**
* - asymmetric error bars
@@ -70,5 +66,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,11 +2,11 @@ package errorPlots
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.bar
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.BarMode
import space.kscience.plotly.models.ErrorType
import space.kscience.plotly.models.XAnchor
import space.kscience.plotly.models.bar
import space.kscience.plotly.openInBrowser
/**
@@ -56,5 +56,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,8 +2,8 @@ package errorPlots
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.ErrorType
import space.kscience.plotly.openInBrowser
import space.kscience.plotly.trace
/**
@@ -33,5 +33,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,8 +2,8 @@ package errorPlots
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.box
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.box
import space.kscience.plotly.openInBrowser
import space.kscience.plotly.palettes.T10
import java.util.*
@@ -40,5 +40,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,11 +2,8 @@ package errorPlots
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.FillType
import space.kscience.plotly.models.Scatter
import space.kscience.plotly.models.ScatterMode
import space.kscience.plotly.models.Ticks
import space.kscience.plotly.models.*
import space.kscience.plotly.openInBrowser
/**
@@ -108,5 +105,5 @@ fun main() {
}
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,7 +2,7 @@ package errorPlots
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.openInBrowser
import space.kscience.plotly.palettes.Xkcd
import space.kscience.plotly.trace
import java.util.*
@@ -34,5 +34,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -1,8 +1,8 @@
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.UnstablePlotlyAPI
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.functionXY
import space.kscience.plotly.openInBrowser
import space.kscience.plotly.trace
import kotlin.math.PI
import kotlin.math.sin
@@ -31,5 +31,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -3,15 +3,14 @@ package geo
import io.invoke
import org.jetbrains.kotlinx.dataframe.DataFrame
import org.jetbrains.kotlinx.dataframe.io.readCSV
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.layout
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.geo.GeoScope
import space.kscience.plotly.models.geo.LocationMode
import space.kscience.plotly.models.geo.choropleth
import space.kscience.plotly.models.geo.geo
import space.kscience.plotly.openInBrowser
private val df = DataFrame.readCSV("https://raw.githubusercontent.com/plotly/datasets/master/2014_usa_states.csv")
@@ -27,16 +26,16 @@ fun main() {
layout {
title = "2014 US Popultaion by State"
geo{
geo {
scope = GeoScope.usa
countrycolor(255,255,255)
countrycolor(255, 255, 255)
landcolor(217, 217, 217)
showland = true
lakecolor(255, 255, 255)
showlakes = true
subunitcolor(255,255,255)
subunitcolor(255, 255, 255)
}
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -12,13 +12,13 @@ import space.kscience.plotly.models.geo.choroplethMapBox
import space.kscience.plotly.models.geo.json.GeoJsonFeatureCollection
import space.kscience.plotly.models.geo.json.combine
import space.kscience.plotly.models.geo.openStreetMap
import space.kscience.plotly.server.close
import space.kscience.plotly.server.plot
import space.kscience.plotly.server.serve
import space.kscience.plotly.plot
import space.kscience.visionforge.plotly.serveSinglePage
import space.kscience.visionforge.server.openInBrowser
import java.net.URL
import kotlin.random.Random
fun main() {
suspend fun main() {
//downloading GeoJson
val geoJsonString =
@@ -30,7 +30,7 @@ fun main() {
it.getString("NAME_1") == "Sachsen"
}.combine()
val server = Plotly.serve {
val server = Plotly.serveSinglePage {
plot {
choroplethMapBox {
geoJsonFeatures(features)
@@ -50,7 +50,7 @@ fun main() {
locations.numbers = features.map { it.id!!.int }
// Set random values to locations
z.numbers = features.map { Random.nextDouble(1.0, 10.0) }
launch {
context.launch {
while (isActive) {
delay(300)
z.numbers = features.map { Random.nextDouble(1.0, 10.0) }
@@ -62,15 +62,17 @@ fun main() {
title = "Geojson demo"
height = 800
}
embedData = true
// embedData = true
}
}
server.openInBrowser()
println("Press Enter to close server")
while (readLine()?.trim() != "exit") {
//wait
}
server.close()
server.stop()
}

View File

@@ -4,12 +4,12 @@ import kotlinx.serialization.json.int
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.layout
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.geo.LocationMode
import space.kscience.plotly.models.geo.choroplethMapBox
import space.kscience.plotly.models.geo.json.GeoJsonFeatureCollection
import space.kscience.plotly.models.geo.json.combine
import space.kscience.plotly.models.geo.openStreetMap
import space.kscience.plotly.openInBrowser
import java.net.URL
import kotlin.random.Random
@@ -57,5 +57,5 @@ fun main() {
zoom = 7.0
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -6,11 +6,11 @@ import org.jetbrains.kotlinx.dataframe.io.readCSV
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.layout
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.DragMode
import space.kscience.plotly.models.geo.mapbox
import space.kscience.plotly.models.geo.scattermapbox
import space.kscience.plotly.models.geo.useOpenStreetMap
import space.kscience.plotly.openInBrowser
private val df = DataFrame.readCSV(
"https://raw.githubusercontent.com/plotly/datasets/master/2015_06_30_precipitation.csv"
@@ -43,5 +43,5 @@ fun main() {
}
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -3,6 +3,8 @@ import space.kscience.plotly.*
import space.kscience.plotly.models.Trace
import space.kscience.plotly.models.invoke
import space.kscience.plotly.palettes.T10
import space.kscience.visionforge.html.VisionPage
import space.kscience.visionforge.html.openInBrowser
import kotlin.math.PI
import kotlin.math.cos
import kotlin.math.sin
@@ -60,15 +62,15 @@ private class PlotGrid {
}
private fun Plotly.grid(block: PlotGrid.() -> Unit): PlotlyPage {
private fun Plotly.grid(block: PlotGrid.() -> Unit): VisionPage {
val grid = PlotGrid().apply(block)
return page(cdnBootstrap, cdnPlotlyHeader) { container ->
return page(cdnBootstrap, cdnPlotlyHeader) {
div("col") {
grid.grid.forEach { row ->
div("row") {
row.forEach { cell ->
div("col-${cell.width}") {
plotly(cell.plot, cell.id, renderer = container)
staticPlot(cell.plot, plotId = cell.id)
}
}
}
@@ -125,5 +127,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -3,10 +3,10 @@ package heatmap
import space.kscience.dataforge.meta.Value
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.heatmap
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.Font
import space.kscience.plotly.models.Text
import space.kscience.plotly.models.heatmap
import space.kscience.plotly.openInBrowser
import kotlin.math.cos
import kotlin.math.pow
import kotlin.math.sin
@@ -71,5 +71,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -3,8 +3,8 @@ package heatmap
import space.kscience.dataforge.meta.Value
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.heatmap
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.heatmap
import space.kscience.plotly.openInBrowser
import space.kscience.plotly.palettes.Xkcd
@@ -15,22 +15,25 @@ import space.kscience.plotly.palettes.Xkcd
* - Change size of the plot
*/
fun main() {
val months = listOf("January", "February", "March", "April", "May", "June", "July", "August",
"September", "October", "November", "December")
val months = listOf(
"January", "February", "March", "April", "May", "June", "July", "August",
"September", "October", "November", "December"
)
val years = 1949..1961
val flights = listOf(
listOf(112, 115, 145, 171, 196, 204, 242, 284, 315, 340, 360, 417), /* January */
listOf(118, 126, 150, 180, 196, 188, 233, 277, 301, 318, 342, 391), /* February */
listOf(132, 141, 178, 193, 236, 235, 267, 317, 356, 362, 406, 419), /* March */
listOf(129, 135, 163, 181, 235, 227, 269, 313, 348, 348, 396, 461), /* April */
listOf(121, 125, 172, 183, 229, 234, 270, 318, 355, 363, 420, 472), /* May */
listOf(135, 149, 178, 218, 243, 264, 315, 374, 422, 435, 472, 535), /* June */
listOf(148, 170, 199, 230, 264, 302, 364, 413, 465, 491, 548, 622), /* July */
listOf(148, 170, 199, 242, 272, 293, 347, 405, 467, 505, 559, 606), /* August */
listOf(136, 158, 184, 209, 237, 259, 312, 355, 404, 404, 463, 508), /* September */
listOf(119, 133, 162, 191, 211, 229, 274, 306, 347, 359, 407, 461), /* October */
listOf(104, 114, 146, 172, 180, 203, 237, 271, 305, 310, 362, 390), /* November */
listOf(118, 140, 166, 194, 201, 229, 278, 306, 336, 337, 405, 432) /* December */)
listOf(112, 115, 145, 171, 196, 204, 242, 284, 315, 340, 360, 417), /* January */
listOf(118, 126, 150, 180, 196, 188, 233, 277, 301, 318, 342, 391), /* February */
listOf(132, 141, 178, 193, 236, 235, 267, 317, 356, 362, 406, 419), /* March */
listOf(129, 135, 163, 181, 235, 227, 269, 313, 348, 348, 396, 461), /* April */
listOf(121, 125, 172, 183, 229, 234, 270, 318, 355, 363, 420, 472), /* May */
listOf(135, 149, 178, 218, 243, 264, 315, 374, 422, 435, 472, 535), /* June */
listOf(148, 170, 199, 230, 264, 302, 364, 413, 465, 491, 548, 622), /* July */
listOf(148, 170, 199, 242, 272, 293, 347, 405, 467, 505, 559, 606), /* August */
listOf(136, 158, 184, 209, 237, 259, 312, 355, 404, 404, 463, 508), /* September */
listOf(119, 133, 162, 191, 211, 229, 274, 306, 347, 359, 407, 461), /* October */
listOf(104, 114, 146, 172, 180, 203, 237, 271, 305, 310, 362, 390), /* November */
listOf(118, 140, 166, 194, 201, 229, 278, 306, 336, 337, 405, 432) /* December */
)
val customColorscale = listOf(listOf(0, Xkcd.POWDER_BLUE), listOf(1, Xkcd.PURPLE))
val plot = Plotly.plot {
@@ -51,5 +54,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -3,8 +3,8 @@ package heatmap
import space.kscience.dataforge.meta.Value
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.heatmap
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.heatmap
import space.kscience.plotly.openInBrowser
/**
@@ -30,5 +30,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,8 +2,8 @@ package heatmap
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.heatmap
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.heatmap
import space.kscience.plotly.openInBrowser
/**
@@ -15,9 +15,10 @@ fun main() {
val x1 = listOf("Monday", "Tuesday", "Wednesday", "Thursday", "Friday")
val y1 = listOf("Morning", "Afternoon", "Evening")
val z1 = listOf(
listOf<Number?>(1, null, 30, 50, 1),
listOf<Number>(20, 1, 60, 80, 30),
listOf<Number>(30, 60, 1, -10, 20))
listOf<Number?>(1, null, 30, 50, 1),
listOf<Number>(20, 1, 60, 80, 30),
listOf<Number>(30, 60, 1, -10, 20)
)
val plot = Plotly.plot {
heatmap {
@@ -45,5 +46,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -1,7 +1,12 @@
package heatmap
import space.kscience.plotly.*
import space.kscience.plotly.Plotly
import space.kscience.plotly.layout
import space.kscience.plotly.models.Heatmap
import space.kscience.plotly.models.invoke
import space.kscience.plotly.page
import space.kscience.plotly.plot
import space.kscience.visionforge.html.openInBrowser
/**
@@ -14,13 +19,14 @@ fun main() {
val y2 = (0..6)
val z1 = listOf(
listOf<Number?>(null, null, null, 12, 13, 14, 15, 16),
listOf<Number?>(null, 1, null, 11, null, null, null, 17),
listOf<Number?>(null, 2, 6, 7, null, null, null, 18),
listOf<Number?>(null, 3, null, 8, null, null, null, 19),
listOf<Number?>(5, 4, 10, 9, null, null, null, 20),
listOf<Number?>(null, null, null, 27, null, null, null, 21),
listOf<Number?>(null, null, null, 26, 25, 24, 23, 22))
listOf<Number?>(null, null, null, 12, 13, 14, 15, 16),
listOf<Number?>(null, 1, null, 11, null, null, null, 17),
listOf<Number?>(null, 2, 6, 7, null, null, null, 18),
listOf<Number?>(null, 3, null, 8, null, null, null, 19),
listOf<Number?>(5, 4, 10, 9, null, null, null, 20),
listOf<Number?>(null, null, null, 27, null, null, null, 21),
listOf<Number?>(null, null, null, 26, 25, 24, 23, 22)
)
val heatmap1 = Heatmap {
x.set(x1)
@@ -37,7 +43,7 @@ fun main() {
connectgaps = true
}
Plotly.fragment {
Plotly.page {
plot {
traces(heatmap1)
layout {
@@ -55,5 +61,5 @@ fun main() {
title = "Connected Gaps"
}
}
}.makeFile()
}.openInBrowser()
}

View File

@@ -3,10 +3,10 @@ package heatmap
import space.kscience.dataforge.meta.Value
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.heatmap
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.Font
import space.kscience.plotly.models.Text
import space.kscience.plotly.models.heatmap
import space.kscience.plotly.openInBrowser
/**
* - Simple heatmap with annotations
@@ -17,10 +17,11 @@ fun main() {
val x1 = listOf("Monday", "Wednesday", "Friday", "Sunday")
val y1 = listOf("June", "July", "August")
val z1 = listOf(
listOf<Number>(.1, .3, .5, .7),
listOf<Number>(1.0, .8, .6, .4),
listOf<Number>(.6, .4, .2, 0.0),
listOf<Number>(.9, .7, .5, .3))
listOf<Number>(.1, .3, .5, .7),
listOf<Number>(1.0, .8, .6, .4),
listOf<Number>(.6, .4, .2, 0.0),
listOf<Number>(.9, .7, .5, .3)
)
val customColorscale = listOf(listOf(0, "navy"), listOf(1, "plum"))
val annotationsList = mutableListOf<Text>()
@@ -67,5 +68,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -3,10 +3,11 @@ package histogram
import space.kscience.dataforge.meta.Value
import space.kscience.plotly.Plotly
import space.kscience.plotly.layout
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.ContoursColoring
import space.kscience.plotly.models.Histogram2DContour
import space.kscience.plotly.models.MeasureMode
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
/**
@@ -47,5 +48,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,8 +2,8 @@ package histogram
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.histogram
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.histogram
import space.kscience.plotly.openInBrowser
import java.util.*
@@ -51,5 +51,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,8 +2,8 @@ package histogram
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.*
import space.kscience.plotly.openInBrowser
import java.util.*
/**
@@ -33,7 +33,7 @@ fun main() {
val trace2 = Histogram {
x.numbers = k.map { it * 10 }
y.numbers = k.map { it*2 }
y.numbers = k.map { it * 2 }
name = "experimental"
marker {
color(0, 100, 255, 0.7)
@@ -71,5 +71,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -1,9 +1,9 @@
package histogram
import space.kscience.plotly.Plotly
import space.kscience.plotly.histogram
import space.kscience.plotly.layout
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.histogram
import space.kscience.plotly.openInBrowser
import space.kscience.plotly.palettes.T10
import java.util.*
@@ -41,5 +41,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,8 +2,8 @@ package histogram
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.histogram
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.histogram
import space.kscience.plotly.openInBrowser
import space.kscience.plotly.palettes.T10
@@ -42,5 +42,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,9 +2,9 @@ package histogram
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.histogram
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.HistNorm
import space.kscience.plotly.models.histogram
import space.kscience.plotly.openInBrowser
import space.kscience.plotly.palettes.Xkcd
import kotlin.random.Random
@@ -43,5 +43,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,9 +2,10 @@ package histogram
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.BarMode
import space.kscience.plotly.models.Histogram
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
import space.kscience.plotly.palettes.T10
import java.util.*
@@ -51,5 +52,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,10 +2,10 @@ package histogram
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.histogram
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.HistFunc
import space.kscience.plotly.models.XAnchor
import space.kscience.plotly.models.histogram
import space.kscience.plotly.openInBrowser
/**
@@ -44,5 +44,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,9 +2,10 @@ package histogram
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.BarMode
import space.kscience.plotly.models.Histogram
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
import java.util.*
@@ -38,5 +39,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,9 +2,9 @@ package io
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.ScatterMode
import space.kscience.plotly.scatter
import space.kscience.plotly.models.scatter
import space.kscience.plotly.openInBrowser
fun main() {
@@ -26,5 +26,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -1,34 +1,35 @@
import space.kscience.plotly.*
import space.kscience.plotly.models.scatter
fun main() {
Plotly.page(mathJaxHeader, cdnPlotlyHeader) {
plot {
scatter {
x(2, 3, 4, 5)
y(10, 15, 13, 17)
}
Plotly.plot {
text {
position(2, 10)
font {
size = 18
}
text = "\$\\alpha\$"
}
scatter {
x(2, 3, 4, 5)
y(10, 15, 13, 17)
}
text {
position(5, 17)
font {
size = 18
}
text = "\$\\Omega\$"
text {
position(2, 10)
font {
size = 18
}
text = "\$\\alpha\$"
}
layout {
title {
text = "Plot with annotations \$\\alpha~and~\\Omega\$"
}
text {
position(5, 17)
font {
size = 18
}
text = "\$\\Omega\$"
}
layout {
title {
text = "Plot with annotations \$\\alpha~and~\\Omega\$"
}
}
}.makeFile()
}.openInBrowser(mathJaxHeader, cdnPlotlyHeader)
}

View File

@@ -25,6 +25,6 @@ fun main() {
}
}
plot.makeFile(selectFile())
plot.makeFile(Plotly.selectFile()?:error("File not selected"))
//plot.makeFile(Files.createTempFile("plotlykt",".html"))
}

View File

@@ -1,13 +1,16 @@
import kotlinx.coroutines.*
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.layout
import space.kscience.plotly.models.Bar
import space.kscience.plotly.server.*
import space.kscience.plotly.models.invoke
import space.kscience.plotly.plot
import space.kscience.visionforge.plotly.serveSinglePage
import space.kscience.visionforge.server.openInBrowser
import kotlin.random.Random
@OptIn(DelicateCoroutinesApi::class)
fun main() {
suspend fun main() {
val initialValue = (1..10).toList()
val traces = (0..2).associate { i ->
@@ -21,8 +24,7 @@ fun main() {
}
}
val server = Plotly.serve(port = 3872) {
pushUpdates(200)
val server = Plotly.serveSinglePage ( port = 3872) {
//root level plots go to default page
plot {
traces(traces.values)
@@ -34,7 +36,7 @@ fun main() {
}
}
server.show()
server.openInBrowser()
//Start pushing updates
GlobalScope.launch {
@@ -59,5 +61,5 @@ fun main() {
println("Press Enter to close server")
readLine()
server.close()
server.stop()
}

View File

@@ -2,16 +2,16 @@ package misc
import kotlinx.coroutines.*
import space.kscience.plotly.Plotly
import space.kscience.plotly.histogram
import space.kscience.plotly.Plotly.plot
import space.kscience.plotly.layout
import space.kscience.plotly.server.close
import space.kscience.plotly.server.plot
import space.kscience.plotly.server.serve
import space.kscience.plotly.models.histogram
import space.kscience.visionforge.plotly.serveSinglePage
import space.kscience.visionforge.server.openInBrowser
import kotlin.random.Random
@OptIn(DelicateCoroutinesApi::class)
fun main() {
val server = Plotly.serve {
suspend fun main() {
val server = Plotly.serveSinglePage {
val rnd = Random(222)
plot {
histogram {
@@ -53,9 +53,11 @@ fun main() {
}
}
server.openInBrowser()
println("Press Enter to close server")
readLine()
server.close()
server.stop()
}

View File

@@ -2,10 +2,10 @@ package misc
import space.kscience.plotly.Plotly
import space.kscience.plotly.layout
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.ImageXAnchor
import space.kscience.plotly.models.ImageYAnchor
import space.kscience.plotly.scatter
import space.kscience.plotly.models.scatter
import space.kscience.plotly.openInBrowser
fun main() {
Plotly.plot {
@@ -35,5 +35,5 @@ fun main() {
yanchor = ImageYAnchor.bottom
}
}
}.makeFile()
}.openInBrowser()
}

View File

@@ -2,9 +2,9 @@ package misc
import space.kscience.plotly.Plotly
import space.kscience.plotly.layout
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.AxisSide
import space.kscience.plotly.scatter
import space.kscience.plotly.models.scatter
import space.kscience.plotly.openInBrowser
fun main() {
@@ -42,5 +42,5 @@ fun main() {
side = AxisSide.right
}
}
}.makeFile()
}.openInBrowser()
}

View File

@@ -1,8 +1,8 @@
package misc
import space.kscience.plotly.Plotly
import space.kscience.plotly.bar
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.bar
import space.kscience.plotly.openInBrowser
fun main() {
val plot = Plotly.plot {
@@ -11,5 +11,5 @@ fun main() {
y(20)
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,8 +2,9 @@ package pie
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.Pie
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
/**
* - basic pie chart
@@ -26,5 +27,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -1,10 +1,12 @@
package pie
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.fragment
import space.kscience.plotly.makeFile
import space.kscience.plotly.layout
import space.kscience.plotly.models.Pie
import space.kscience.plotly.models.invoke
import space.kscience.plotly.page
import space.kscience.plotly.plot
import space.kscience.visionforge.html.openInBrowser
fun main() {
@@ -20,7 +22,7 @@ fun main() {
hole = 0.4
}
Plotly.fragment {
Plotly.page {
plot {
traces(donut1)
@@ -40,5 +42,5 @@ fun main() {
title = "CO2"
}
}
}.makeFile()
}.openInBrowser()
}

View File

@@ -3,9 +3,10 @@ package pie
import space.kscience.dataforge.meta.Value
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.Pie
import space.kscience.plotly.models.TextInfo
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
/**
@@ -16,15 +17,17 @@ import space.kscience.plotly.models.TextInfo
fun main() {
val allLabels = listOf("1st", "2nd", "3rd", "4th", "5th")
val allValues = listOf(
listOf<Number>(38, 27, 18, 10, 7),
listOf<Number>(28, 26, 21, 15, 10),
listOf<Number>(38, 19, 16, 14, 13),
listOf<Number>(31, 24, 19, 18, 8))
listOf<Number>(38, 27, 18, 10, 7),
listOf<Number>(28, 26, 21, 15, 10),
listOf<Number>(38, 19, 16, 14, 13),
listOf<Number>(31, 24, 19, 18, 8)
)
val ultimateColors = listOf(
listOf("rgb(56, 75, 126)", "rgb(18, 36, 37)", "rgb(34, 53, 101)", "rgb(36, 55, 57)", "rgb(6, 4, 4)"),
listOf("rgb(177, 127, 38)", "rgb(205, 152, 36)", "rgb(99, 79, 37)", "rgb(129, 180, 179)", "rgb(124, 103, 37)"),
listOf("rgb(33, 75, 99)", "rgb(79, 129, 102)", "rgb(151, 179, 100)", "rgb(175, 49, 35)", "rgb(36, 73, 147)"),
listOf("rgb(146, 123, 21)", "rgb(177, 180, 34)", "rgb(206, 206, 40)", "rgb(175, 51, 21)", "rgb(35, 36, 21)"))
listOf("rgb(56, 75, 126)", "rgb(18, 36, 37)", "rgb(34, 53, 101)", "rgb(36, 55, 57)", "rgb(6, 4, 4)"),
listOf("rgb(177, 127, 38)", "rgb(205, 152, 36)", "rgb(99, 79, 37)", "rgb(129, 180, 179)", "rgb(124, 103, 37)"),
listOf("rgb(33, 75, 99)", "rgb(79, 129, 102)", "rgb(151, 179, 100)", "rgb(175, 49, 35)", "rgb(36, 73, 147)"),
listOf("rgb(146, 123, 21)", "rgb(177, 180, 34)", "rgb(206, 206, 40)", "rgb(175, 51, 21)", "rgb(35, 36, 21)")
)
val pie1 = Pie {
values = allValues[0].map { Value.of(it) }
@@ -85,5 +88,5 @@ fun main() {
showlegend = false
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -3,8 +3,9 @@ package pie
import space.kscience.dataforge.meta.Value
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.Pie
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
import space.kscience.plotly.palettes.Xkcd
@@ -74,5 +75,5 @@ fun main() {
}
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,9 +2,9 @@ package pie
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.TextInfo
import space.kscience.plotly.pie
import space.kscience.plotly.models.pie
import space.kscience.plotly.openInBrowser
fun main() {
val labels = listOf("Cookies", "Jellybean", "Milkshake", "Cheesecake")
@@ -29,5 +29,5 @@ fun main() {
}
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,10 +2,10 @@ package pie
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.TextInfo
import space.kscience.plotly.models.TextPosition
import space.kscience.plotly.pie
import space.kscience.plotly.models.pie
import space.kscience.plotly.openInBrowser
/**
@@ -38,5 +38,5 @@ fun main() {
title = "Pull Sector Pie Chart"
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -1,8 +1,8 @@
package plots3d
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.TraceType
import space.kscience.plotly.openInBrowser
import space.kscience.plotly.trace
@@ -15,5 +15,5 @@ fun main() {
z(1,2,3)
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,8 +2,8 @@ package plots3d
import space.kscience.dataforge.meta.asValue
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.TraceType
import space.kscience.plotly.openInBrowser
import space.kscience.plotly.trace
private fun l(vararg numbers: Number) = numbers.map { it.asValue() }.asValue()
@@ -31,5 +31,5 @@ fun main() {
type = TraceType.surface
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -3,8 +3,8 @@ package scatter
import space.kscience.dataforge.meta.Value
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.*
import space.kscience.plotly.openInBrowser
/**
@@ -86,5 +86,5 @@ fun main() {
hovermode = HoverMode.closest
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,10 +2,10 @@ package scatter
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.ScatterMode
import space.kscience.plotly.models.TextPosition
import space.kscience.plotly.scatter
import space.kscience.plotly.models.scatter
import space.kscience.plotly.openInBrowser
/**
@@ -57,5 +57,5 @@ fun main() {
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,11 +2,8 @@ package scatter
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.LineShape
import space.kscience.plotly.models.Scatter
import space.kscience.plotly.models.ScatterMode
import space.kscience.plotly.models.TraceOrder
import space.kscience.plotly.models.*
import space.kscience.plotly.openInBrowser
/**
@@ -87,5 +84,5 @@ fun main() {
}
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -3,8 +3,8 @@ package scatter
import space.kscience.dataforge.meta.Value
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.*
import space.kscience.plotly.openInBrowser
/**
@@ -158,5 +158,5 @@ fun main() {
annotations = annotationsList
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,9 +2,9 @@ package scatter
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.ScatterMode
import space.kscience.plotly.scatter
import space.kscience.plotly.models.scatter
import space.kscience.plotly.openInBrowser
/**
@@ -34,5 +34,5 @@ fun main() {
title = "Line and Scatter Plot"
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -2,9 +2,10 @@ package scatter
import space.kscience.plotly.Plotly
import space.kscience.plotly.layout
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.AxisType
import space.kscience.plotly.models.Scatter
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
/**
@@ -36,5 +37,5 @@ fun main() {
}
}
}
plot.makeFile()
plot.openInBrowser()
}

View File

@@ -3,14 +3,15 @@ package scatter
import space.kscience.dataforge.meta.Value
import space.kscience.dataforge.meta.invoke
import space.kscience.plotly.Plotly
import space.kscience.plotly.makeFile
import space.kscience.plotly.models.Scatter
import space.kscience.plotly.models.ScatterMode
import space.kscience.plotly.models.invoke
import space.kscience.plotly.openInBrowser
/**
* - Scatter plot only with markers
* - Use numbers as color list
* - Use numbers as a color list
*/
fun main() {
val scatter = Scatter {
@@ -29,5 +30,5 @@ fun main() {
title = "Scatter plot with color dimension"
}
}
plot.makeFile()
plot.openInBrowser()
}

Some files were not shown because too many files have changed in this diff Show More