Skip to content

Commit a31f739

Browse files
committed
doc: add bundler example.
1 parent d15312f commit a31f739

File tree

2 files changed

+97
-2
lines changed

2 files changed

+97
-2
lines changed

Diff for: README.md

+47-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ecStat
22

3-
A statistical and data mining tool for [Apache ECharts (incubating)](https://github.com/apache/incubator-echarts). You can use it to analyze data and then visualize the results with ECharts, or just use it to process data.
3+
A statistical and data mining tool for [Apache ECharts](https://github.com/apache/echarts). You can use it to analyze data and then visualize the results with ECharts, or just use it to process data.
44

55
It works both in node.js and in the browser.
66

@@ -25,6 +25,52 @@ var result = ecStat.clustering.hierarchicalKMeans(data, clusterNumber, false);
2525
</script>
2626
```
2727

28+
If using bundler (like webpack, rollup, etc.), for example:
29+
```sh
30+
npm install echarts-stat
31+
npm install echarts
32+
```
33+
```js
34+
import * as echarts from 'echarts';
35+
import {transform} from 'echarts-stat';
36+
37+
echarts.registerTransform(transform.histogram);
38+
39+
var myChart = echarts.init(document.getElementById('main0'));
40+
41+
var option = {
42+
dataset: [{
43+
source: [
44+
[8.3, 143], [8.6, 214], [8.8, 251], [10.5, 26], [10.7, 86], [10.8, 93], [11.0, 176], [11.0, 39], [11.1, 221], [11.2, 188], [11.3, 57], [11.4, 91], [11.4, 191], [11.7, 8], [12.0, 196], [12.9, 177], [12.9, 153], [13.3, 201], [13.7, 199], [13.8, 47], [14.0, 81], [14.2, 98], [14.5, 121], [16.0, 37], [16.3, 12], [17.3, 105], [17.5, 168], [17.9, 84], [18.0, 197], [18.0, 155], [20.6, 125]
45+
]
46+
}, {
47+
transform: {
48+
type: 'ecStat:histogram'
49+
}
50+
}],
51+
tooltip: {
52+
},
53+
xAxis: {
54+
type: 'category',
55+
scale: true
56+
},
57+
yAxis: {},
58+
series: {
59+
name: 'histogram',
60+
type: 'bar',
61+
barWidth: '99.3%',
62+
label: {
63+
show: true,
64+
position: 'top'
65+
},
66+
datasetIndex: 1
67+
}
68+
};
69+
70+
myChart.setOption(option);
71+
```
72+
73+
2874
## API Reference
2975

3076
* [Histogram](#histogram)

Diff for: README.zh-CN.md

+50-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ecStat
22

3-
ecStat 是 [Apache ECharts (incubating)](https://github.com/apache/incubator-echarts) 的统计和数据挖掘工具。你可以把它当作一个工具库直接用来分析数据;你也可以将其与 ECharts 结合使用,用 ECharts 可视化数据分析的结果。
3+
ecStat 是 [Apache ECharts](https://github.com/apache/echarts) 的统计和数据挖掘工具。你可以把它当作一个工具库直接用来分析数据;你也可以将其与 ECharts 结合使用,用 ECharts 可视化数据分析的结果。
44

55
同时支持 Node 和浏览器中使用。
66

@@ -25,6 +25,55 @@ var result = ecStat.clustering.hierarchicalKMeans(data, clusterNumber, false);
2525
</script>
2626
```
2727

28+
29+
如果使用打包工具(如 webpack、rollup 等),可参照下例:
30+
```sh
31+
npm install echarts-stat
32+
npm install echarts
33+
```
34+
```js
35+
import * as echarts from 'echarts';
36+
import {transform} from 'echarts-stat';
37+
38+
echarts.registerTransform(transform.histogram);
39+
40+
var myChart = echarts.init(document.getElementById('main0'));
41+
42+
var option = {
43+
dataset: [{
44+
source: [
45+
[8.3, 143], [8.6, 214], [8.8, 251], [10.5, 26], [10.7, 86], [10.8, 93], [11.0, 176], [11.0, 39], [11.1, 221], [11.2, 188], [11.3, 57], [11.4, 91], [11.4, 191], [11.7, 8], [12.0, 196], [12.9, 177], [12.9, 153], [13.3, 201], [13.7, 199], [13.8, 47], [14.0, 81], [14.2, 98], [14.5, 121], [16.0, 37], [16.3, 12], [17.3, 105], [17.5, 168], [17.9, 84], [18.0, 197], [18.0, 155], [20.6, 125]
46+
]
47+
}, {
48+
transform: {
49+
type: 'ecStat:histogram'
50+
}
51+
}],
52+
tooltip: {
53+
},
54+
xAxis: {
55+
type: 'category',
56+
scale: true
57+
},
58+
yAxis: {},
59+
series: {
60+
name: 'histogram',
61+
type: 'bar',
62+
barWidth: '99.3%',
63+
label: {
64+
show: true,
65+
position: 'top'
66+
},
67+
datasetIndex: 1
68+
}
69+
};
70+
71+
myChart.setOption(option);
72+
```
73+
74+
75+
76+
2877
## API
2978

3079
* [直方图](#histogram)

0 commit comments

Comments
 (0)