效果图
实现代码
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
<meta name="format-detection" content="telephone=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title>ECharts</title>
<style type="text/css">
.row {
display: flex;
justify-content: space-between;
margin-bottom: 5px;
}
.row .cell {
border: solid 1px #d6b8b8;
padding: 5px;
width: 47%;
}
.head {
font-weight: bold;
font-size: 16px;
}
.center {
color: #D9001B;
font-weight: bold;
font-size: 26px;
border-bottom: solid 1px #196CE5;
margin: 0px auto;
width: 98%;
padding-bottom: 5px;
padding-top: 5px;
}
.footer {
font-weight: bold;
font-size: 14px;
margin-top: 5px;
}
</style>
<script src="../res/echarts.js"></script>
</head>
<body>
<div class="row">
<div class="cell">
<div class="head">2022年合同额(未税)</div>
<div class="center">1785万元</div>
<div class="footer">计算进度:3191%</div>
</div>
<div class="cell">
<div class="head">2022年合同额(未税)</div>
<div class="center">1785万元</div>
<div class="footer">计算进度:3191%</div>
</div>
</div>
<div class="row">
<div class="cell">
<div class="head">2022年合同额(未税)</div>
<div class="center">1785万元</div>
<div class="footer">计算进度:3191%</div>
</div>
<div class="cell">
<div class="head">2022年合同额(未税)</div>
<div class="center">1785万元</div>
<div class="footer">计算进度:3191%</div>
</div>
</div>
<!-- 饼图 -->
<div id="pie" style="width: 100%;height:300px;"></div>
<!-- 结算情况 -->
<div id="pie_info" style="width: 100%;height:520px;"></div>
<!-- 为 ECharts 准备一个定义了宽高的 DOM -->
<div id="main" style="width: 100%;height:400px;"></div>
<script type="text/javascript">
//结算情况
var pie_info = echarts.init(document.getElementById('pie_info'));
pie_info.setOption({
title: [
{
text: '结算员合同计算情况',
left: 'left'
},
{
subtext: '张三',
left: '120px',
top: '245px',
textAlign: 'center'
},
{
subtext: '李四',
left: '350px',
top: '245px',
textAlign: 'center'
},
{
subtext: '张三',
left: '120px',
top: '475px',
textAlign: 'center'
},
{
subtext: '李四',
left: '350px',
top: '475px',
textAlign: 'center'
},
],
// tooltip: {
// trigger: 'item'
// },
legend: {
top: '20px',
left: 'left'
},
series: [
{
//name: '详细信息',
type: 'pie',
radius: '100px',
avoidLabelOverlap: false,
center: ['120px', '150px'],
itemStyle: {
borderRadius: 10,
borderColor: '#fff',
borderWidth: 2
},
label: {
show: false,
position: 'center'
},
emphasis: {
label: {
show: true,
fontSize: '15',
fontWeight: 'bold'
}
},
labelLine: {
show: false
},
label: {
normal: {
show: true,
//自定义显示格式(b:name, c:value, d:百分比)
formatter: '{b}:{c}' + '\n\r' + '({d}%)',
position: 'inner'
}
},
data: [
{ value: 300, name: '合同额' },
{ value: 500, name: '结算额' },
]
},
{
//name: '详细信息',
type: 'pie',
radius: '100px',
avoidLabelOverlap: false,
center: ['120px', '380px'],
itemStyle: {
borderRadius: 10,
borderColor: '#fff',
borderWidth: 2
},
label: {
show: false,
position: 'center'
},
emphasis: {
label: {
show: true,
fontSize: '15',
fontWeight: 'bold'
}
},
labelLine: {
show: false
},
label: {
normal: {
show: true,
//自定义显示格式(b:name, c:value, d:百分比)
formatter: '{b}:{c}' + '\n\r' + '({d}%)',
position: 'inner'
}
},
data: [
{ value: 300, name: '合同额' },
{ value: 500, name: '结算额' },
]
},
{
//name: '详细信息',
type: 'pie',
radius: '100px',
avoidLabelOverlap: false,
center: ['350px', '150px'],
itemStyle: {
borderRadius: 10,
borderColor: '#fff',
borderWidth: 2
},
label: {
show: false,
position: 'center'
},
emphasis: {
label: {
show: true,
fontSize: '15',
fontWeight: 'bold'
}
},
labelLine: {
show: false
},
label: {
normal: {
show: true,
//自定义显示格式(b:name, c:value, d:百分比)
formatter: '{b}:{c}' + '\n\r' + '({d}%)',
position: 'inner'
}
},
data: [
{ value: 800, name: '合同额' },
{ value: 600, name: '结算额' },
]
}
, {
//name: '详细信息',
type: 'pie',
radius: '100px',
avoidLabelOverlap: false,
center: ['350px', '380px'],
itemStyle: {
borderRadius: 10,
borderColor: '#fff',
borderWidth: 2
},
label: {
show: false,
position: 'center'
},
emphasis: {
label: {
show: true,
fontSize: '15',
fontWeight: 'bold'
}
},
labelLine: {
show: false
},
label: {
normal: {
show: true,
//自定义显示格式(b:name, c:value, d:百分比)
formatter: '{b}:{c}' + '\n\r' + '({d}%)',
position: 'inner'
}
},
data: [
{ value: 800, name: '合同额' },
{ value: 600, name: '结算额' },
]
}
]
});
//饼图
var pie = echarts.init(document.getElementById('pie'));
pie.setOption({
title: {
text: '饼图设计',
left: 'left'
},
// tooltip: {
// trigger: 'item'
// },
legend: {
top: '20px',
left: 'left'
},
series: [
{
//name: '详细信息',
type: 'pie',
radius: ['50%', '80%'],
avoidLabelOverlap: false,
center: ['50%', '50%'],
itemStyle: {
borderRadius: 10,
borderColor: '#fff',
borderWidth: 2
},
label: {
show: false,
position: 'center'
},
emphasis: {
label: {
show: true,
fontSize: '15',
fontWeight: 'bold'
}
},
labelLine: {
show: false
},
label: {
normal: {
show: true,
//自定义显示格式(b:name, c:value, d:百分比)
formatter: '{b}:{c}' + '\n\r' + '({d}%)',
position: 'inner'
}
},
data: [
{ value: 1048, name: '已结算' },
{ value: 735, name: '未结算' },
]
}
]
});
// 基于准备好的dom,初始化echarts实例
var myChart = echarts.init(document.getElementById('main'));
// 指定图表的配置项和数据
var option = {
title: {
text: 'ECharts 入门示例'
},
tooltip: {},
legend: {
data: ['销量']
},
xAxis: {
data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
},
yAxis: {},
series: [
{
name: '销量',
type: 'bar',
data: [5, 20, 36, 10, 10, 20]
}
]
};
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
</script>
</body>
</html>