Add pie demo

This commit is contained in:
Jackson Tian 2012-11-05 10:21:30 +08:00
parent 1b1e623aaa
commit 4705eaea0c
3 changed files with 64 additions and 4 deletions

10
example/pie/pie_map.csv Normal file
View File

@ -0,0 +1,10 @@
50265,北京
60555,上海
38544,广州
27276,深圳
20506,西安
26916,昆明
17636,武汉
977,拉萨
10406,哈尔滨
6695,乌鲁木齐
1 50265 北京
2 60555 上海
3 38544 广州
4 27276 深圳
5 20506 西安
6 26916 昆明
7 17636 武汉
8 977 拉萨
9 10406 哈尔滨
10 6695 乌鲁木齐

53
example/pie/pie_map.html Normal file
View File

@ -0,0 +1,53 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Pie Chart</title>
<script src="../../build/deps.js"></script>
<!-- chord -->
<script src="../../deps/seajs/sea.js"></script>
<script>
seajs.config({
alias: {
'DataV': '/lib/datav.js',
'Pie': '/lib/charts/pie.js'
}
});
</script>
<style type="text/css">
#chart {
border-top: 1px dashed #F00;
border-bottom: 1px dashed #F00;
padding-left: 20px;
}
.textArea {
border: 2px solid black;
color: black;
font-family: monospace;
height: 3in;
overflow: auto;
padding: 0.5em;
width: 750px;
}
</style>
</head>
<body>
<div id="chart"></div>
<script>
seajs.use(["Pie", "DataV"], function (Pie, DataV) {
// DataV.changeTheme("datav");
var pie = new Pie("chart", {
width: 1000,
tag: true
});
DataV.csv("pie_map.csv", function (source) {
pie.setSource(source, {label: 1, value: 0});
pie.render();
});
});
</script>
</script>
</body>
</html>

View File

@ -189,7 +189,6 @@
return function (num) {
var thisColor = gotColor;
var thisColorCount = colorCount;
return thisColor[num % thisolorCount];
};
};
@ -254,9 +253,7 @@
* @param {String} url JSON文件地址
* @param {Function} callback 回调函数
*/
DataV.json = function (url, callback) {
d3.json(url, callback);
};
DataV.json = d3.json;
/**
* 请求一个CSV文件并解析