All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.jetbrains.datalore.plot.base.scale.Scales.kt Maven / Gradle / Ivy

There is a newer version: 4.5.3-alpha1
Show newest version
/*
 * Copyright (c) 2019. JetBrains s.r.o.
 * Use of this source code is governed by the MIT license that can be found in the LICENSE file.
 */

package jetbrains.datalore.plot.base.scale

import jetbrains.datalore.plot.base.Aes
import jetbrains.datalore.plot.base.Scale

object Scales {
    fun  continuousDomain(
        name: String,
        aes: Aes
    ): Scale {
        return ContinuousScale(
            name,
            Mappers.undefined(),
            aes.isNumeric
        )
    }

    fun continuousDomainNumericRange(
        name: String
    ): Scale {
        return ContinuousScale(
            name,
            Mappers.undefined(),
            true
        )
    }

    fun  continuousDomain(
        name: String,
        mapper: (Double?) -> T?,
        continuousRange: Boolean
    ): Scale {
        return ContinuousScale(name, mapper, continuousRange)
    }

    fun  discreteDomain(name: String, domainValues: Collection): Scale {
        return discreteDomain(
            name,
            domainValues,
            Mappers.undefined()
        )
    }

    fun  discreteDomain(name: String, domainValues: Collection, mapper: ((Double?) -> T?)): Scale {
        return DiscreteScale(name, domainValues, mapper)
    }

    fun  pureDiscrete(
        name: String,
        domainValues: List,
        outputValues: List,
        defaultOutputValue: T
    ): Scale {
        return discreteDomain(name, domainValues)
            .with()
            .mapper(Mappers.discrete(outputValues, defaultOutputValue))
            .build()
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy