-
Notifications
You must be signed in to change notification settings - Fork 310
/
Copy pathhistogram_bar.html
71 lines (70 loc) · 2.59 KB
/
histogram_bar.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="../lib/esl.js"></script>
<script src="../lib/config.js"></script>
<script src="../lib/jquery.min.js"></script>
</head>
<body>
<style>
html, body, #main {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
}
</style>
<div id="main"></div>
<script>
require([
'echarts',
'ecStat'
], function (echarts, ecStat) {
var chart = echarts.init(document.getElementById('main'));
window.onresize = function () {
chart.resize();
};
// var height = [70, 65, 63, 72, 81, 83, 66, 75, 80, 75, 79, 76, 76, 69, 75, 74, 85, 86, 71, 64, 78, 80, 74, 72, 77, 81, 82, 80, 80, 80, 87];
var girth = [8.3,8.6, 8.8, 10.5, 10.7, 10.8, 11.0, 11.0, 11.1, 11.2, 11.3, 11.4, 11.4, 11.7, 12.0, 12.9, 12.9, 13.3, 13.7, 13.8, 14.0, 14.2, 14.5, 16.0, 16.3, 17.3, 17.5, 17.9, 18.0, 18.0, 20.6];
var testdata = [0.87659, 0.68975, 0.78613];
var bins = ecStat.histogram(girth);
var option = {
title: {
text: 'Girths of Black Cherry Trees',
left: 'center',
top: 20
},
color: ['rgb(25, 183, 207)'],
grid: {
left: '3%',
right: '3%',
bottom: '3%',
containLabel: true
},
xAxis: {
// boundaryGap: '5%',
scale: true, //这个一定要设,不然barWidth和bins对应不上
},
yAxis: {
},
series: [{
name: 'height',
type: 'bar',
barWidth: '99.3%',
// barCategoryGap: 0,
label: {
normal: {
show: true,
position: 'insideTop'
}
},
data: bins.data
}]
};
chart.setOption(option);
});
</script>
</body>
</html>