org.jetbrains.kotlinx.ggdsl.letsplot.scales.LetsPlotScaleParameters.kt Maven / Gradle / Ivy
/*
* Copyright 2020-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package org.jetbrains.kotlinx.ggdsl.letsplot.scales
import kotlinx.serialization.Serializable
import org.jetbrains.kotlinx.ggdsl.ir.bindings.BaseScaledNonPositionalMapping
import org.jetbrains.kotlinx.ggdsl.ir.bindings.BaseScaledPositionalMapping
import org.jetbrains.kotlinx.ggdsl.ir.scale.FreePositionalScale
import org.jetbrains.kotlinx.ggdsl.ir.scale.ScaleParameters
import org.jetbrains.kotlinx.ggdsl.letsplot.scales.guide.Axis
import org.jetbrains.kotlinx.ggdsl.letsplot.scales.guide.Legend
public sealed interface LetsPlotScaleParameters : ScaleParameters
@Serializable
internal data class OrderBy(
val name: String?,
val order: Int
)
@Serializable
public data class PositionalParameters(
val axis: Axis
) : LetsPlotScaleParameters {
internal var orderBy: OrderBy? = null
}
@Serializable
public data class NonPositionalParameters(val legend: Legend)
: LetsPlotScaleParameters
public inline fun BaseScaledPositionalMapping.with(
block: PositionalParameters.() -> Unit
) {
scaleParameters = PositionalParameters(Axis.create()).apply(block)
}
public inline fun FreePositionalScale.with(
block: PositionalParameters.() -> Unit
) {
scaleParameters = PositionalParameters(Axis.create()).apply(block)
}
public inline fun BaseScaledNonPositionalMapping.with(
block: NonPositionalParameters.() -> Unit
) {
scaleParameters = NonPositionalParameters(Legend.create()).apply(block)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy