In this second tutorial, you'll see some of the basic features of Charts-kt, and build a bar chart based on your data model.

This tutorial will help you understand how to:

  1. Parse and map a CSV file to a Kotlin data class
  2. Use your own model and data in your charts
  3. Describe your values through "dimensions"
  4. Create a bar chart
  5. Understand the "Datum" concept

What do you need?

Parsing a CSV file

This CSV file contains statistical weather data for each month of 2016 and 2017, for 5 different cities. Save it in the resources repository of your project:

Weather - Stats.csv

Parsing this file is very easy using the multiplatform Dsv module of data2viz.

  1. create a Kotlin data class Weather to hold the information,
  2. load the file which is located in "./src/main/resources/",
  3. parse each row and, if needed, drop the header (the first line of the file),
  4. finally, map each row of the file in a Weather instance.