| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <!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
- },
- tooltip: {},
- xAxis: [{
- scale: true, //这个一定要设,不然barWidth和bins对应不上
- }],
- yAxis: {
- },
- series: [{
- type: 'custom',
- renderItem: function (params, api) {
- var yValue = api.value(2);
- var start = api.coord([api.value(0), yValue]);
- var size = api.size([api.value(1) - api.value(0), yValue]);
- return {
- type: 'rect',
- shape: {
- x: start[0],
- y: start[1],
- width: size[0] * 0.99,
- height: size[1]
- },
- style: api.style()
- };
- },
- itemStyle: {
- color: 'rgb(25, 183, 207)'
- },
- label: {
- normal: {
- show: true,
- position: 'insideTop'
- }
- },
- dimensions: ['x0', 'x1', 'sampleNum'],
- encode: {
- x: [0, 1],
- y: 2,
- tooltip: [0, 1, 2]
- },
- data: bins.customData
- }]
- };
- chart.setOption(option);
- });
- </script>
- </body>
- </html>
|