现在是四条不相干的数据,如何把户型和指标关联起来,选中一个户型可以看到销量和销售额两条线,反之亦然
配置项如下
option = {
title: {
text: '某楼盘销售情况',
// subtext: '纯属虚构',
textStyle:{
color:'#f00'
},
left:'center',
top:'top'
},
toolbox: {
show: true,
feature: {
magicType: {show: true, type: ['line', 'bar']},
saveAsImage: {show: true},
dataZoom:{}
}
},
tooltip: {
trigger: 'axis'
},
legend: [
{
data:['销量','销售额'],
top: '40px',
icon: 'rect'
},
{
data:['户型A','户型B'],
top:'20px',
icon: 'rect'
}
],
xAxis: {
type: 'category',
boundaryGap: ['5%', '5%'],
data: ['周一','周二','周三','周四','周五']
},
yAxis: [
{
type: 'value',
name: '销量',
position: 'left'
},
{
type: 'value',
name: '销售额',
position: 'right'
}
],
series: [
{
name: ['销量'],
yAxisIndex:0,
type: 'line',
smooth: true,
data:[10,2,8,6,9]
},
{
name: ['销售额'],
yAxisIndex:1,
type: 'line',
smooth: true,
data: [90, 120, 210,100,150]
},
{
name: ['户型A'],
yAxisIndex:0,
type: 'line',
smooth: true,
data:[1,2,6,6,11]
},
{
name: ['户型B'],
yAxisIndex:1,
type: 'line',
smooth: true,
data: [100, 101, 200,80,100]
}
]
};