官术网_书友最值得收藏!

Loading the data

The first thing we do is load the data. In the previous section, we already showed what the data looks like, and how we sanitized it. The only change we make here is that we change the labels indicating how long a firm has been in business. We do this because the default labels are a bit long and shorter labels look better in the final visualization:

var loadedData; 
d3.csv('./data/businessFiltered.csv',
function(row) {
switch (row.yearsInBusiness) {
case "001" : row.yearsInBusinessLabel = "All"; break;
case "311" : row.yearsInBusinessLabel = "less then 2 years"; break;
case "318" : row.yearsInBusinessLabel = "2 to 3 years "; break;
case "319" : row.yearsInBusinessLabel = "4 to 5 years"; break;
case "321" : row.yearsInBusinessLabel = "6 to 10 years"; break;
case "322" : row.yearsInBusinessLabel = "11 to 15 years"; break;
case "323" : row.yearsInBusinessLabel = "more then 16 years"; break;
}

return row;
},
function (data) {
loadedData = data;
updateCircle();
});

As you can see we use the standard d3.csv to load the data and change the row.yearsInBusinessLabel field of each row. Once the data is loaded, we call the updateCircle() function. We'll show you what happens in that function later in this chapter. We'll first look at the dropdown you can use to select a specific group to show.

主站蜘蛛池模板: 江口县| 宁南县| 亳州市| 自治县| 吉首市| 孝义市| 察雅县| 丰都县| 三江| 重庆市| 固安县| 金川县| 荣成市| 屯昌县| 台南市| 徐州市| 武山县| 营口市| 山东省| 耿马| 东兴市| 固原市| 崇义县| 九寨沟县| 南投市| 漠河县| 遂昌县| 永川市| 香河县| 昌平区| 建平县| 连城县| 徐州市| 新绛县| 泽普县| 筠连县| 辉县市| 盐城市| 宽城| 济宁市| 贞丰县|