Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 16 additions & 132 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,138 +7,22 @@ DataV.js 是一个 JavaScript 的数据可视化库,致力于推动数据可
![DataV logo](https://raw.github.com/TBEDP/datavjs/master/doc/assets/logo.png)

- [API文档](http://tbedp.github.com/datavjs/index.html)
- 任意疑问,请移至底下联系人部分即可。

## 安装
目前处于开发中,并未release正式版本,如需使用,请采用如下方式:
## 说明
此版本只演示与TEDP主版本有区别或新增的内容,如需查看原始主版本,请至 [DataV.js on Github](https://github.com/TBEDP/datavjs) .

```bash
$ git clone git://github.com/TBEDP/datavjs.git
```

需要注意的是 [example](https://github.com/TBEDP/datavjs/tree/master/example) 目录下的例子中有 `ajax` 存在,所以你需要一个服务器来托管这些静态文件。

你也可以试用基于 DataV.js 开发的 [Chrome插件](https://chrome.google.com/webstore/detail/datavjs/fkekhkndcgobgjbkclehjognobgdoppm),可以在任意网页中将表格可视化。

## Examples
- [Pie](http://datavlab.org/datavjs/#pie)
![Pie图](https://raw.github.com/TBEDP/datavjs/master/doc/assets/pie.jpg)
- [Treemap](http://datavlab.org/datavjs/#treemap)
![Treemap图](https://raw.github.com/TBEDP/datavjs/master/doc/assets/treemap.jpg)
- [Tree](http://datavlab.org/datavjs/#tree)
![Tree图](https://raw.github.com/TBEDP/datavjs/master/doc/assets/tree.jpg)
- [Stream](http://datavlab.org/datavjs/#stream)
![Stream图](https://raw.github.com/TBEDP/datavjs/master/doc/assets/stream.jpg)
- [ScatterplotMatrix](http://datavlab.org/datavjs/#scatterplotMatrix)
![ScatterplotMatrix图](https://raw.github.com/TBEDP/datavjs/master/doc/assets/scatterplotMatrix.jpg)
- [Force](http://datavlab.org/datavjs/#force)
![Force图](https://raw.github.com/TBEDP/datavjs/master/doc/assets/force.jpg)
- [Matrix](http://datavlab.org/datavjs/#matrix)
![Matrix图](https://raw.github.com/TBEDP/datavjs/master/doc/assets/matrix.jpg)
- [Bubble](http://datavlab.org/datavjs/#bubble)
![Bubble图](https://raw.github.com/TBEDP/datavjs/master/doc/assets/bubble.jpg)
- [Chord](http://datavlab.org/datavjs/#chord)
![Chord图](https://raw.github.com/TBEDP/datavjs/master/doc/assets/chord.jpg)
- [Gender 性别图](https://github.com/TBEDP/datavjs/tree/master/example/gender)
## New Examples
- [Gender 性别图](https://github.com/hlqf/datavjs/tree/master/example/gender)
![Gender](http://nfs.nodeblog.org/d/3/d317bbffe6cc085b63c653e02d4d5373.png)

## Quick start
此处以Pie图为例。

### 引入依赖

```html
<script src="path/to/build/datav.js"></script>
<script src="path/to/charts/pie.js"></script>
```

### 准备数据

```js
var source = [
['北京', 50265],
['上海', 60555],
['广州', 38544],
['深圳', 27276],
['西安', 20506],
['昆明', 26916],
['武汉', 17636],
['拉萨', 977],
['哈尔滨', 10406],
['乌鲁木齐', 6695]
];
```

### 渲染图表

```js
// 初始化组件
var pie = new Pie("container", {width: 1000, tag: true});
// 添加数据源
pie.setSource(source);
// 渲染
pie.render();
```

### 结果:

![Pie图](https://raw.github.com/TBEDP/datavjs/master/doc/assets/pie.jpg)

## Requirements:
* [D3.js](https://github.com/mbostock/d3).
* [Raphael.js](http://raphaeljs.com/).
* [Sea.js](https://github.com/seajs/seajs).

## Learn more?
- The example site: <http://datavlab.org/datavjs/>
- [API Docs](http://tbedp.github.com/datavjs/)

## Contributors
Thanks goes to the people who have contributed code to this library, see the [GitHub Contributors](https://github.com/TBEDP/datavjs/graphs/contributors) page.

Below is the output from `git-summary`

```bash
$ git summary

project : datavjs
repo age : 1 year
active : 159 days
commits : 431
files : 276
authors :
305 Jackson Tian 70.8%
46 jdk137 10.7%
25 xie cong 5.8%
18 gozo1234 4.2%
11 Theseue 2.6%
8 xiecong 1.9%
8 wxtheseue 1.9%
4 Jiang Dongke 0.9%
3 郭方舟 0.7%
2 unknown 0.5%
1 arcthur 0.2%
```

## License

DataV.js is available under the [MIT License](https://github.com/TBEDP/datavjs/blob/master/MIT-License).

## Contact

组件由淘宝数据产品部可视化小组以及浙大CAD&CG可视化与可视分析小组共同开发
开发联系人,有问题可咨询:

- 阿里旺旺
- 朴灵[![朴灵 在线咨询](http://amos1.taobao.com/online.ww?v=2&uid=%E6%9C%B4%E7%81%B5&s=1)](http://amos1.taobao.com/msg.ww?v=2&uid=%E6%9C%B4%E7%81%B5&s=1)
- 宁朗[![宁朗 在线咨询](http://amos1.taobao.com/online.ww?v=2&uid=%E5%AE%81%E6%9C%97&s=1)](http://amos1.taobao.com/msg.ww?v=2&uid=%E5%AE%81%E6%9C%97&s=1)
- 法慧[![法慧 在线咨询](http://amos1.taobao.com/online.ww?v=2&uid=%E6%B3%95%E6%85%A7&s=1)](http://amos1.taobao.com/msg.ww?v=2&uid=%E6%B3%95%E6%85%A7&s=1)
- 解聪(浙大实习生)[![解聪 在线咨询](http://amos1.taobao.com/online.ww?v=2&uid=%E9%95%BF%E4%BA%AD%E7%9A%84%E8%8B%8F%E5%B9%95%E9%81%AE&s=1)](http://amos1.taobao.com/msg.ww?v=2&uid=%E9%95%BF%E4%BA%AD%E7%9A%84%E8%8B%8F%E5%B9%95%E9%81%AE&s=1)
- 黄芯芯(浙大实习生)[![黄芯芯 在线咨询](http://amos1.taobao.com/online.ww?v=2&uid=littlemonkey007&s=1)](http://amos1.taobao.com/msg.ww?v=2&uid=littlemonkey007&s=1)
- 阿里旺旺群:76480715
- QQ群: 18164936
- Google Group: [DataVLab](http://groups.google.com/group/datavlab)
- Gtalk: <shyvo1987@gmail.com>
- 浙大CAD&CG可视化与可视分析小组: [VAG Wiki](http://www.cad.zju.edu.cn/home/vagwiki/index.php)

如有疑问,或发现Bug,也可[提交Bug](https://github.com/TBEDP/datavjs/issues/new)
- [Level 层级图](https://github.com/hlqf/datavjs/tree/master/example/level)
![Level](https://raw.github.com/hlqf/datavjs/master/doc/assets/level.jpg)
- [Level 多元素层级图](https://github.com/hlqf/datavjs/tree/master/example/level)
![Level](https://raw.github.com/hlqf/datavjs/master/doc/assets/level_duo.jpg)
- [ChineseMap图](https://github.com/hlqf/datavjs/tree/master/example/chinamap)
![ChineseMap](https://raw.github.com/hlqf/datavjs/master/doc/assets/chinesemap.jpg)
- [分层选择器](https://github.com/hlqf/datavjs/tree/master/example/tiflevel)
![TifLevel](https://raw.github.com/hlqf/datavjs/master/doc/assets/tiflevel.jpg)
- [柱状选择器](https://github.com/hlqf/datavjs/tree/master/example/tifbarlevel)
![TifLevel](https://raw.github.com/hlqf/datavjs/master/doc/assets/tifbarlevel.jpg)

选择器用于既需要显示数据间的相关占比关系又需要合并或拆分查询条件的业务场景。
Binary file added doc/assets/chinesemap.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/assets/level.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/assets/level_duo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/assets/tifbarlevel.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/assets/tiflevel.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions example/level/level_shu.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>Document</title>
<script src="../../build/deps.js"></script>
<script src="../../lib/datav.js"></script>
<script src="../../lib/charts/level.js"></script>
<style>
.level {
padding: 10px;
margin: 10px;
height: 235px;
width: 300px;
overflow: hidden;
float: left;
}
.level2 {
padding: 10px;
margin: 10px;
height: 235px;
width: 500px;
overflow: hidden;
float: left;
}
.clr {
clear: both;
}
</style>
</head>
<body>
<div class="level"></div>
<div class="level"></div>
<div class="level"></div>
<div class="level"></div>
<div class="level"></div>
<div class="clr"></div>
<div class="level2"></div>
<script>
/**
* Examples about how to use LevelChart
* var tester = new LevelChart(DomNode); //init levelchart
* tester.render([ Array data ],{ Object globalBase: [Array globalBascialData], labels : [Array labelTypes], tipImg : "String image url for giving a tip" }, nobase : Boolean true/false );
*/

//To draw charts in different data env
var tester = new LevelChart($('.level:eq(0)'));
tester.render([ 10, 20, 30, 49, 50 ]);

var tester = new LevelChart($('.level:eq(1)'));
tester.render([ 10, 35, 88, 49, 10 ], { globalBase : [ 10, 20, 50, 30, 15], labels : [ 'a', 'b', 'c', 'd', 'e' ] });

var tester = new LevelChart($('.level:eq(2)'));
tester.render([ 0, 0, 0, 0, 0 ], { globalBase : [ 10, 20, 50, 30, 15], labels : [ 'a', 'b', 'c', 'd', 'e' ] });

//When there is no baseline, the hover effects won't be shown.
var tester = new LevelChart($('.level:eq(3)'));
tester.render([ 10, 35, 88, 49, 10 ], { nobase : true });

//You could use your own images for marking the baseline on the top-right of the chart now!
var tester = new LevelChart($('.level:eq(4)'));
tester.render([ 10, 35, 88, 49, 10 ], { globalBase : [ 0, 0, 5, 0, 0], tipImg : 'http://img03.taobaocdn.com/tps/i3/T1iTjQXXXbXXc_eAHa-19-18.png' });
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个 tipImg 是特意加上的吗??是个新浪微博的图标。

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为增强自定义,他们需要的baseline可能不称之为"全网基数",所以可以自定义图片. 在shu上面找了没找到什么合适的图片,于是放了微博的那个. 不太美观的话,一会儿ps一个替换掉

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不填写tipImg属性的时候,默认就是全网参数了的.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嗯嗯,就留着吧。


//When there is no baseline, the hover effects won't be shown.
var tester = new LevelChart($('.level2:eq(0)'), {
"width": 400,
"height": 235,
});
tester.render([[ 10, 35, 88, 49, 10 ],[ 15, 45, 78, 40, 10 ]], { globalBase : [[ 10, 20, 70, 30, 5 ], [ 10, 35, 70, 40, 15 ]]});

</script>
</body>
</html>
33 changes: 33 additions & 0 deletions example/tifbarlevel/tifbarlevel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo</title>
<script src="../../build/deps.js"></script>
<script src="../../lib/datav.js"></script>
<!--<script src="../../lib/charts/tifbarlevel.js"></script>-->
<!--If you need to roate the chart, you should use tifbarlevel2.js-->
<script src="../../lib/charts/tifbarlevel2.js"></script>
</head>
<body>
<div id="demo1"></div>
<script>
var chart = new TifBarLevel({
container: "demo1",
width: 300,
height: 200,
data: [{name: "白富美", value: 40}, {name: "高富帅", value: 60}, {name: "穷屌丝", value: 34}, {name: "女汉子", value: 45}],
clickHandle: function (d, i) {
console.log(d);
console.log(i);
},
margin: {
top: 40,
bottom: 30,
left: 60,
right: 90
}
});
</script>
</body>
</html>
31 changes: 31 additions & 0 deletions example/tifgender/tifgender.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo</title>
<script src="../../build/deps.js"></script>
<script src="../../lib/datav.js"></script>
<script src="../../lib/charts/tifgender.js"></script>
</head>
<body>
<div id="demo1"></div>
<script>
var chart = new TifGender({
container: "demo1",
width: 326,
height: 190,
data: [{name: "男", value: 55}, {name: "女", value: 45, color: "#ff88a2"}],
clickHandle: function (d, i) {
console.log(d);
console.log(i);
},
margin: {
top: 50,
bottom: 30,
left: 20,
right: 20
}
});
</script>
</body>
</html>
64 changes: 64 additions & 0 deletions example/tiflevel/tiflevel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>Document</title>
<script src="../../build/deps.js"></script>
<script src="../../lib/datav.js"></script>
<script src="../../lib/charts/tiflevel.js"></script>
<style>
</style>
</head>
<body>
<div class="level" id="tiflevel-demo1"></div>
<div class="level" id="tiflevel-demo2"></div>
<script>
//Init params for chart and darw the picture;
var tifLevel = new TifBuyerLevel({
container: "tiflevel-demo1",
width: 326,
height: 190,
margin: {
top: 60,
bottom: 100,
left: 30,
right: 50
},
clickHandle: function (d, i) {
console.log(d);
console.log(i);
},
});


var tifLevel = new TifBuyerLevel({
container: "tiflevel-demo2",
width: 326,
height: 190,
margin: {
top: 60,
bottom: 100,
left: 30,
right: 50
},
data: [{name: "白富美", value: 40}, {name: "高富帅", value: 30}, {name: "穷屌丝", value: 20}, {name: "女汉子", value: 15}],
clickHandle: function (d, i) { //event after click the bar or the tag,use console to show up.
console.log(d);
console.log(i);
},
});
//Add mark for some sections, you could use imgages like this.
tifLevel.paper.image("http://shu.taobao.com/assets/images/buyer_level_heart.png", tifLevel.leftArr[0] - 8, tifLevel.config.margin.top - 18, 18, 18)
.attr({"title": "段落标记"});
tifLevel.paper.image("http://shu.taobao.com/assets/images/buyer_level_heart.png", tifLevel.leftArr[1] - 9, tifLevel.config.margin.top - 18, 18, 18)
.attr({"title": "MarkII"});
tifLevel.paper.text(20, 30, "图表选择器").attr({
"font-family": "微软雅黑",
"font-size": "14px",
"text-anchor": "start"
});

</script>
</body>
</html>
Loading