Charts: performance (WIP)
a sketch by
Pierre Mariac
Snapshot
Settings
Save
View
Editor
Details
Sign up
Log in
import io.data2viz.charts.* import io.data2viz.charts.core.* 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 io.data2viz.color.* import io.data2viz.random.RandomDistribution import io.data2viz.timeFormat.* import io.data2viz.timeFormat.TimeLocale import kotlinx.datetime.Instant import io.data2viz.math.* import io.data2viz.shape.* fun main() { // Creating and sizing the VizContainer val vc = newVizContainer().apply { size = Size(width, height) } vc.chart(samples) { config { events { zoomMode = ZoomMode.None panMode = PanMode.None highlightMode = HighlightMode.None } cursor { show = false } } val timeDim = temporal( { domain.timestamp } ) val tempDim = quantitative( { domain.temperature } ) val colorDim = discrete( { Colors.hsl((domain.temperature * 170.0 - 3).rad, 80.pct, 50.pct) as Color? } ) plot(timeDim, tempDim) { strokeColor = colorDim symbol = constant(Symbols.Square) size = constant(1.0) } } } val width = 450.0 val height = 300.0 val randomGenerator = RandomDistribution(42).bates(100.0) data class Sample( val sampleIndex: Int, val batchCode: String, val timestamp: Instant, val temperature: Double, val pressure: Double ) val samples = generateSamples(50_000) fun generateSamples(numSamples: Int) = (0 until numSamples).map { val batchIndex = 1 + (it % 4) val pressure: Double = randomGenerator() * 1000 val temp: Double = randomGenerator() * batchIndex * pressure / 100000 val ts = Instant.fromEpochMilliseconds(1611150127144L + (it * 8632L)) Sample(it, "Batch #$batchIndex", ts, temp, pressure) }
Sketch Settings
Sketch description
Displaying 50'000 styled plots.
Sketch Thumbnail
Sketch DELETE
DELETE CURRENT SKETCH