【D3.js数据可视化系列教程】--(九)D3的数据类型
2013-09-08 10:06
786 查看
1 变量
JAVASCRIPT的变量是一种类型宽松的语言。定义变量不用指定数据类型。而且还是动态可变的。var value = 100; value = 99.9999; value = false; value = "hello world!";
2 数组
从0开始 var percentages = [ 0.55, 0.32, 0.91 ]; var names = [ "a", "b", "c" ]; percentages[1] //返回 0.32 names[1] //返回 "b"
3 对象
var people = { name: "tianxuzhang", birthday: "1992-06-01", sex: "male", hobby: "d3" }; people.name //返回 "tianxuzhang" people.birthday //返回 "1992-06-01" people.sex //返回 male people.hobby //返回 d3
4 对象数组
var fruits = [ { kind: "grape", color: "red", quantity: 12, tasty: true }, { kind: "kiwi", color: "brown", quantity: 98, tasty: true }, { kind: "banana", color: "yellow", quantity: 0, tasty: true } ]; fruits[0].kind == "grape" fruits[0].color == "red" fruits[0].quantity == 12 fruits[0].tasty == true fruits[1].kind == "kiwi" fruits[1].color == "brown" fruits[1].quantity == 98 fruits[1].tasty == true fruits[2].kind == "banana" fruits[2].color == "yellow" fruits[2].quantity == 0 fruits[2].tasty == true
5 JSON
JSON是Javascript对象。常用于AJAX数据请求。它的速度更快,比XML更容易解析var jsonFruit = { "kind": "grape", "color": "red", "quantity": 12, "tasty": true };
6 GeoJSON
GeoJSON是可以存储地理空间(通常为经度/纬度坐标)点,形状(如线和多边形)和其他空间的Feature。var geodata = { "type": "FeatureCollection", "features": [ { "type": "Feature", "geometry": { "type": "Point", "coordinates": [ 150.1282427, -24.471803 ] }, "properties": { "type": "town" } } ] };
相关文章推荐
- 【D3.V3.js数据可视化系列教程】--(九)D3的数据类型
- 【D3.js数据可视化系列教程】--(四)使用数据
- 【D3.js数据可视化系列教程】--(八)使用D3绘制SVG
- 【D3.js数据可视化系列教程】--(六)生成测试数据
- 【D3.js数据可视化系列教程】(十七)--通过键联结数据
- 【D3.js数据可视化系列教程】--(三)数据绑定
- 【D3.js数据可视化系列教程】--(一)简介
- 【D3.js数据可视化系列教程】(二十二)--交互图表之提示条
- 【D3.js数据可视化系列教程】(二十四)--力导向图
- 【D3.js数据可视化系列教程】(二十五)--加载csv文件
- 【D3.js数据可视化系列教程】(二十七)--径向树
- 【D3.js数据可视化系列教程】--(七)SVG初探
- 【D3.js数据可视化系列教程】(三十一)-- 力导向图之分子式
- 【D3.js数据可视化系列教程】--(五)用层画条形图
- 【D3.js数据可视化系列教程】--(十)更自由的条形图
- 【D3.js数据可视化系列教程】(三十)--力导向图之带文字
- 【D3.V3.js数据可视化系列教程】--(三)数据绑定
- 【D3.js数据可视化系列教程】--(二)最简单的开始:添加元素
- Sqlserver基础系列教程2-数据表的创建与数据类型
- 【D3.V3.js数据可视化系列教程】--(四)使用数据