jQuery插件echarts實(shí)現(xiàn)的多柱子柱狀圖效果示例【附demo源碼下載】
本文實(shí)例講述了jQuery插件echarts實(shí)現(xiàn)的多柱子柱狀圖效果。分享給大家供大家參考,具體如下:
1、問(wèn)題背景:
利用ECharts制作一個(gè)多柱子柱狀圖,其中數(shù)據(jù)源模擬動(dòng)態(tài)獲取
2、實(shí)現(xiàn)源碼:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>echarts-多柱子柱狀圖</title>
<script type="text/javascript" src="jquery-1.4.2.min.js" ></script>
<script type="text/javascript" src="echarts.js" ></script>
<style>
body,html{
width:99%;
height: 99%;
font-family: "arial, helvetica, sans-serif";
font-size: x-large;
font-kerning: inherit;
font-stretch: expanded;
}
#manyColumn{
width: 100%;
height: 100%;
font-size: 14px;
font-family: "微軟雅黑";
backface-visibility: visible;
background-blend-mode: inherit;
background-origin: border-box;
background: content-box;
background-color: #5BC0DE;
}
</style>
<script>
$(function(){
buildData();
});
//生成數(shù)據(jù)
function buildData()
{
var columLabel = ['甲','乙','丙','丁','戊','己','庚','辛','壬','癸'];
var columName = ['周一','周二','周三','周四','周五','周六','周日'];
var columnValue = new Array();
var arrData = new Array();
for(var i=0;i<columLabel.length;i++)
{
for(var j=0;j<columName.length;j++)
{
arrData.push(Math.floor(Math.random()*1000+1000*j-1000*i));
}
console.info(arrData);
columnValue.push(eval('(' + ("{'name':'"+columLabel[i]+"','type':'bar','data':["+arrData+"]}") + ')'));
}
buildChart(columLabel,columName,columnValue);
}
//生成圖形
function buildChart(columLabel,columName,columnValue)
{
var chart = document.getElementById('manyColumn');
var echart = echarts.init(chart);
var option = {
tooltip : {
trigger: 'axis',
axisPointer : {
type : 'shadow'
}
},
toolbox: {
show : true,
feature : {
saveAsImage : {show: true}
}
},
legend: {
data:columLabel
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis : [
{
min:0,
type : 'category',
data : columName
}
],
yAxis : [
{
min:0,
type : 'value'
}
],
series : columnValue
};
echart.setOption(option);
}
</script>
</head>
<body>
<div id="manyColumn"></div>
</body>
</html>
3、實(shí)現(xiàn)效果圖:

附:完整實(shí)例代碼點(diǎn)擊此處本站下載。
更多關(guān)于jQuery相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《jQuery常用插件及用法總結(jié)》、《jquery中Ajax用法總結(jié)》、《jQuery表格(table)操作技巧匯總》、《jQuery擴(kuò)展技巧總結(jié)》、《jQuery常見(jiàn)經(jīng)典特效匯總》及《jquery選擇器用法總結(jié)》
希望本文所述對(duì)大家jQuery程序設(shè)計(jì)有所幫助。
相關(guān)文章
jQuery lazyLoad圖片延遲加載插件的優(yōu)化改造方法分享
jquery插件開(kāi)發(fā)之實(shí)現(xiàn)jquery手風(fēng)琴功能分享
EasyUI中combobox默認(rèn)值注意事項(xiàng)
jQuery實(shí)現(xiàn)的給圖片點(diǎn)贊+1動(dòng)畫(huà)效果(附在線演示及demo源碼下載)
js獲取通過(guò)ajax返回的map型的JSONArray的方法
jQuery實(shí)現(xiàn)帶滾動(dòng)導(dǎo)航效果的全屏滾動(dòng)相冊(cè)實(shí)例
Treegrid的動(dòng)態(tài)加載實(shí)例代碼
jquery實(shí)現(xiàn)的回旋滾動(dòng)效果完整實(shí)例【附demo源碼下載】

