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.*
val width = 400.0
val height = 400.0
data class PopCount(val year: Int, val population: Double)
fun main() {
// Creating and sizing the VizContainer
val vc = newVizContainer().apply {
size = Size(width, height)
}
vc.chart(canPop) {
title = "Population of Canada 1851–2001"
// Create a discrete dimension for the year of the census
val year = discrete( { domain.year } )
// Create a continuous numeric dimension for the population
val population = quantitative( { domain.population } ) {
name = "Population of Canada (in millions)"
}
// Using a discrete dimension for the X-axis and a continuous one for the Y axis
bar(year, population)
}
}
val canPop = listOf(
PopCount(1851,2.436),
PopCount(1861,3.23),
PopCount(1871,3.689),
PopCount(1881,4.325),
PopCount(1891,4.833),
PopCount(1901,5.371),
PopCount(1911,7.207),
PopCount(1921,8.788),
PopCount(1931,10.377),
PopCount(1941,11.507),
PopCount(1951,13.648),
PopCount(1961,17.78),
PopCount(1971,21.046),
PopCount(1981,23.774),
PopCount(1991,26.429),
PopCount(2001,30.007)
)