Skip to main content
100%

Untitled

✓ Published0🌍 Public
Mmkt-ds
Last edited Oct 30, 2019
Created on Sep 19, 2019

This example demonstrates how to create a continuous color legend using D3’s `d3.scaleSequential` with the interpolator `d3.interpolateViridis`. The legend is rendered as a vertical gradient bar on a Canvas element, where each pixel’s color is drawn with the Canvas 2D API. An SVG overlay adds a `d3.axisRight` for numeric tick labels, with the color scale domain set from 0 to 7. The code uses D3 v5 with the d3-scale-chromatic module for interpolators.

AI-generated description

Happiness by Country

https://gist.githubusercontent.com/mkt-ds/640984c80835e2823c1b0f5c9a3fabe6/raw/51de6483339b81fbe70cd02bdf8fecddddbc4eea/happiness_byCountry.csv

This data contains 110 countries which some attributes to help us measure happiness under some conditions.

Using the data I'm trying to see the effect of certain factors on the happiness of some people in different countries.

Attributes:

D = decision attribute (D) with values 0 (unhappy) and 1 (happy) X1 = the availability of information about the city services X2 = the cost of housing X3 = the overall quality of public schools X4 = your trust in the local police X5 = the maintenance of streets and sidewalks X6 = the availability of social community events

Attributes X1 to X6 have values 1 to 5.

MIT Licensed

Similar vizzes