Toggle navigation
双折线
By
b***n
2019-11-29 04:49:48
脚本
16
21
作品使用的第三方脚本
数据管理
上传数据
支持小于 5M 任意格式(csv, xlsx, json, xml, ...)的数据文件
上传后可以通过生成的文件链接异步获取托管的数据。
历史数据
0 条
无历史数据
代码修改记录
信息提示
保存作品
对当前截图不满意?你还可以
上传本地截图
重新截图
作品名称
作品描述
标签
geo
grid
legend
markLine
markPoint
bar
effectScatter
line
lines
map
timeline
title
toolbox
tooltip
visualMap
作品默认版本
最新
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
20:11:45
图表已生成
整理代码
刷新
代码
//声明数据 var dataTime = [0, 1, 3, 5, 10, 15, 20, 22, 25]; //间隔天数 = 接收日期 - 告知日期 var data1 = [150, 170, 220, 495, 290, 210, 180, 160, 158], data2 = [140, 150, 160, 180, 220, 288, 435, 200, 140]; var data3 = []; /*取到的数组应为比较之后的较大值 [170, 220, 495, 290, 188, 435, 200, 158]*/ for (var i = 0; i < data1.length || i < data2.length; i++) { var _d1 = data1[i], _d2 = data2[i]; if (_d1 > _d2) { data3.push(data1[i]) } else { data3.push(data2[i]) } console.log(data3) } //初始化echarts option = { backgroundColor: '#191b4b', //背景色 title: { show: false }, tooltip: { trigger: 'axis', //item formatter: function(params) { var res = '间隔' + params[0].name + '天
'; for (var i = 0, l = params.length - 1; i < l; i++) { //console.log(params) res += '
' + params[i].seriesName + ' ' + params[i].value + '
'; } return res; }, axisPointer: { type: 'line', //'line' | 'cross' | 'shadow' | 'none lineStyle: { color: 'rgba(255, 255, 255, .5)', width: 2, type: 'solid' } }, confine: 'true' //是否将 tooltip 框限制在图表的区域内 }, legend: { show: false, selectedMode: true, itemWidth: 12, itemHeight: 10, itemGap: 20, textStyle: { fontSize: 16, color: 'white' }, x: 'center', y: 'top' }, grid: { top: '11%', left: '9%', right: '10%', bottom: '11%', }, toolbox: { show: false }, xAxis: { type: 'category', name: '\n\n天数', nameTextStyle: { color: '#8aa5ab', fontSize: 15 }, nameLocation: "end", //坐标轴名称显示位置,可选: start | middle | end boundaryGap: true, //边界间隙 axisLabel: { show: true, textStyle: { color: '#8aa5ab', fontSize: 15 }, formatter: '{value}' }, axisLine: { lineStyle: { color: 'rgba(255, 255, 255, .5)' } }, axisTick: { show: false //坐标轴小标记 }, data: dataTime, }, yAxis: { type: 'value', axisLabel: { show: true, textStyle: { color: 'white', fontSize: 15 }, margin: 10, formatter: '{value}' }, axisLine: { //y轴线 show: true, lineStyle: { color: 'rgba(255, 255, 255, .5)' } }, axisTick: { show: false //坐标轴小标记 }, splitLine: { show: true, lineStyle: { color: 'rgba(72, 81, 119, .5)', //横向网格线颜色 width: 1, type: 'solid' } } }, series: [{ name: '接收', type: 'line', smooth: true, symbol: 'circle', symbolSize: 5, lineStyle: { normal: { width: 5, color: '#00b0f0' //曲线颜色 } }, itemStyle: { normal: { color: '#00b0f0', label: { show: false } } }, data: data1, //载入数据 markPoint: { //设置最高点的显示内容 symbol: 'path://M5.500,0.500 C8.261,0.500 10.500,2.739 10.500,5.500 C10.500,8.261 8.261,10.500 5.500,10.500 C2.739,10.500 0.500,8.261 0.500,5.500 C0.500,2.739 2.739,0.500 5.500,0.500 Z', //'circle', 'rect', 'roundRect' symbolSize: 12, //symbolOffset:[0, 0], itemStyle: { color: 'white' }, label: { show: true, offset: [65, 1], color: '#fff', fontSize: 15, formatter: function(params) { //console.log(params) var res = params.data.text return res; } }, data: [{ type: 'max', name: '最大值', text: '接收' }] } }, { name: '反馈', type: 'line', smooth: true, symbol: 'circle', symbolSize: 5, lineStyle: { normal: { width: 5, color: '#01f274' //曲线颜色 } }, itemStyle: { normal: { color: '#01f274', label: { show: false } } }, data: data2, //载入数据 markPoint: { //设置最高点的显示内容 symbol: 'path://M5.500,0.500 C8.261,0.500 10.500,2.739 10.500,5.500 C10.500,8.261 8.261,10.500 5.500,10.500 C2.739,10.500 0.500,8.261 0.500,5.500 C0.500,2.739 2.739,0.500 5.500,0.500 Z', symbolSize: 12, itemStyle: { color: 'white' }, label: { show: true, offset: [65, 1], color: '#fff', fontSize: 15, formatter: function(params) { var res = params.data.text return res; } }, data: [{ type: 'max', name: '最大值', text: '反馈' }] } }, { type: 'pictorialBar', data: data3, //载入白色虚线数据(比较之后得出的数组) barGap: "10%", symbolRepeat: true, symbolMargin: 2, silent: true, symbol: "rect", symbolSize: 2, symbolClip: true, itemStyle: { normal: { color: 'rgba(255, 255, 255, .7)', label: { show: false } } } }] }; //使用刚指定的配置项和数据显示图表。 myChart.setOption(option);