效果图:
完整实现:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title></title>
</head>
<body>
<!-- 折线统计图 -->
<div class="row">
<div id="part6" style="width: 100%; height: 240px"></div>
</div>
</body>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts-gl/dist/echarts-gl.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts-stat/dist/ecStat.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts/dist/extension/dataTool.min.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts/map/js/china.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts/map/js/world.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts/dist/extension/bmap.min.js"></script>
<script type="text/javascript">
// 指定图表的配置项和数据
//第6部分
var dom6 = document.getElementById('part6')
var myChart6 = echarts.init(dom6)
var app6 = {}
option6 = null
option6 = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
//xy轴十字架指示数值背景区域色
label: {
backgroundColor: '#6a7985',
},
},
},
textStyle: {
color: '#466293',
},
legend: {
borderColor: ['#0090ff', '#464aff', '#ff605f', '#ffb746'],
data: ['租客分期', '装修贷', '房东贷', '周转贷'],
textStyle: {
color: '#8db0ef',
},
//图例标记与顶部标题的距离
top: 15,
},
//简单说grid是控制边距的
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true,
},
xAxis: [
{
type: 'category',
boundaryGap: false,
data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
axisLabel: {
show: true,
textStyle: {
//fontSize: 16,
color: '#466293',
fontFamily: 'DINProRegular',
},
},
axisTick: {
show: true,
lineStyle: {
color: '#00345c',
},
},
axisLine: {
show: true,
lineStyle: {
color: '#00345c',
},
},
},
],
yAxis: [
{
name: '(%)',
type: 'value',
min: 0,
max: 100,
interval: 20,
//y轴文字属性设置
axisLabel: {
textStyle: {
fontSize: 16,
color: '#466293',
fontFamily: 'DINProRegular',
},
formatter: '{value}',
},
//y轴横向分割线颜色
splitLine: {
show: true,
lineStyle: {
color: '#0c3668',
},
},
//y轴刻度线颜色
axisTick: {
show: false,
lineStyle: {
color: '#00345c',
},
},
//y轴边框颜色
axisLine: {
show: false,
lineStyle: {
color: '#00345c',
},
},
},
],
series: [
{
name: '租客分期',
type: 'line',
//如果不想折线那么尖锐,可以加上smooth: true变为柔和曲线
//smooth: true,
//stack: '总量',
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: 'rgba(0, 144, 255,0.7)',
},
{
offset: 1,
color: 'rgba(0, 144, 255,0)',
},
]),
},
lineStyle: {
color: '#0090ff',
},
data: [0, 0, 1.25, 7.9, 94.93, 17.65, 10.13, 13.17, 15.22, 15.22, 11.93, 5.5],
},
{
name: '装修贷',
type: 'line',
//smooth: true,
//如果想要y轴的数值不相加,就要去掉stack参数。否则数值就会相加。
//stack: '总量',
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: 'rgba(70, 74, 255,0.7)',
},
{
offset: 1,
color: 'rgba(70, 74, 255,0)',
},
]),
},
lineStyle: {
color: '#464aff',
},
data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
},
{
name: '房东贷',
type: 'line',
//smooth: true,
//stack: '总量',
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: 'rgba(255, 96, 95,0.7)',
},
{
offset: 1,
color: 'rgba(255, 96, 95,0)',
},
]),
},
lineStyle: {
color: '#ff605f',
},
data: [0, 0, 0, 0, 0, 62.5, 12.5, 0, 62.5, 37.5, 12.5, 0],
},
{
name: '周转贷',
type: 'line',
//smooth: true,
//stack: '总量',
areaStyle: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
{
offset: 0,
color: 'rgba(255, 183, 70,0.7)',
},
{
offset: 1,
color: 'rgba(255, 183, 70,0)',
},
]),
},
lineStyle: {
color: '#ffb746',
},
data: [0, 0, 0, 0, 66.67, 0, 0, 0, 0, 0, 66.67, 0],
},
],
}
if (option6 && typeof option6 === 'object') {
myChart6.setOption(option6, true)
}
</script>
</html>