效果:

代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!-- 引入 echarts.js -->
<script type="text/javascript" src="js/echarts.min.js"></script>
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<style>
div {
float: left;
}
</style>
</head>
<body>
<div id="data1" style="width: 600px;height:400px;"></div>
<div id="data2" style="width: 600px;height:400px;"></div>
<div id="data3" style="width: 600px;height:400px;"></div>
<div id="data4" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
var communityData = ['浪心社区', '上屋社区', '塘头社区', '官田社区', '水田社区', '龙腾社区', '应人石社区', '罗租社区', '石龙社区', '宝源社区'];
// 社区高频问题统计
var problem = ['粘贴小广告', '路面坑洼' ,'公益广告脱落'];
var problemData1 = [30, 40, 30, 22, 60,30, 40, 30, 22, 70];
var problemData2 = [20, 20, 20, 20, 10,20, 20, 20, 20, 10];
var problemData3 = [20, 20, 20, 24, 15,26, 26, 27, 27, 18];
var myChart1 = echarts.init(document.getElementById('data1'));
var option1 = {
backgroundColor: '#fff',
color: ['#20ACFF', '#50B862', '#FFBA33'],
barWidth: 13,
/*title: {
text: '社区高频问题统计',
subtext: '石岩街道数据'
},*/
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
legend: {
// left: '0%',
top: '15',
x:'right', //可设定图例在左、右、居中
textStyle: { //图例文字的样式
color: '#8C8C8C',
fontSize: 12
},
data: problem,
},
grid: {
left: '1%',
right: '1%',
bottom: '1%',
containLabel: true
},
xAxis: {
type: 'category',
splitLine: {
show: false // 去除网格线
},
axisLine: {
lineStyle: {
type: 'solid',
color: '#BFBFBF', // 坐标线的颜色
width: '1'
}
},
axisLabel: {
textStyle: {
color: '#000000' //坐标值的颜色
},
interval: 0,
},
boundaryGap: [0, 0.01],
data: communityData,
},
yAxis: {
type: 'value',
splitLine: {
show: true,
lineStyle:{
color: '#E8E8E8',
type: 'dashed' //设置间隔线为虚线
}
},
axisTick: {
show: false //小横线
},
splitArea: {
// show: true // 保留网格区域
},
axisLine: {
show: false, // 去除纵向边框线
lineStyle: {
type: 'solid',
color: '#BFBFBF', // 坐标线的颜色
width: '1'
}
},
axisLabel: {
textStyle: {
color: '#595959' //坐标值的颜色
}
}
},
series: [
{
name: problem[0],
type: 'bar',
label: {
show: true,
position: 'top', // 位置
/*formatter: '{a}\n{@c}',*/
formatter: '{@c}',
color: '#000000',
fontSize: 12,
fontWeight: 'normal', // 加粗
distance: 5, // 距离
offset: [0, 2] // 偏移距离[横向,纵向]
},
data: problemData1,
},
{
name: problem[1],
type: 'bar',
label: {
show: true,
position: 'top', // 位置
/*formatter: '{a}\n{@c}',*/
formatter: '{@c}',
color: '#000000',
fontSize: 12,
fontWeight: 'normal', // 加粗
distance: 5, // 距离
offset: [0, 2] // 偏移距离[横向,纵向]
},
data: problemData2,
},
{
name: problem[2],
type: 'bar',
label: {
show: true,
position: 'top', // 位置
/*formatter: '{a}\n{@c}',*/
formatter: '{@c}',
color: '#000000',
fontSize: 12,
fontWeight: 'normal', // 加粗
distance: 5, // 距离
offset: [0, 2] // 偏移距离[横向,纵向]
},
data: problemData3,
}
]
};
myChart1.setOption(option1);
// 问题分布统计
var questionData = [30, 40, 30, 22, 60,30, 40, 30, 22, 60];
var myChart2 = echarts.init(document.getElementById('data2'));
var option2 = {
backgroundColor: '#ffffff',
color: '#35ACFF',
barWidth: 15,
tooltip: {
trigger: 'item',
axisPointer: {
type: 'shadow'
}
},
grid: {
height: '100%',
left: '1%',
right: '1%',
bottom: '1%',
containLabel: true,
},
xAxis: {
show: false,
// type: 'category',
// type: 'value',
/*splitLine: {
show: false
},
axisLine: {
show: false,
lineStyle: {
type: 'solid',
color: '#BFBFBF',
width: '1'
}
},*/
/*axisLabel: {
textStyle: {
color: '#595959'
}
},*/
// boundaryGap: [0, 0.01],
// data: communityData,
},
yAxis: [{
// type: 'value',
type: 'category',
data: communityData,
splitLine: {
show: false,
lineStyle:{
color: '#E8E8E8',
type: 'dashed' // 设置间隔线为虚线
}
},
axisTick: {
show: false //小横线
},
axisLine: {
show: false,
lineStyle: {
type: 'solid',
color: '#BFBFBF', // 坐标线的颜色
width: '1'
}
},
axisLabel: {
textStyle: {
color: '#000000' //坐标值的颜色
},
interval: 0,
},
},{
type: 'value',
show: false,
min: 0,
max: 1000000,
splitLine: {
show: false,
},
axisTick: {
show: false //小横线
},
axisLine: {
show: false,
},
axisLabel: {
textStyle: {
color: '#000000' //坐标值的颜色
},
interval: 0,
},
}],
series: [
{
type: 'bar',
itemStyle: {
barBorderRadius: [10, 10, 10, 10] //控制柱状图的圆角显示弧度,(顺时针左上,右上,右下,左下)
},
label: {
show: true,
position: 'right',
color: '#000000',
fontSize: 12,
fontWeight: 'normal', // 加粗
distance: 5, // 距离
offset: [0, 0] // 偏移距离[横向,纵向]
},
data: questionData,
},
]
};
myChart2.setOption(option2);
// 办结情况统计
var myChart3 = echarts.init(document.getElementById('data3'));
var option3 = {
/*title: {
text: '办结情况'
},*/
tooltip: {
trigger: 'axis'
},
legend: {
/* top: '10',
x:'right',
icon: 'rect',
textStyle: {
color: '#8C8C8C',
fontSize: 12
},*/
data: ['按时办结率', '超时办结率']
},
grid: {
left: '1%',
right: '1%',
bottom: '1%',
containLabel: true
},
xAxis: {
type: 'category',
data: communityData,
axisLine: {
lineStyle: {
type: 'solid',
color: '#BFBFBF', // 坐标线的颜色
width: '1'
}
},
axisLabel: {
textStyle: {
color: '#000000' //坐标值的颜色
},
interval: 0,
},
boundaryGap: [0, 0.01],
},
yAxis: {
type: 'value',
splitLine: {
show: true,
lineStyle:{
color: '#E8E8E8',
type: 'dashed' //设置间隔线为虚线
}
},
axisTick: {
show: false //小横线
},
axisLine: {
show: false, // 去除纵向边框线
lineStyle: {
type: 'solid',
color: '#BFBFBF', // 坐标线的颜色
width: '1'
}
},
axisLabel: {
textStyle: {
color: '#595959',
},
formatter: '{value} %',
}
},
series: [{
name: '按时办结率',
type: 'line',
smooth: true,
lineStyle: {
width: 4
},
label : {
show: true,
position: 'top',
formatter: '{c} %',
fontSize: 13,
fontWeight: 'normal',
color: '#000000',
},
data: [65, 85, 87, 75, 83, 89, 85, 86, 86, 75]
},
{
name: '超时办结率',
type: 'line',
smooth: true,
lineStyle: {
width: 4
},
label : {
show: true,
position: 'top',
formatter: '{c} %',
fontSize: 13,
fontWeight: 'normal',
color: '#000000',
},
data: [35, 15, 13, 25, 17, 11, 15, 14, 14, 25]
}]
};
myChart3.setOption(option3);
// 问题占比统计
var myChart4 = echarts.init(document.getElementById('data4'));
var option4 = {
tooltip: {
trigger: 'item',
formatter: " {b} <br/>共{c}个,占比{d}%",
},
legend: {
orient: 'vertical',
left:'85%',
align:'left',
top:'middle',
itemWidth: 20,
itemHeight: 10,
itemGap: 30,
data: ['粘贴小广告','路面坑洼','公益广告脱落','建筑物倒塌','垃圾可见','其它问题'],
},
series: [
{
name: '面积模式',
type: 'pie',
radius: [25, 125],
center: ['50%', '50%'],
// color:['#2E46FF','#537BFF','#53BCFE','#00FFFF','#20D667','#FF8D46','#FFF146','#FD5959',''],//饼图自定义颜色
roseType: 'area',
itemStyle: {
borderRadius: 8
},
label:{
formatter:" {b} \n{c}个,{d}%",
color: '#000000',
fontSize: 12,
backgroundColor: '#F2F2F2',
padding: [10, 10, 10, 10]
},
data: [
{value: 60, name: '粘贴小广告'},
{value: 50, name: '路面坑洼'},
{value: 40, name: '公益广告脱落'},
{value: 30, name: '建筑物倒塌'},
{value: 20, name: '垃圾可见'},
{value: 10, name: '其它问题'},
]
}
]
};
myChart4.setOption(option4);
</script>
</body>
</html>