TIP:ie8不支持原生的map()方法,查找资料后,改变值的获取方式。
$.map(data,function(item,index){return XXX})
<div id="zwTotal"></div>
//zwTotal
var zwTotalChart = echarts.init(document.getElementById('zwTotal'));
var halfData = [["2000-07-12",113],["2000-07-13",107],["2000-07-14",131],["2000-07-15",111],["2000-07-16",64],["2000-07-17",69],["2000-07-18",88],["2000-07-19",77],["2000-07-20",83],["2000-07-21",111],["2000-07-22",57],["2000-07-23",55],["2000-07-24",60]];
var monthData = [["2000-06-05",116],["2000-06-06",129],["2000-06-07",135],["2000-06-08",86],["2000-06-09",73],["2000-06-10",85],["2000-06-11",73],["2000-06-12",68],["2000-06-13",92],["2000-06-14",130],["2000-06-15",245],["2000-06-16",139],["2000-06-17",115],["2000-06-18",111],["2000-06-19",309],["2000-06-20",206],["2000-06-21",137],["2000-06-22",128],["2000-06-23",85],["2000-06-24",94],["2000-06-25",71],["2000-06-26",106],["2000-06-27",84],["2000-06-28",93],["2000-06-29",85],["2000-06-30",73],["2000-07-01",83],["2000-07-02",125],["2000-07-03",107],["2000-07-04",82]];
/*var dateList = halfData.map(function (item) {
return item[0];
});
var valueList = halfData.map(function (item) {
return item[1];
});
var dateListMonth = monthData.map(function (item) {
return item[0];
});
var valueListMonth = monthData.map(function (item) {
return item[1];
});*/
var dateList = $.map(halfData,function(item,index){
return item[0];
});
var valueList = $.map(halfData,function(item,index){
return item[1];
});
var dateListMonth = $.map(monthData,function(item,index){
return item[0];
});
var valueListMonth = $.map(monthData,function(item,index){
return item[1];
});
var zwTotalOption = {
backgroundColor:'#fff',
// Make gradient line here
visualMap: [{
show: false,
type: 'continuous',
seriesIndex: 0,
min: 0,
max: 400
}, {
show: false,
type: 'continuous',
seriesIndex: 1,
dimension: 0,
min: 0,
max: dateListMonth.length - 1
}],
title: [{
left: 'center',
bottom:'60%',
text: '近15天',
textStyle:{
fontSize:13,
color:'#959595',
fontWeight:'normal'
}
}, {
left: 'center',
top:'70%',
text: '近1个月',
textStyle:{
fontSize:13,
color:'#959595',
fontWeight:'normal'
}
}],
tooltip: {
trigger: 'axis'
},
xAxis: [{
data: dateList, //曲线(1)X轴数据
axisLine: {show: false},
axisLabel: {
show: false, //刻度标签隐藏
inside:true //刻度标签朝内
},
axisTick: {show: false},
splitLine: {show: false}
}, {
data: dateListMonth, //曲线(2)X轴数据
gridIndex: 1,
axisLine: {show: false},
axisLabel: {
show: false,
inside:true
},
axisTick: {show: false},
splitLine: {show: false}
}],
yAxis: [{
splitLine: {show: false},
axisLine: {show: false},
axisLabel: {
show: false,
inside:true
},
axisTick: {show: false}
}, {
splitLine: {show: false},
gridIndex: 1,
axisLine: {show: false},
axisLabel: {
show: false,
inside:true
},
axisTick: {show: false}
}],
grid: [{
bottom: '90%'
}, {
top: '40%'
}],
series: [{
type: 'line',
itemStyle : {
normal : {
lineStyle:{
color:'#d1d1d1',
width:1
}
}
},
showSymbol: false,
data: valueList //曲线(1)数据
}, {
type: 'line',
itemStyle : {
normal : {
lineStyle:{
color:'#d1d1d1',
width:1
}
}
},
showSymbol: false,
data: valueListMonth, //曲线(2)数据
xAxisIndex: 1,
yAxisIndex: 1
}]
};
// 使用刚指定的配置项和数据显示图表
zwTotalChart.setOption(zwTotalOption);
// 图表自适应
window.onresize = function () {
zwTotalChart.resize();
};