fix for Plotly vision serialization

This commit is contained in:
Alexander Nozik 2021-08-14 15:54:16 +03:00
parent 60cec91ab8
commit a33d9d1946
4 changed files with 12 additions and 5 deletions

View File

@ -11,6 +11,7 @@ import space.kscience.dataforge.names.NameToken
import space.kscience.dataforge.names.asName
import space.kscience.visionforge.Vision
import space.kscience.visionforge.VisionManager
import space.kscience.visionforge.root
import kotlin.collections.set
@DslMarker
@ -84,6 +85,7 @@ public abstract class VisionTagConsumer<R>(
): T {
val output = VisionOutput(manager)
val vision = output.visionProvider()
vision.root(manager)
return vision(name, vision, output.meta)
}

View File

@ -5,6 +5,7 @@ import kotlinx.serialization.Serializable
import kotlinx.serialization.modules.SerializersModule
import kotlinx.serialization.modules.polymorphic
import kotlinx.serialization.modules.subclass
import space.kscience.dataforge.meta.MutableMeta
import space.kscience.dataforge.meta.string
import space.kscience.dataforge.names.Name
import space.kscience.dataforge.names.asName
@ -18,6 +19,9 @@ public class VisionOfMarkup(
public val format: String = COMMONMARK_FORMAT
) : VisionBase() {
//FIXME to be removed after https://github.com/Kotlin/kotlinx.serialization/issues/1602 fix
override var properties: MutableMeta? = null
//TODO add templates
public var content: String?

View File

@ -2,16 +2,19 @@ package space.kscience.visionforge.plotly
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import space.kscience.dataforge.meta.MutableMeta
import space.kscience.dataforge.misc.DFExperimental
import space.kscience.plotly.Plot
import space.kscience.plotly.Plotly
import space.kscience.visionforge.VisionBase
import space.kscience.visionforge.html.VisionOutput
import space.kscience.visionforge.root
@Serializable
@SerialName("vision.plotly")
public class VisionOfPlotly private constructor() : VisionBase() {
//FIXME to be removed after https://github.com/Kotlin/kotlinx.serialization/issues/1602 fix
override var properties: MutableMeta? = null
public constructor(plot: Plot) : this() {
properties = plot.meta
}
@ -23,6 +26,4 @@ public fun Plot.asVision(): VisionOfPlotly = VisionOfPlotly(this)
@DFExperimental
public inline fun VisionOutput.plotly(
block: Plot.() -> Unit,
): VisionOfPlotly = VisionOfPlotly(Plotly.plot(block)).apply {
root(this@plotly.manager)
}
): VisionOfPlotly = VisionOfPlotly(Plotly.plot(block))

View File

@ -69,4 +69,4 @@ public class Solids(meta: Meta) : VisionPlugin(meta) {
@VisionBuilder
@DFExperimental
public inline fun VisionOutput.solid(block: SolidGroup.() -> Unit): SolidGroup =
SolidGroup().apply(block).apply { root(this@solid.manager) }
SolidGroup().apply(block)