Data2viz
.play
Explore
Sketches
Create
Sketch
Documentation
Let's start
Core mechanisms
Colors and gradients
Scales
Chromatic Scales
Forces
Random numbers
Fork
View
Editor
Details
Sign up
Log in
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) } }
Sketch created by
pierre
2792
0
0
Charts.kt
Description
Basic scatter plot in Charts-kt displaying random points.
comments
Submit
Lovers
comments