Skip to content

Instantly share code, notes, and snippets.

@tonydisera
Last active May 29, 2018 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonydisera/f54eee20d2406e1873ec71c5fbd018bd to your computer and use it in GitHub Desktop.
Save tonydisera/f54eee20d2406e1873ec71c5fbd018bd to your computer and use it in GitHub Desktop.
coursera-data-viz-assignment-1
Year Glob NHem SHem 24N-90N 24S-24N 90S-24S 64N-90N 44N-64N 24N-44N EQU-24N 24S-EQU 44S-24S 64S-44S 90S-64S
1880 -19 -33 -5 -38 -16 -5 -89 -54 -22 -26 -5 -2 -8 39
1881 -10 -18 -2 -27 -2 -5 -54 -40 -14 -5 2 -6 -3 37
1882 -9 -17 -1 -21 -10 4 -125 -20 -3 -12 -8 3 8 42
1883 -19 -30 -8 -34 -22 -2 -28 -57 -20 -25 -19 -1 0 37
1884 -27 -42 -12 -56 -17 -11 -127 -58 -41 -21 -14 -15 -5 40
1885 -31 -41 -21 -61 -17 -20 -119 -70 -43 -11 -23 -27 -7 38
1886 -30 -39 -21 -49 -24 -20 -124 -43 -38 -24 -24 -18 -21 28
1887 -33 -37 -28 -46 -27 -26 -158 -52 -21 -24 -31 -24 -29 21
1888 -20 -22 -17 -42 7 -33 -141 -43 -22 7 8 -30 -38 16
1889 -11 -16 -6 -25 4 -17 -82 -13 -21 -3 11 -16 -17 19
1890 -36 -40 -33 -44 -39 -26 -127 -41 -30 -35 -43 -16 -40 4
1891 -23 -23 -24 -33 -16 -23 -118 -17 -27 -8 -24 -20 -28 9
1892 -26 -30 -21 -29 -30 -16 -119 -30 -12 -32 -29 -4 -34 5
1893 -29 -39 -19 -37 -40 -7 -76 -35 -30 -43 -36 3 -22 2
1894 -30 -37 -23 -26 -38 -22 -121 -17 -9 -53 -23 -16 -32 -12
1895 -21 -28 -14 -34 -13 -19 -86 -38 -18 -19 -8 -21 -13 -1
1896 -14 -20 -8 -33 3 -18 -113 -34 -12 -2 8 -15 -22 3
1897 -11 -13 -9 -30 16 -28 -73 -31 -19 13 18 -21 -37 5
1898 -28 -28 -29 -28 -29 -29 -121 -2 -21 -28 -29 -27 -30 8
1899 -16 -17 -15 -18 -13 -17 -99 4 -12 -16 -10 -13 -23 13
1900 -8 -3 -13 -12 15 -34 -50 -3 -8 11 19 -31 -38 12
1901 -13 -8 -19 -10 -5 -28 -41 -1 -9 -3 -6 -29 -26 1
1902 -26 -29 -23 -47 -5 -33 -145 -40 -26 -3 -8 -27 -42 6
1903 -35 -35 -35 -39 -32 -33 -37 -30 -46 -27 -37 -37 -25 -43
1904 -44 -45 -42 -46 -46 -38 -23 -53 -47 -45 -48 -36 -38 -108
1905 -27 -28 -26 -37 -13 -36 -12 -16 -57 -15 -11 -37 -34 -20
1906 -21 -20 -23 -19 -22 -24 -29 4 -32 -22 -21 -23 -22 -49
1907 -39 -46 -31 -56 -34 -28 -68 -69 -44 -33 -36 -25 -31 -101
1908 -42 -45 -39 -46 -47 -33 -39 -50 -45 -45 -49 -31 -38 82
1909 -47 -48 -46 -47 -53 -40 -72 -49 -40 -50 -55 -38 -41 -32
1910 -42 -43 -41 -36 -54 -32 -62 -13 -44 -54 -54 -32 -32 43
1911 -44 -41 -47 -37 -47 -47 -24 -36 -43 -47 -47 -43 -53 31
1912 -35 -47 -22 -57 -22 -30 -60 -70 -48 -33 -11 -37 -13 -137
1913 -33 -42 -25 -40 -31 -31 -51 -27 -46 -45 -16 -29 -31 -75
1914 -15 -18 -13 -22 -7 -19 -50 -6 -25 -12 -2 -17 -23 -16
1915 -10 -9 -11 -16 1 -18 -50 -6 -13 2 -1 -10 -23 -182
1916 -33 -35 -30 -27 -45 -22 -25 -43 -19 -47 -42 -22 -17 -104
1917 -39 -52 -26 -40 -61 -9 -64 -39 -36 -70 -51 -17 4 37
1918 -24 -32 -17 -32 -27 -14 -108 -13 -23 -32 -22 -8 -23 4
1919 -21 -32 -10 -39 -14 -13 -80 -44 -25 -23 -5 -7 -22 44
1920 -25 -26 -24 -16 -27 -30 13 -8 -29 -40 -14 -20 -44 -69
1921 -19 -8 -31 7 -27 -35 5 24 -4 -30 -25 -25 -49 -52
1922 -26 -25 -27 -18 -32 -25 -22 -31 -8 -35 -29 -23 -27 -5
1923 -22 -18 -27 -7 -30 -28 29 -3 -21 -33 -27 -26 -28 -34
1924 -26 -15 -38 -7 -25 -47 38 -15 -16 -26 -24 -38 -60 -49
1925 -19 -7 -30 3 -22 -36 -4 27 -11 -22 -22 -24 -55 -59
1926 -8 4 -21 6 3 -38 52 25 -18 1 5 -32 -46 -39
1927 -20 -10 -29 -9 -14 -37 -4 -12 -9 -12 -17 -31 -41 -130
1928 -20 -7 -33 -3 -14 -46 59 -7 -18 -14 -14 -32 -62 -205
1929 -35 -30 -40 -33 -27 -48 1 -50 -33 -26 -29 -41 -57 -97
1930 -13 2 -29 10 -12 -38 48 16 -5 -9 -15 -31 -42 -237
1931 -9 5 -23 5 3 -38 48 8 -10 6 0 -42 -31 -26
1932 -16 -3 -30 7 -17 -38 25 31 -15 -17 -18 -25 -57 -81
1933 -28 -24 -31 -21 -29 -33 -29 -38 -8 -29 -29 -22 -46 -94
1934 -13 1 -27 21 -27 -28 74 40 -8 -28 -26 -23 -34 -31
1935 -19 -8 -29 0 -22 -33 22 7 -11 -20 -24 -29 -34 -139
1936 -14 -3 -26 -1 -14 -27 24 18 -21 -6 -23 -27 -28 26
1937 -1 13 -16 21 -6 -18 108 8 2 2 -14 -21 -14 74
1938 -2 14 -18 37 -26 -10 123 44 6 -21 -31 -9 -8 -72
1939 -3 7 -13 24 -17 -9 51 33 10 -17 -18 -5 -10 -155
1940 8 14 3 10 19 -7 88 3 -10 19 18 1 -21 16
1941 13 16 10 -3 39 -6 -21 -11 7 44 34 2 -18 -26
1942 10 14 6 14 15 1 36 0 15 15 14 8 -5 -69
1943 14 21 7 38 0 9 118 33 16 -4 5 13 1 136
1944 26 28 24 39 22 18 103 50 14 11 32 32 -1 -49
1945 13 9 16 10 22 3 45 -1 6 9 35 14 -4 -143
1946 -3 7 -12 8 -1 -16 -15 2 20 5 -7 -18 -16 41
1947 -3 5 -12 14 -9 -13 100 -15 6 -9 -9 -16 -11 28
1948 -9 0 -18 14 -18 -20 8 36 2 -22 -14 -19 -16 -83
1949 -9 -2 -16 12 -18 -19 22 17 7 -22 -13 -15 -13 -152
1950 -18 -16 -19 -8 -27 -14 4 -34 4 -28 -26 -5 -21 -68
1951 -7 5 -18 7 -6 -22 1 3 12 1 -13 -20 -21 -48
1952 1 5 -3 9 2 -7 10 -7 18 0 3 -9 0 -21
1953 8 22 -6 33 5 -14 81 37 15 6 5 -10 -12 -93
1954 -12 -4 -20 3 -21 -14 58 -20 -1 -14 -28 -16 -4 -69
1955 -14 -9 -19 2 -32 -7 -43 -7 23 -27 -38 -16 -19 130
1956 -20 -25 -14 -24 -32 1 -21 -47 -10 -27 -37 -11 0 59
1957 3 4 3 2 7 -1 3 22 -11 6 8 -8 -9 39
1958 6 16 -5 10 20 -17 -15 18 12 26 14 -9 -7 -68
1959 3 11 -4 15 6 -13 50 17 2 5 8 -4 -15 -36
1960 -3 8 -13 9 1 -20 35 -6 10 5 -3 -10 -4 -86
1961 5 8 3 18 -3 4 -18 37 17 -7 1 11 -11 12
1962 3 14 -9 27 -4 -13 58 34 14 -4 -5 6 -9 -85
1963 6 15 -3 16 11 -12 -5 32 13 13 9 -11 -20 5
1964 -20 -20 -21 -24 -14 -26 -67 -22 -11 -14 -13 -30 -9 -44
1965 -10 -13 -7 -17 -3 -12 -20 -24 -11 -7 1 -21 0 -6
1966 -5 0 -10 -12 8 -16 -67 -16 8 17 -1 -24 -17 15
1967 -2 3 -8 13 -14 -2 43 26 -6 -11 -16 -7 -7 27
1968 -7 -5 -9 -8 -6 -8 -17 -2 -8 -1 -10 -12 2 -14
1969 6 -2 14 -26 32 4 5 -59 -15 35 29 2 13 -4
1970 3 -3 9 -10 6 11 -17 -14 -6 6 6 9 0 41
1971 -9 -15 -3 -6 -26 9 -6 0 -10 -30 -22 4 11 25
1972 1 -18 20 -35 16 16 -45 -49 -22 6 26 14 2 55
1973 15 10 20 12 17 14 20 26 2 6 28 20 -1 29
1974 -8 -19 4 -17 -19 17 -29 -11 -18 -23 -16 21 -6 58
1975 -1 -5 2 12 -22 12 22 35 -6 -29 -14 13 4 28
1976 -11 -21 -2 -26 -11 2 -4 -33 -28 -14 -7 9 10 -36
1977 18 12 24 14 16 25 24 22 7 10 23 23 37 13
1978 7 2 12 -3 9 15 -8 0 -3 10 7 20 16 -5
1979 17 8 26 -3 25 25 -59 6 9 24 27 32 38 -24
1980 28 16 39 6 30 46 32 1 2 31 28 35 37 104
1981 33 39 27 50 19 35 129 77 9 22 16 29 37 54
1982 13 6 21 -6 27 14 -27 7 -8 24 30 18 30 -27
1983 31 26 35 24 44 20 32 67 -6 30 58 20 29 4
1984 16 5 27 3 19 25 39 7 -12 8 30 16 24 58
1985 12 0 25 -3 11 29 41 -27 -1 4 18 29 38 14
1986 19 14 25 11 24 21 7 24 4 18 30 26 26 -3
1987 34 27 41 7 60 27 -26 13 14 56 63 33 21 18
1988 40 37 43 40 38 42 75 49 23 32 45 39 18 105
1989 29 29 29 42 16 33 40 67 27 10 22 37 25 34
1990 44 51 36 61 38 35 60 83 48 36 39 38 32 28
1991 42 41 44 46 39 43 74 59 28 34 44 33 34 99
1992 23 12 33 7 30 28 -19 37 -2 20 41 21 33 42
1993 24 20 29 13 34 23 63 23 -8 29 38 26 35 -13
1994 32 36 27 43 32 21 36 46 43 27 37 27 25 -11
1995 46 58 34 70 44 23 140 95 33 40 49 32 16 8
1996 35 28 42 26 34 45 79 19 13 31 37 35 31 111
1997 48 53 42 54 53 34 78 87 26 52 54 43 38 -4
1998 63 73 54 79 72 36 91 92 68 63 81 43 32 21
1999 42 52 32 73 26 32 47 82 77 19 32 50 16 3
2000 42 51 33 71 28 33 110 75 56 22 33 47 10 34
2001 55 64 46 80 45 44 104 81 71 41 48 58 20 49
2002 63 71 56 81 61 48 126 96 58 55 67 49 29 87
2003 62 72 52 80 64 41 143 94 52 59 68 47 23 59
2004 55 67 42 75 57 32 64 92 68 56 58 50 21 -6
2005 69 84 55 99 65 45 200 116 56 61 69 52 20 76
2006 64 80 47 96 56 40 173 105 67 55 58 54 19 36
2007 66 83 49 110 47 48 201 129 69 44 50 54 6 117
2008 54 66 42 88 39 40 144 102 61 33 45 56 10 50
2009 65 71 59 74 68 51 127 58 67 66 71 61 18 85
2010 71 88 55 98 69 48 199 86 74 72 66 66 23 38
2011 60 71 50 93 37 58 211 90 57 38 37 68 26 93
2012 63 77 50 97 51 44 189 89 73 46 57 60 25 32
2013 66 76 56 88 58 54 123 103 68 57 58 64 30 67
2014 75 91 58 106 67 54 185 113 76 70 64 76 23 47
<html>
<head>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src="legend.js"></script>
<style>
body {
font-family: Helvetica;
color: #888888;
fill: #888888;
}
path.mouse-line {
stroke-width: 1.5px !important;
fill: none !important;
stroke: #888888 !important;
}
.title text {
font-size: 20px;
}
.line {
stroke-width: 1.5px;
fill: none;
}
.line#Glob {
stroke: #679d07;
}
.line#NHem {
stroke: #4040b5;
}
.line#SHem {
stroke: #eb6f0e;
}
.axis path, .axis line {
stroke: #888888;
fill: none;
stroke-width: 2px;
}
.axis text {
font-size: 12px;
}
.legend text {
font-size: 14px;
}
</style>
</head>
<body>
<svg width="960" height="600"></svg>
</body>
<script>
var svg = d3.select("svg");
var width = 960;
var height = 600;
var margin = { top: 40, left: 60, right: 220, bottom: 50};
var innerHeight = height - margin.top - margin.bottom;
var innerWidth = width - margin.left - margin.right;
var temps = {
Glob: function(d) {
return +d.Glob
},
NHem: function(d) {
return +d.NHem;
},
SHem: function(d) {
return +d.SHem;
}
}
var labels = {
Glob: 'Global',
NHem: 'Northern Hemisphere',
SHem: 'Southern Hemisphere'
}
var colors = ['#679d07', '#4040b5', '#eb6f0e'];
d3.csv("GISTEMPData2.csv", function(data) {
//
//
// Set up x and y scales
//
//
var x = d3.scale.linear()
.range([0, innerWidth]);
x.domain(d3.extent(data, function(d) {
return +d.Year;
}));
var y = d3.scale.linear()
.range([innerHeight, 0]);
y.domain([
d3.min(data, function(d) {
return d3.min([+d.Glob, +d.NHem, d.SHem]);
}),
d3.max(data, function(d) {
return d3.max([+d.Glob, +d.NHem, d.SHem]);
})
]);
//
// Create title and axis headings
//
svg.append('g')
.attr('class', 'title')
.attr('transform', 'translate(' + (margin.left + (innerWidth / 2)) + ', ' + 22 + ')')
.append('text')
.attr('text-anchor', 'middle')
.text('Changes in Global and Hemispheric Temperatures')
svg.append('g')
.attr('transform', 'translate(' + 12 + ', ' + (height / 2) + ')')
.append('text')
.attr('text-anchor', 'middle')
.attr('transform', 'rotate(-90)')
.text('Deviation from mean temperature 1951-1980')
svg.append('g')
.attr('transform', 'translate(' + (margin.left + (innerWidth / 2)) + ', ' + (height - 3) + ')')
.append('text')
.attr('text-anchor', 'middle')
.text('Year')
//
// Create legend
//
var ordinalScale = d3.scale
.ordinal()
.domain(Object.values(labels))
.range(colors);
var legend = d3legend()
.labelFormat("none")
.cellPadding(5)
.units("")
.orientation("vertical")
.cellWidth(25)
.cellHeight(18)
.inputScale(ordinalScale)
.cellStepping(10);
svg.append("g")
.attr("transform", "translate(" + (margin.left + innerWidth + 15) + "," + "20" + ")")
.attr("class", "legend")
.call(legend);
var g = svg.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
//
//
// Create x and y axis
//
//
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom")
.ticks(16);
var yAxis = d3.svg.axis()
.scale(y)
.orient("left");
g.selectAll("g.x").remove();
g.selectAll("g.x").data([data]).enter()
.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + innerHeight + ")")
.call(xAxis);
g.selectAll("g.y").remove();
g.selectAll("g.y").data([data]).enter()
.append("g")
.attr("class", "y axis")
.call(yAxis);
// Transform data into object:
// key = regions (e.g. global, northern hemi, southern hemi)
// value = array of (date, temp) tuples
var regionTemps = Object.keys(temps).map(function(tempName) {
return {
name: tempName,
values: data.map(function(d) {
return {
date: d.Year,
temperature: +d[tempName]
};
})
};
});
//
//
// Draw lines for each "region"
//
//
var line = d3.svg.line()
.interpolate("basis")
.x(function(d) {
return x(d.date);
})
.y(function(d) {
return y(d.temperature);
});
var region = g.selectAll(".region")
.data(regionTemps)
.enter().append("g")
.attr("class", "region");
region.append("path")
.attr("class", "line")
.attr("d", function(d) {
return line(d.values);
})
.style("stroke", function(d,i) {
return colors[i];
});
//
//
// Should temps when mousing over line
//
var mouseG = g.append("g")
.attr("class", "mouse-over-effects");
mouseG.append("path") // this is the black vertical line to follow mouse
.attr("class", "mouse-line")
.style("stroke", "black")
.style("stroke-width", "1px")
.style("opacity", "0");
var lines = document.getElementsByClassName('line');
var mousePerLine = mouseG.selectAll('.mouse-per-line')
.data(regionTemps)
.enter()
.append("g")
.attr("class", "mouse-per-line");
mousePerLine.append("circle")
.attr("r", 7)
.style("stroke", function(d,i) {
return colors[i];
})
.style("fill", "none")
.style("stroke-width", "1px")
.style("opacity", "0");
mousePerLine.append("rect")
.attr("transform", "translate(10,-13)")
.attr("x", 0)
.attr("y", 0)
.attr('width', 50)
.attr('height', 20)
.style('fill', "white")
.style("opacity", .8)
mousePerLine.append("text")
.attr("transform", "translate(10,3)");
mouseG.append('svg:rect') // append a rect to catch mouse movements on canvas
.attr('width', innerWidth) // can't catch mouse events on a g element
.attr('height', innerHeight)
.attr('fill', 'none')
.attr('pointer-events', 'all')
.on('mouseout', function() { // on mouse out hide line, circles and text
d3.select(".mouse-line")
.style("opacity", "0");
d3.selectAll(".mouse-per-line circle")
.style("opacity", "0");
d3.selectAll(".mouse-per-line text")
.style("opacity", "0");
d3.selectAll(".mouse-per-line rect")
.style("opacity", "0");
})
.on('mouseover', function() { // on mouse in show line, circles and text
d3.select(".mouse-line")
.style("opacity", "1");
d3.selectAll(".mouse-per-line circle")
.style("opacity", "1");
d3.selectAll(".mouse-per-line text")
.style("opacity", "1");
d3.selectAll(".mouse-per-line rect")
.style("opacity", "1");
})
.on('mousemove', function() { // mouse moving over canvas
var mouse = d3.mouse(this);
d3.select(".mouse-line")
.attr("d", function() {
var d = "M" + mouse[0] + "," + innerHeight;
d += " " + mouse[0] + "," + 0;
return d;
});
d3.selectAll(".mouse-per-line")
.attr("transform", function(d, i) {
console.log(innerWidth/mouse[0])
var xYear = x.invert(mouse[0]),
bisect = d3.bisector(function(d) { return d.date; }).right;
idx = bisect(d.values, xYear);
var beginning = 0,
end = lines[i].getTotalLength(),
target = null;
while (true){
target = Math.floor((beginning + end) / 2);
pos = lines[i].getPointAtLength(target);
if ((target === end || target === beginning) && pos.x !== mouse[0]) {
break;
}
if (pos.x > mouse[0]) end = target;
else if (pos.x < mouse[0]) beginning = target;
else break; //position found
}
d3.select(this).select('text')
.text(y.invert(pos.y).toFixed(2));
return "translate(" + mouse[0] + "," + pos.y +")";
});
});
});
</script>
</html>
d3legend = function() {
var legendValues=[{color: "red", stop: [0,1]},{color: "blue", stop: [1,2]},{color: "purple", stop: [2,3]},{color: "yellow", stop: [3,4]},{color: "Aquamarine", stop: [4,5]}];
var legendScale;
var cellWidth = 30;
var cellHeight = 20;
var adjustable = false;
var labelFormat = d3.format(".01f");
var labelUnits = "units";
var lastValue = 6;
var changeValue = 1;
var orientation = "horizontal";
var cellPadding = 0;
function legend(g) {
function cellRange(valuePosition, changeVal) {
legendValues[valuePosition].stop[0] += changeVal;
legendValues[valuePosition - 1].stop[1] += changeVal;
redraw();
}
function redraw() {
g.selectAll("g.legendCells").data(legendValues).exit().remove();
g.selectAll("g.legendCells").select("rect").style("fill", function(d) {return d.color});
if (orientation == "vertical") {
g.selectAll("g.legendCells").select("text.breakLabels").style("display", "block").style("text-anchor", "start").attr("x", cellWidth + cellPadding).attr("y", 5 + (cellHeight / 2)).text(function(d) {return labelFormat(d.stop[0]) + (d.stop[1].length > 0 ? " - " + labelFormat(d.stop[1]) : "")})
g.selectAll("g.legendCells").attr("transform", function(d,i) {return "translate(0," + (i * (cellHeight + cellPadding)) + ")" });
}
else {
g.selectAll("g.legendCells").attr("transform", function(d,i) {return "translate(" + (i * cellWidth) + ",0)" });
g.selectAll("text.breakLabels").style("text-anchor", "middle").attr("x", 0).attr("y", -7).style("display", function(d,i) {return i == 0 ? "none" : "block"}).text(function(d) {return labelFormat(d.stop[0])});
}
}
g.selectAll("g.legendCells")
.data(legendValues)
.enter()
.append("g")
.attr("class", "legendCells")
.attr("transform", function(d,i) {return "translate(" + (i * (cellWidth + cellPadding)) + ",0)" })
g.selectAll("g.legendCells")
.append("rect")
.attr("height", cellHeight)
.attr("width", cellWidth)
.style("fill", function(d) {return d.color})
.style("stroke", "black")
.style("stroke-width", "2px");
g.selectAll("g.legendCells")
.append("text")
.attr("class", "breakLabels")
.style("pointer-events", "none");
g.append("text")
.text(labelUnits)
.attr("y", -7);
redraw();
}
legend.inputScale = function(newScale) {
if (!arguments.length) return scale;
scale = newScale;
legendValues = [];
if (scale.invertExtent) {
//Is a quantile scale
scale.range().forEach(function(el) {
var cellObject = {color: el, stop: scale.invertExtent(el)}
legendValues.push(cellObject)
})
}
else {
scale.domain().forEach(function (el) {
var cellObject = {color: scale(el), stop: [el,""]}
legendValues.push(cellObject)
})
}
return this;
}
legend.scale = function(testValue) {
var foundColor = legendValues[legendValues.length - 1].color;
for (el in legendValues) {
if(testValue < legendValues[el].stop[1]) {
foundColor = legendValues[el].color;
break;
}
}
return foundColor;
}
legend.cellWidth = function(newCellSize) {
if (!arguments.length) return cellWidth;
cellWidth = newCellSize;
return this;
}
legend.cellHeight = function(newCellSize) {
if (!arguments.length) return cellHeight;
cellHeight = newCellSize;
return this;
}
legend.cellPadding = function(newCellPadding) {
if (!arguments.length) return cellPadding;
cellPadding = newCellPadding;
return this;
}
legend.cellExtent = function(incColor,newExtent) {
var selectedStop = legendValues.filter(function(el) {return el.color == incColor})[0].stop;
if (arguments.length == 1) return selectedStop;
legendValues.filter(function(el) {return el.color == incColor})[0].stop = newExtent;
return this;
}
legend.cellStepping = function(incStep) {
if (!arguments.length) return changeValue;
changeValue = incStep;
return this;
}
legend.units = function(incUnits) {
if (!arguments.length) return labelUnits;
labelUnits = incUnits;
return this;
}
legend.orientation = function(incOrient) {
if (!arguments.length) return orientation;
orientation = incOrient;
return this;
}
legend.labelFormat = function(incFormat) {
if (!arguments.length) return labelFormat;
labelFormat = incFormat;
if (incFormat == "none") {
labelFormat = function(inc) {return inc};
}
return this;
}
return legend;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment