Intervals in JavaScript and R

The R-package ClassInt can be used to choose univariate class intervals and assign colours for them. To use the same intervals and colours for the a map the R and the JavaScript code is shown below:

JavaScript

// get color depending on value
	function getColor(d) {
		return 	d > 110 ? "#CD3333" : 	
			d > 100 ? "#FFB6C1" :
			d > 99	? "#98FB98" :
			d > 90  ? "#ADD8E6" :
			d > 80  ? "#0000FF" :
			d > 30  ? "#00008B" :
				  "#FFFFFF";

// in the function legend.onAdd
grades = ['no data', 30, 80, 90, 99, 100, 110],

R

# 6 classes with fixed given breaks
nclass=classIntervals(dat[,2], n=6, style="fixed", fixedBreaks=c(30, 80, 90, 99, 100, 110, 120), intervalClosure='right')

# Color for each class
colcode = findColours(nclass, c('darkblue', 'blue', 'lightblue', 'palegreen', 'lightpink', 'brown3'))

See also:
How to use R package ‘classInt’ to choose univariate class intervals
How to make an interactive choropleth map using R, GeoJSON and Leaflet