Several Lines
val months = listOf(1, 2, 3, 4, 5)
val salesProducts = listOf(200.0, 220.0, 180.0, 240.0, 210.0)
val salesClothes = listOf(150.0, 130.0, 160.0, 140.0, 170.0)
val salesElectronics = listOf(300.0, 320.0, 310.0, 330.0, 340.0)
val dataset = dataFrameOf(
"month" to months + months + months,
"sales" to salesProducts + salesClothes + salesElectronics,
"category" to List(5) { "Products" } + List(5) { "Clothes" } + List(5) { "Electronics" }
)
dataset.groupBy("category").plot {
line {
x("month")
y("sales")
color("category")
}
}
val months = listOf(1, 2, 3, 4, 5)
val salesProducts = listOf(200.0, 220.0, 180.0, 240.0, 210.0)
val salesClothes = listOf(150.0, 130.0, 160.0, 140.0, 170.0)
val salesElectronics = listOf(300.0, 320.0, 310.0, 330.0, 340.0)
val dataset = mapOf(
"month" to months + months + months,
"sales" to salesProducts + salesClothes + salesElectronics,
"category" to List(5) { "Products" } + List(5) { "Clothes" } + List(5) { "Electronics" }
)
dataset.plot {
groupBy("category") {
line {
x("month")
y("sales")
color("category")
}
}
}
Last modified: 06 December 2023