赞
踩
将数据以图形图像的形式展现出来,人类对三维及以下的数据产生直观感受。
便于人们发现与理解数据蕴含的信息,便于人们进行讨论。
百度开源的JS数据可视化库,底层依赖ZRender渲染。虽然该项目并不能称最优秀可视化库,但国内市场占有率很高,故本教程选择echarts。
echarts 提供的图表很丰富,只需使用其中几个。
通过官网的文档,共同学习echarts使用的基本方法。
主要学习的图表有折线图、条形图、散点图等。
官网:
大体是JSON形式数据展示:
替换为年份数据:
替换为降雨量数据:
var xAxisData = [2009,2007,2006,2005,2004,2003,2002,2001,2000,1999,1998,1997,1996,1995,1994,1993,1992,1991,1990,1989,1988,1987,1986,1985,1984,1983,1982,1981,1980,1979,1978,1977,1976,1975,1974,1973,1972,1971,1970,1969,1968,1967,1966,1965,1964,1963,1962,1961,1960,1959,1958,1957,1956,1955,1954,1953,1952,1951,1950,1949]; var data = [0.4806,0.4839,0.318,0.4107,0.4835,0.4445,0.3704,0.3389,0.3711,0.2669,0.7317,0.4309,0.7009,0.5725,0.8132,0.5067,0.5415,0.7479,0.6973,0.4422,0.6733,0.6839,0.6653,0.721,0.4888,0.4899,0.5444,0.3932,0.3807,0.7184,0.6648,0.779,0.684,0.3928,0.4747,0.6982,0.3742,0.5112,0.597,0.9132,0.3867,0.5934,0.5279,0.2618,0.8177,0.7756,0.3669,0.5998,0.5271,1.406,0.6919,0.4868,1.1157,0.9332,0.9614,0.6577,0.5573,0.4816,0.9109,0.921]; option = { title: { text: '柱状图动画延迟' }, legend: { data: ['beijing'], align: 'left' }, toolbox: { // y: 'bottom', feature: { magicType: { type: ['stack', 'tiled'] }, dataView: {}, saveAsImage: { pixelRatio: 2 } } }, tooltip: {}, xAxis: { data: xAxisData, silent: false, splitLine: { show: false } }, yAxis: { }, series: [{ name: 'beijing', type: 'bar', data: data, animationDelay: function (idx) { return idx * 10; } } ], animationEasing: 'elasticOut', animationDelayUpdate: function (idx) { return idx * 5; } };
var xAxisData = [2009,2007,2006,2005,2004,2003,2002,2001,2000,1999,1998,1997,1996,1995,1994,1993,1992,1991,1990,1989,1988,1987,1986,1985,1984,1983,1982,1981,1980,1979,1978,1977,1976,1975,1974,1973,1972,1971,1970,1969,1968,1967,1966,1965,1964,1963,1962,1961,1960,1959,1958,1957,1956,1955,1954,1953,1952,1951,1950,1949]; var data = [0.4806,0.4839,0.318,0.4107,0.4835,0.4445,0.3704,0.3389,0.3711,0.2669,0.7317,0.4309,0.7009,0.5725,0.8132,0.5067,0.5415,0.7479,0.6973,0.4422,0.6733,0.6839,0.6653,0.721,0.4888,0.4899,0.5444,0.3932,0.3807,0.7184,0.6648,0.779,0.684,0.3928,0.4747,0.6982,0.3742,0.5112,0.597,0.9132,0.3867,0.5934,0.5279,0.2618,0.8177,0.7756,0.3669,0.5998,0.5271,1.406,0.6919,0.4868,1.1157,0.9332,0.9614,0.6577,0.5573,0.4816,0.9109,0.921]; option = { title: { text: '柱状图动画延迟' }, legend: { data: ['beijing','shanghai'], align: 'left' }, toolbox: { // y: 'bottom', feature: { magicType: { type: ['stack', 'tiled'] }, dataView: {}, saveAsImage: { pixelRatio: 2 } } }, tooltip: {}, xAxis: { data: xAxisData, silent: false, splitLine: { show: false } }, yAxis: { }, series: [ { name: 'beijing', type: 'bar', data: data, animationDelay: function (idx) { return idx * 10; } }, { name: 'shanghai', type: 'bar', data: data, animationDelay: function (idx) { return idx * 10; } } ], animationEasing: 'elasticOut', animationDelayUpdate: function (idx) { return idx * 5; } };
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。