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

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.

主站蜘蛛池模板: 岳普湖县| 庆安县| 定陶县| 迁安市| 宁津县| 古浪县| 华安县| 庆云县| 祁阳县| 姚安县| 和政县| 榆树市| 额济纳旗| 高雄市| 固安县| 佛教| 佳木斯市| 怀集县| 竹山县| 诸城市| 广水市| 石楼县| 八宿县| 济源市| 福建省| 台湾省| 章丘市| 临汾市| 孟连| 昌乐县| 夏河县| 拜泉县| 岗巴县| 宁晋县| 株洲市| 宜良县| 静安区| 深圳市| 莎车县| 抚宁县| 集安市|