<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>第一个 ECharts 实例</title>
<!-- 引入 echarts.js -->
<script src="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>
</head>
<body>
<!-- 为ECharts准备一个具备大小(宽高)的Dom -->
<div id="main" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('main'));
// 指定图表的配置项和数据
var option;
option = {
title: {
text: 'Funnel'
},
tooltip: {
trigger: 'item',
formatter: '{a} <br/>{b} : {c}%'
},
toolbox: {
feature: {
dataView: { readOnly: false },
restore: {},
saveAsImage: {}
}
},
legend: {
data: ['Show', 'Click']
},
series: [
{
name: 'Funnel',
type: 'funnel',
left: '10%',
top: 60,
bottom: 80,
width: '80%',
min: 0,
max: 100,
//漏斗的形成形状 控制
minSize: '20%',
maxSize: '100%',
//
sort: 'descending',
gap: 3,
label: {
show: true,
position: 'inside'
},
labelLine: {
length: 40,
lineStyle: {
width: 1,
type: 'solid'
}
},
itemStyle: {
// 梯形块状 的样式颜色设置
borderColor: '#fff',
borderWidth: 10
},
emphasis: {
label: {
fontSize: 30
}
},
data: [
{ value: 60, name: 'Visit' },
{ value: 40, name: 'Inquiry' },
{ value: 20, name: 'Order' }
]
}
]
};
option && myChart.setOption(option);
</script>
</body>
</html>