in plot-api/src/commonMain/kotlin/org/jetbrains/letsPlot/scale/ExpandLimits.kt [38:77]
fun expandLimits(
x: Any? = null,
y: Any? = null,
size: Any? = null,
color: Any? = null,
fill: Any? = null,
alpha: Any? = null,
shape: Any? = null
): Feature {
val standardized: Map<String, List<Any?>> = mapOf(
"x" to standardize(x),
"y" to standardize(y),
"size" to standardize(size),
"color" to standardize(color),
"fill" to standardize(fill),
"alpha" to standardize(alpha),
"shape" to standardize(shape),
)
// Drop all undefined but keep x and y even if undefined.
val cleaned = standardized.filter { (k, v) ->
k == "x" || k == "y" || v.any { it != null && if (it is Number) isFinite(it.toDouble()) else true }
}
val maxLen = cleaned.values.maxBy { it.size }.size
val data = cleaned.mapValues { (_, v) ->
v + List(maxLen - v.size) { null }
}
return geomBlank {
this.x = data.getValue("x")
this.y = data.getValue("y")
data["size"]?.let { this.size = it }
data["color"]?.let { this.color = it }
data["fill"]?.let { this.fill = it }
data["alpha"]?.let { this.alpha = it }
data["shape"]?.let { this.shape = it }
}
}