- Expert Data Visualization
- Jos Dirksen
- 217字
- 2021-07-09 18:22:45
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.
推薦閱讀
- Boost.Asio C++ Network Programming(Second Edition)
- C++面向?qū)ο蟪绦蛟O(shè)計(第三版)
- Java程序設(shè)計與開發(fā)
- PHP程序設(shè)計(慕課版)
- Mastering Entity Framework
- 64位匯編語言的編程藝術(shù)
- Python機(jī)器學(xué)習(xí)實戰(zhàn)
- ASP.NET 3.5程序設(shè)計與項目實踐
- Python機(jī)器學(xué)習(xí)編程與實戰(zhàn)
- Learning Zurb Foundation
- Learning ArcGIS for Desktop
- 批調(diào)度與網(wǎng)絡(luò)問題的組合算法
- HTML5與CSS3基礎(chǔ)教程(第8版)
- INSTANT Yii 1.1 Application Development Starter
- GameMaker Essentials