Skip to content

Commit

Permalink
Fix loss of colobar options.
Browse files Browse the repository at this point in the history
  • Loading branch information
OLarionova-HORIS committed Apr 10, 2024
1 parent 3daf22b commit fd76882
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,14 @@ import org.jetbrains.letsPlot.core.plot.builder.layout.PlotLabelSpecFactory
import org.jetbrains.letsPlot.core.plot.builder.layout.PlotLayoutUtil
import kotlin.math.max

class ColorBarAssembler(
class ColorBarAssembler constructor(
private val legendTitle: String,
private val transformedDomain: DoubleSpan,
private val scale: Scale,
private val scaleMapper: ScaleMapper<Color>,
private val theme: LegendTheme
private val theme: LegendTheme,
private var colorBarOptions: ColorBarOptions?
) {

private var colorBarOptions: ColorBarOptions? = null

fun createColorBar(): LegendBoxInfo {
var scale = scale
if (!scale.hasBreaks()) {
Expand Down Expand Up @@ -64,9 +62,6 @@ class ColorBarAssembler(
}
}

internal fun setOptions(options: ColorBarOptions?) {
colorBarOptions = options
}

fun equalScalesAndOptions(other: ColorBarAssembler): Boolean {
if (transformedDomain != other.transformedDomain) return false
Expand All @@ -82,7 +77,7 @@ class ColorBarAssembler(
fun withTitle(title: String): ColorBarAssembler {
return ColorBarAssembler(
title,
transformedDomain, scale, scaleMapper, theme
transformedDomain, scale, scaleMapper, theme, colorBarOptions
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,14 @@ internal object PlotGuidesAssemblerUtil {
scaleMapper: ScaleMapper<Color>,
options: ColorBarOptions?,
theme: LegendTheme
): ColorBarAssembler {

val result = ColorBarAssembler(
scaleName,
transformedDomain,
scale,
scaleMapper,
theme
)
result.setOptions(options)
return result
}
) = ColorBarAssembler(
scaleName,
transformedDomain,
scale,
scaleMapper,
theme,
options
)

fun fitsColorBar(aes: Aes<*>, scale: Scale): Boolean {
return aes.isColor && scale.isContinuous
Expand Down

0 comments on commit fd76882

Please sign in to comment.