css静态漏斗绘制
- 示例图

- html代码
<view class="funnel-chart flex-align-center">
<view class="funnel-chart-left">
<view class="badge-item f-c-c" v-for="(item,index) in badgeList" :key="index">
<span :style="{'background':item.color,'border-color': item.borderColor}"></span>
<span>{{ item.num }}</span>
</view>
</view>
<view class="funnel-chart-right f-c-c">
<view class="funnel-item" v-for="(item, index) in funnelData" :key="index">
<view class="funnel-item-son f-c-c" :style="{width:item.funnleWidth+'rpx',
borderBottom:' 38rpx solid '+funnleColor[index],
borderLeft:item.nextWidth+'rpx solid transparent',
borderRight: item.nextWidth+'rpx solid transparent'}"></view>
<view v-if="index == level-1" class="carbon-intensity f-c-c" :style="{'background':funnleColor[index]}">{{ popDetail.carbonIntensity }}
<view class="tip" :style="{'border-right-color':funnleColor[index],'border-bottom-color':funnleColor[index]}"></view>
</view>
</view>
</view>
</view>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
- 数据部分
funnleColor:['#31946C', '#F7ED3B', '#F89D4C', '#F24A4F'],
funnelData:[
{funnleWidth: 36, nextWidth: 8},
{funnleWidth: 52, nextWidth: 8},
{funnleWidth: 68, nextWidth: 8},
{funnleWidth: 96, nextWidth: 14}
],
badgeList:[
{
num: 34,
color: '#31946C',
borderColor:'#027846'
},
{
num: 40,
color: '#F7ED3B',
borderColor:'#F5EA0B'
},
{
num: 48,
color: '#F89D4C',
borderColor:'#F38622'
},
{
num: 59,
color: '#F24A4F',
borderColor:'#EC1D23'
}
],
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
- 样式部分
.funnel-chart{
.funnel-chart-left{
.badge-item{
margin-bottom: 20rpx;
position: relative;
&::after{
content: '';
border-right: 2rpx solid #E1E7E7;
height: 40rpx;
position: absolute;
top:12rpx;
left:6rpx;
z-index: 0;
}
&:nth-last-child(1){
margin-bottom: 0;
&::after{
display: none;
}
}
span{
&:nth-child(1){
width: 12rpx;
height: 12rpx;
border: 2rpx solid;
margin-right: 8rpx;
border-radius: 50%;
z-index: 1;
}
&:nth-child(2){
font-weight: 400;
font-size: 20rpx;
color: #000000;
line-height: 26rpx;
}
}
}
}
.funnel-chart-right{
margin-left: 14rpx;
flex-direction: column;
.funnel-item{
position: relative;
.funnel-item-son{
height: 0;
}
.carbon-intensity{
position: absolute;
width: 60rpx;
height: 32rpx;
background: #F7ED3B;
font-weight: 400;
font-size: 24rpx;
color: #000000;
border-radius: 10rpx;
top:0rpx;
right:-62rpx;
.tip{
position: absolute;
left:-7rpx;
bottom:8rpx;
display: block;
width: 0;
height: 0;
border-radius: 4rpx;
border: 8rpx solid transparent;
transform: scaleX(0.8) rotate(135deg);
}
}
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
上次更新: 2024/03/31, 18:31:51