option = { // 标题组件,包含主标题和副标题。 title: { id: 'line-chart', show: true, text: '折线图标题', textStyle: { color: '#fff' }, subtext: '副标题副标题', subtextStyle: { color: '#eee' }, left: 'center',//标题位置 top: '20'//标题位置 }, // 图例组件 legend: { type: 'plain',//plain:普通图例;scroll:可滚动翻页的图例。当图例数量较多时使。 show: true, bottom: '50', left: 'center', // 图例图形中线的样式 lineStyle: { color: '#fff' }, // 图例的公用文本样式 textStyle: { color: '#fff' } }, // 直角坐标系内绘图网格 grid: { show: false,//是否显示直角坐标系网格,外边框 top: '10%',//离容器左侧的距离 right: '50',//离容器上侧的距离 left: '20',//离容器左侧的距离 bottom: '12%',//离容器底部的距离 borderColor: '#ff0',//外边框颜色 containLabel: true,//是否包含坐标轴的刻度标签,默认为false;true时防止标签溢出 }, // 提示框组件 tooltip: { trigger: 'axis',//触发类型,axis:坐标轴触发 axisPointer: {//坐标轴指示器配置项 type: 'shadow'//指示器类型:line、shadow、none、cross }, backgroundColor: 'rgba(50,50,50,0.7)',//提示框浮层的背景颜色 borderColor: '#fff',//提示框浮层的边框颜色 textStyle: { color: '#fff', fontSize: '15' }, // 折线图:{a}(系列名称) {b}(x轴的值),{c}(y轴的值) formatter: '{b0}:<br />{a0}:{c0}人'//1.字符串模板 // formatter:function(params){ //2.回调函数,可return dom 自定义样式 // console.log('params',params) // return params[0].name // } }, //图表背景色 backgroundColor: '#081736', // x 轴设置 xAxis: [{ type: 'category', name: '村落',//X轴名称 nameLocation: 'end',//X轴名称位置 nameTextStyle: {//X轴名称样式 color: '#fff', fontWeight: 'bold' }, nameGap: 10,//X轴名称与轴线之间的距离 nameRotate: 45,//坐标轴名称旋转 axisLabel: {//X轴类目名称样式 color: '#fff', rotate: 30 //X轴类目名称旋转角度 }, axisLine: { //X轴轴线设置 show: true, lineStyle: { color: '#fff', width: 2 }, }, axisTick: {//X轴刻度相关设置 show: false, }, splitLine: {// 横向分隔线 show: true, lineStyle: { color: '#195384', type: "dotted", } }, // 类目数据 data: ['博雅社区', '曹家村', '大草坝村', '杜家漕村', '黄家村', '栗子园村', '廉家庄村', '吕家村', '马家店村', '庙坡村', '石家庄村', '五郎庙村', '小东关社区', '小西关村', '谢家井社区', '胥水村', '翟家寺村'] }], // y轴设置 yAxis: [ { type: 'value', position: 'left', name: "人数", nameTextStyle: { color: "#fff", fontSize: 12, fontWeight: 'bold' }, min: 0,//坐标轴刻度最小值 minInterval: 10,//坐标轴最小间隔大小 axisLine: {//y轴轴线设置 show: true, lineStyle: { color: '#fff', width: 2 } }, axisLabel: {//y轴刻度标签 formatter: '{value}', inside: false,//刻度标签是否朝内,默认朝外 textStyle: { color: "#fff", } }, axisTick: {//刻度设置 show: false, }, splitLine: {//纵向分隔线 show: true, lineStyle: { color: '#0a3e98', type: "dotted", } }, } ], series: [ { name: '外出人数',//系列名称 type: 'line', smooth: true, //是否平滑 showAllSymbol: true, // symbol: 'image://http://example.website/a/b.png',//自定义图片 symbol: 'roundRect', symbolSize: 6, lineStyle: {//线条样式 normal: { color: "#7F4CEF", }, }, label: {//图形上的文本标签 show: true, position: 'top', textStyle: { color: '#fff', } }, itemStyle: {//折线拐点标志的样式 color: "#fff", borderColor: "#7F4CEF", borderWidth: 2, }, areaStyle: {//区域填充样式 color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: 'RGBA(127, 76, 239, 1)' }, { offset: 1, color: 'RGBA(127, 76, 239, 0.2)' } ], false), shadowColor: 'RGBA(80, 38, 72, 0.2)', shadowBlur: 20 }, // 具体数据 data: [13, 17, 22, 25, 36, 71, 18, 94, 10, 37, 45, 46, 53, 61, 71, 83, 92] } ], // 滑动条型数据区域缩放组件 dataZoom: [ { type: 'slider', start: 0,//数据窗口范围的起始百分比 end: 100//数据窗口范围的结束百分比 }, ], };