fun getGeom2dLayer()

in plot-api/src/commonMain/kotlin/org/jetbrains/letsPlot/bistro/common/Plot2dUtil.kt [88:154]


    fun getGeom2dLayer(
        geomKind: String?,
        bins2d: Pair<Int, Int>?,
        binWidth2d: Pair<Number, Number>?,
        color: String?,
        size: Number?,
        alpha: Number?,
        colorBy: String?,
        showLegend: Boolean,
    ): Feature {

        return when (geomKind) {
            "point" -> {
                geomPoint(color = color, size = size, alpha = alpha, showLegend = showLegend)
            }

            "tile" -> {
                geomBin2D(
                    bins = bins2d,
                    binWidth = binWidth2d,
                    color = color,
                    size = size,
                    alpha = alpha,
                    showLegend = showLegend
                ) {
                    fill = colorBy.takeIf { it != null } ?: "..count.."
                }
            }

            "density2d" -> {
                geomDensity2D(
                    color = color,
                    size = size,
                    alpha = alpha,
                    showLegend = showLegend
                ) {
                    this.color = colorBy.takeIf { it != null } ?: "..group.."
                }
            }

            "density2df" -> {
                geomDensity2DFilled(
                    color = color,
                    size = size,
                    alpha = alpha,
                    showLegend = showLegend
                ) {
                    fill = colorBy.takeIf { it != null } ?: "..group.."
                }
            }

            "pointdensity" -> {
                geomPointDensity(
                    color = color,
                    size = size,
                    alpha = alpha,
                    showLegend = showLegend
                ) {
                    this.color = colorBy.takeIf { it != null } ?: "..density.."
                }
            }

            "none" -> DummyFeature

            else -> throw IllegalArgumentException("Unknown geom: $geomKind")
        }
    }