org.jetbrains.kotlinx.kandy.dsl.plotCreation.kt Maven / Gradle / Ivy
/*
* Copyright 2020-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package org.jetbrains.kotlinx.kandy.dsl
import org.jetbrains.kotlinx.dataframe.DataFrame
import org.jetbrains.kotlinx.dataframe.api.GroupBy
import org.jetbrains.kotlinx.dataframe.api.toDataFrame
import org.jetbrains.kotlinx.kandy.dsl.internal.dataframe.DataFramePlotBuilder
import org.jetbrains.kotlinx.kandy.dsl.internal.dataframe.GroupByPlotBuilder
import org.jetbrains.kotlinx.kandy.ir.Plot
/**
* Returns a new [Plot].
*
* Creates a [DataFramePlotBuilder] plotting context, in which you can configure a plot.
* Possible configuration parameters depend on the engine.
*
* @param dataset plot dataset.
*/
public inline fun plot(dataset: Map> = mapOf(), block: DataFramePlotBuilder<*>.() -> Unit): Plot {
return plot(dataset.toDataFrame(), block)
}
/**
* Returns a new [Plot].
*
* Creates a [DataFramePlotBuilder] plotting context, in which you can configure a plot.
* Possible configuration parameters depend on the engine.
*
* @receiver plot dataset.
*/
@JvmName("mapPlot")
public inline fun Map>.plot(block: DataFramePlotBuilder<*>.() -> Unit): Plot {
return plot(this, block)
}
/**
* Returns a new [Plot].
*
* Creates a [DataFramePlotBuilder] plotting context, in which you can configure a plot.
* Possible configuration parameters depend on the engine.
*
* @receiver plot dataset.
*/
public inline fun DataFrame.plot(block: DataFramePlotBuilder.() -> Unit): Plot {
return plot(this, block)
}
/**
* Returns a new [Plot].
*
* Creates a [DataFramePlotBuilder] plotting context, in which you can configure a plot.
* Possible configuration parameters depend on the engine.
*
* @param dataframe plot dataset.
*/
@JvmName("plotDataframe")
public inline fun plot(dataframe: DataFrame, block: DataFramePlotBuilder.() -> Unit): Plot {
return DataFramePlotBuilder(dataframe).apply(block).toPlot()
}
/**
* Returns a new [Plot].
*
* Creates a [GroupByPlotBuilder] plotting context, in which you can configure a plot.
* Possible configuration parameters depend on the engine.
*
* @receiver plot dataset.
*/
public inline fun GroupBy.plot(block: GroupByPlotBuilder.() -> Unit): Plot {
return GroupByPlotBuilder(this).apply(block).toPlot()
}
/**
* Returns a new [Plot].
*
* Creates a [GroupByPlotBuilder] plotting context, in which you can configure a plot.
* Possible configuration parameters depend on the engine.
*
* @param groupedDataframe plot dataset.
*/
@JvmName("plotGroupBy")
public inline fun plot(groupedDataframe: GroupBy, block: GroupByPlotBuilder.() -> Unit): Plot {
return GroupByPlotBuilder(groupedDataframe).apply(block).toPlot()
}