ฟันเนลชาร์ตเหมาะกับการแสดงการหลุดจากขั้นเริ่มต้นไปจนถึงคอนเวอร์ชัน ความกว้างของรูปทรงช่วยให้เข้าใจจำนวนคงเหลือได้ทันที
import numpy as np
import matplotlib.pyplot as plt
steps = ["เข้าชม", "ดูสินค้า", "ใส่ตะกร้า", "ข้อมูลชำระเงิน", "ซื้อสำเร็จ"]
counts = np.array([12000, 5400, 2600, 1800, 1250])
max_width = counts[0]
fig, ax = plt.subplots(figsize=(6, 4))
y_positions = np.arange(len(steps), 0, -1)
for idx, (step, count) in enumerate(zip(steps, counts)):
width = count / max_width
left = 0.5 - width / 2
ax.fill_between(
[left, left + width],
[y_positions[idx]] * 2,
[y_positions[idx] - 0.8] * 2,
color=plt.cm.Blues(0.3 + idx * 0.12),
)
ax.text(
0.5,
y_positions[idx] - 0.4,
f"{step}\n{count:,}",
ha="center",
va="center",
color="white",
fontsize=11,
)
ax.set_xlim(0, 1)
ax.set_ylim(0, len(steps) + 0.5)
ax.axis("off")
ax.set_title("ฟันเนลการซื้อของอีคอมเมิร์ซ")
conversion = counts[-1] / counts[0]
ax.text(0.02, 0.3, f"CVR: {conversion:.1%}", fontsize=11, fontweight="bold")
fig.tight_layout()
plt.show()

อ่านอย่างไร #
- ความกว้างของแต่ละขั้นคือตัวแทนจำนวนที่เหลือ ขั้นที่แคบลงมากคือคอขวด
- ใส่ค่า CVR จากบนลงล่างเพื่อสื่อผลกระทบได้ชัด
- เปลี่ยนชื่อขั้นให้สอดคล้องกับฟลว์ของบริการได้ง่าย