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

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.

主站蜘蛛池模板: 长子县| 峨山| 仙游县| 绵竹市| 古浪县| 辰溪县| 柳江县| 岳阳县| 铜鼓县| 阿拉善盟| 武安市| 务川| 老河口市| 饶平县| 灵璧县| 弥勒县| 逊克县| 嘉峪关市| 孟州市| 那曲县| 无棣县| 县级市| 茌平县| 叶城县| 巩义市| 武鸣县| 宾阳县| 乐至县| 深泽县| 东莞市| 华容县| 卫辉市| 安塞县| 娱乐| 乌拉特后旗| 宝兴县| 商洛市| 吴忠市| 同仁县| 什邡市| 乐安县|