Basic Scatter Plot

import io.data2viz.charts.* import io.data2viz.charts.core.CursorType import io.data2viz.charts.dimension.* import io.data2viz.charts.chart.* import io.data2viz.charts.chart.mark.* import io.data2viz.charts.viz.* import io.data2viz.charts.layout.* import io.data2viz.geom.* import kotlin.random.Random val width = 700.0 val height = 500.0 val randomPoints = (1 .. 1000).map{ Point(Random.nextDouble(), Random.nextDouble()) } fun main() { // Creating and sizing the VizContainer val vc = newVizContainer().apply { size = Size(width, height) } // Chart DSL, our domain object is a "Point" vc.chart(randomPoints) { config { // Display the cursor cursor { show = true } } // Create 2 continuous numeric dimensions val xPosition = quantitative( { domain.x } ) val yPosition = quantitative( { domain.y } ) // Plot values plot(xPosition, yPosition) } }
pierre avatar

Sketch created by

pierre

Basic scatter plot in Charts-kt displaying random points.

comments