Toggle navigation
测量数据统计
By
眉***藏
2020-12-04 10:05:01
脚本
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
图表已生成
整理代码
刷新
代码
const mock = [{ k: '测量总次数', v: [{ k: '测量总次数', v: 120 }], }, { k: '自动上传次数', v: [{ k: '自动上传次数', v: 80 }], }, { k: '手动上传次数', v: [{ k: '手动上传次数', v: 80 }], }, { k: '测量人数', v: [{ k: '测量人数', v: 80 }], } ] var colorList=['#6227E6','#0D6DD8','#E449B3','#0C7E38']; var colorList2=['#6995F0','#63E6EF','#FC7CDC','#1BC85E']; // 横轴数据 const xAxis = mock.map(item => item.k) // 系列 1 数据 (类目1) const seriesData1 = mock.map(item => item.v[0].v) // 最大值 (额外拉高多少根据数据数量级决定) const max = Math.max(...seriesData1) + 10 // 构造柱最大值数组 const maxList = [] for (let i = 0; i < mock.length; i += 1) { maxList.push(max) } option = { backgroundColor: '#081d5f', title: { text: '测量数据统计', textStyle: { fontSize: 22, fontWeight: 400, color:'#fff' }, left: '0%', top: '0%' }, series: [ { // 该系列为背景深蓝色半胶囊 data: maxList, type: 'bar', xAxisIndex: 0, silent: true, label: { normal: { show: true, position: 'top', formatter:function(params){ return seriesData1[params.dataIndex] }, fontSize: 20, color: "#688DEF" } }, itemStyle: { color: '#334fba', barBorderRadius: [20, 20, 20, 20], }, barWidth: 30, tooltip: { show: false, }, }, { data: seriesData1, type: 'bar', xAxisIndex: 1, itemStyle: { barBorderRadius: 25, color: function(params){ console.log(colorList[params.dataIndex]) return new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 1, color: colorList[params.dataIndex] // 100% 处的颜色 }, { offset: 0.3, color: colorList2[params.dataIndex]// 0% 处的颜色 }], false)} }, barWidth: 30, }, ], dataZoom: { type: 'inside', xAxisIndex: [0, 1], }, tooltip: { trigger: 'axis', axisPointer: { type: 'shadow', }, }, xAxis: [{ data: maxList, axisLine: { show: false, }, axisLabel: { show: false, }, axisTick: { show: false, }, position: 'bottom', }, { data: xAxis, axisLine: { show: false, }, axisLabel: { color: '#fff', }, axisTick: { show: false, }, position: 'bottom', }, ], yAxis: { axisLine: { show: false, }, axisLabel: { color: '#fff', }, axisTick: { show: false, }, splitLine: { show: false, }, }, }