配置项如下
option = {
title: {
text: '商城对语音用户留存率影响'
},
legend: {
data:['访问商城语音新用户7日点留存率', '访问商城语音老用户7日点留存率', '没访问商城语音新用户7日点留存率', '没访问商城语音老用户7日点留存率'],
left: 240
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
toolbox: {
feature: {
saveAsImage: {}
}
},
tooltip: {
trigger: 'axis',
formatter: function (params) {
var content = params.map(function (item) {
var value = item.value;
var name = item.seriesName;
value = value + '%';
return name + ': ' + value;
});
return content.join('<br>');
}
},
xAxis: [
{
type: 'category',
boundaryGap: true,
position: 'bottom',
data: [
'2016-05-01','2016-05-02','2016-05-03','2016-05-04',
'2016-05-05','2016-05-06','2016-05-07'
]
},
{
inverse: true,
type: 'category',
boundaryGap: true,
axisLine: {onZero: false},
position: 'top',
data: [
'2015-03-01','2015-03-02','2015-03-03','2015-03-04',
'2015-03-05','2015-03-06','2015-03-07'
]
}
],
yAxis: [
{
type: 'value',
name: '7日留存率',
nameLocation: 'start',
nameGap: 25,
min: 0,
max: 100,
axisLabel: {
formatter: '{value}%'
}
},
{
type: 'value',
name: '7日留存率',
nameLocation: 'start',
nameGap: 25,
min: 0,
max: 100,
axisLabel: {
formatter: '{value}%'
}
}
],
series: [
{
name:'访问商城语音新用户7日点留存率',
type:'bar',
data:[27, 92, 11, 24, 90, 33, 31]
},
{
name:'访问商城语音老用户7日点留存率',
type:'line',
xAxisIndex: 1, // 双轴时这里要设置
data:[17, 82, 41, 74, 80, 53, 61]
},
{
name:'没访问商城语音新用户7日点留存率',
type:'bar',
yAxisIndex: 1, // 双轴时这里要设置
data:[27, 12, 71, 54, 10, 63, 21]
},
{
name:'没访问商城语音老用户7日点留存率',
type:'line',
xAxisIndex: 1, // 双轴时这里要设置
yAxisIndex: 1, // 双轴时这里要设置
data:[67, 52, 91, 34, 80, 53, 81]
}
]
}