配置项如下
option = {
backgroundColor: 'rgba(255,255,255,0)',
title: {
text: '按企业经济类型分',
subtext: ''
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
label: {
backgroundColor: '#283b56'
}
}
},
legend: {
data:['投资项目总数', '总投资额']
},
toolbox: {
show: true,
feature: {
restore: {show: true},
saveAsImage: {show: true}
}
},
dataZoom: {
show: false,
start: 0,
end: 100
},
xAxis: [
{
type: 'category',
boundaryGap: true,
data: (function (){
var now = new Date();
var res = ['国有','集体','股份制','私营','其它'];
return res;
})()
},
{
type: 'category',
boundaryGap: true,
data: (function (){
var res = [];
return res;
})()
}
],
yAxis: [
{
type: 'value',
scale: true,
name: '投资项目数(个)',
max: 8000,
min: 0,
boundaryGap: [0.2, 0.2]
},
{
type: 'value',
scale: true,
name: '投资总额(万元)',
max: 120000000,
min: 0,
boundaryGap: [0.2, 0.2]
}
],
series: [
{
name:'投资项目总数',
type:'bar',
xAxisIndex: 1,
barMaxWidth:75,
yAxisIndex: 1,
data:(function (){
var res = [45113555,37300833,119274188,1409131,16948179];
return res;
})()
},
{
name:'总投资额',
type:'line',
data:(function (){
var res = [2050,1593,82,674,7560];
return res;
})()
}
]
};
app.count = 11;
setInterval(function (){
axisData = (new Date()).toLocaleTimeString().replace(/^\D*/,'');
var data0 = option.series[0].data;
var data1 = option.series[1].data;
data0.shift();
data0.push(Math.round(Math.random() * 1000));
data1.shift();
data1.push((Math.random() * 10 + 5).toFixed(1) - 0);
option.xAxis[0].data.shift();
option.xAxis[0].data.push(axisData);
option.xAxis[1].data.shift();
option.xAxis[1].data.push(app.count++);
// myChart.setOption(option);
}, 2100);