<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ECharts</title>
<script src="common/js/echarts-2.2.2/echarts.js"></script>
<script type="text/javascript">
function initDefaultChart(ec){
var myChart = ec.init(document.getElementById('main01'));
var option = {
tooltip : {
formatter: "{a} <br/>{b} : {c}%"
},
toolbox: {
show : false,
feature : {
mark : {show: true},
restore : {show: true},
saveAsImage : {show: true}
}
},
series : [
{
name:'业务指标',
type:'gauge',
splitNumber: 10,
axisLine: {
lineStyle: {
color: [[0.2, '#228b22'],[0.8, '#48b'],[1, '#ff4500']],
width: 3
}
},
axisTick: {
splitNumber: 10,
length :10,
lineStyle: {
color: 'auto'
}
},
axisLabel: {
textStyle: {
color: 'auto'
}
},
splitLine: {
show: true,
length :15,
lineStyle: {
color: 'auto'
}
},
pointer : {
width : 5
},
title : {
show : true,
offsetCenter: [0, '-40%'],
textStyle: {
fontWeight: 'bolder'
}
},
detail : {
formatter:'{value}%',
textStyle: {
color: 'auto',
fontWeight: 'bolder'
}
},
data:[{value: 25, name: '完成率'}]
}
]
};
myChart.setOption(option);
setInterval(function (){
option.series[0].data[0].value = (Math.random()*100).toFixed(2) - 0;
myChart.setOption(option,true);
},2000);
var myChart02 = ec.init(document.getElementById('main02'));
var option02 = {
tooltip : {
formatter: "{a} <br/>{b} : {c}%"
},
toolbox: {
show : false,
feature : {
mark : {show: true},
restore : {show: true},
saveAsImage : {show: true}
}
},
series : [
{
name:'温度指标',
type:'gauge',
splitNumber: 10,
axisLine: {
lineStyle: {
color: [[0.2, '#228b22'],[0.8, '#48b'],[1, '#ff4500']],
width: 3
}
},
axisTick: {
splitNumber: 10,
length :10,
lineStyle: {
color: 'auto'
}
},
axisLabel: {
textStyle: {
color: 'auto'
}
},
splitLine: {
show: true,
length :15,
lineStyle: {
color: 'auto'
}
},
pointer : {
width : 5
},
title : {
show : true,
offsetCenter: [0, '-40%'],
textStyle: {
fontWeight: 'bolder'
}
},
detail : {
formatter:'{value}',
textStyle: {
color: 'auto',
fontWeight: 'bolder'
}
},
data:[{value: 50, name: '完成率'}]
}
]
};
myChart02.setOption(option);
setInterval(function (){
option02.series[0].data[0].value = (Math.random()*100).toFixed(2) - 0;
myChart02.setOption(option02,true);
},2000);
}
</script>
<script type="text/javascript">
require.config({
paths: {
echarts: 'common/js/echarts-2.2.2'
}
});
require(
[
'echarts',
'echarts/chart/line',
'echarts/chart/bar',
'echarts/chart/gauge'
],
function (ec) {
initDefaultChart(ec);
}
);
</script>
</head>
<body>
<div id="main01" style="height:400px"></div>
<div id="main02" style="height:400px"></div>
</body>
</html>