For the complete documentation index, see llms.txt. This page is also available as Markdown.

Creating More Advanced Charts

Source code is located at the end of this tutorial.

This tutorial introduces you to Symbol Type marks by creating a heatmap visualization. The heatmap shows contribution level to the Republican party within the continental United States:

The contribution data are obtained using the following SQL query:

The visualization uses a Symbol Type marks type to represent each data item in the heatmap_query data table:

The marks properties property specifies the symbol shape, which is a square. Each square has a pixel width and height of one pixel.

Notice that the data x and y location values do not reference a scale. The location values are the values of the SQL query, transformed using extension functions.

The fill color of the square uses the heat_color scale to determine the color used to represent the data item.

Quantize scales are similar to linear scales, except they use a discrete rather than continuous range. The continuous input domain is divided into uniform segments based on the number of values in the output range.

A heatmap shows a continuous input domain divided into uniform segments based on the number of values in the output range. This is a quantize scales type. In the example, dollar amounts between $10,000 and $1 million are uniformly divided among 21 range values, where the larger amounts are represented by brighter colors.

Values outside the domain and null values are rendered as dark blue, #0d0887.

Source Code

Advanced Chart Type Tutorial Directory Structure

HTML

Advanced Chart Type Tutorial index.html

JavaScript

Advanced Chart Type Tutorial vegademo.js

Advanced Chart Type Tutorial vegaspec.js

Last updated

Was this helpful?