"Raw" Data & Extension Methods

The idea here, is that "raw datatypes" have some unambiguous visualisation which is relatively common to want to plot. Pie charts, bar charts and the like, which are always going to look very similar to the examples on the vega website, and come from a simple datastructure. We want to be able to plot these as quickly as possible.

We achieve this through scala 3's extension methods have a look in the viz.extensions package for ideas.

Currently, extension methods are not availalbe in scala JS, so you'd have to copy paste these into a repl in order to get the idea.

import viz.PlotTargets.desktopBrowser
import viz.extensions.*

Labelled bar chart

List(("A", 4),("B", 6),("C", -1)).plotBarChart(List())

Bar chart

(1 to 5).plotBarChart()

Pie chart

(1 to 5).plotPieChart()

Pie chart with labels...

(1 to 5).map(i => (scala.util.Random.nextString(5), i)).plotPieChart(List())

Word cloud

   "how much wood would a wood chuck chuck if a wood chuck could chuck wood", 
   "a wood chuck would chuck as much wood as a wood chuck could chuck if a wood chuck could chuck wood"

Line Chart


Dot Plot


Scatter Plot

List((1.0,2.0),(3.0,4.0),(0.5 , 5.0),(3.14159, 1.0)).plotScatter()


import viz.extensions.jvm.*
List((1.0,2.0),(3.0,4.0),(0.5 , 5.0),(3.14159, 1.0)).plotRegression()