Toggle navigation
自定义堆叠图
By
断***1
2020-10-29 06:55:19
脚本
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
图表已生成
整理代码
刷新
代码
let maxSeries = [97.26, 97.08, 97.67, 97.83, 97.65, 97.75] let otherSeries =[[0.47, 0.63, 0.59, 0.53, 0.55, 0.56], [0.31, 0.30, 0.32, 0.34, 0.35, 0.37], [1.53, 1.59, 1.04, 0.92, 1.03, 0.91], [0.43, 0.40, 0.38, 0.38, 0.41, 0.41]] let sumOtherSeries = otherSeries.reduce((a, b) => { a = a.map((item, index) => { return (a[index] *100 + b[index]* 100)/100 }) return a; }) let maxSumOtherSeriesSingle = Math.max.apply(null, sumOtherSeries); let minmaxSeriesSingle =Math.min.apply(null, maxSeries); // 被减数 // 公式 y= x -a 的方式平移 let minuend = 0 if(Number(minmaxSeriesSingle) > Number(maxSumOtherSeriesSingle)) { minuend = (Number(minmaxSeriesSingle)*100 - Number(maxSumOtherSeriesSingle)*100)/100; console.log(maxSumOtherSeriesSingle, 'maxSumOtherSeriesSingle') console.log(minuend, 'minuend1') minuend = Math.floor(minuend) console.log(minuend, 'minuend2') } let max = (Number(Math.max.apply(null, maxSeries)) *100 - Number(minuend) *100 + Number(maxSumOtherSeriesSingle) *100)/100; max = parseInt(max) // 判断整个序列最大值 考虑到最大值的情况有可能取整少1 let allMaxSeries = sumOtherSeries.map((item, index) => { return (item *100 + maxSeries[index]* 100)/100 }) let allMaxSingle = Math.max.apply(null, allMaxSeries) if((Number(allMaxSingle) *100 - minuend *100)/100 > max) { max = parseInt(allMaxSingle) + 1; } // 处理最大列数据 let computemaxSeries= maxSeries.map(item => item = (item *100 - minuend *100)/100) option = { title: { text: '堆叠区域图' }, tooltip: { trigger: 'axis', axisPointer: { type: 'cross', label: { backgroundColor: '#6a7985' } }, }, legend: { data: ['正常占比', '次级占比', '损失类占比', '关注类占比', '可疑类占比'] }, toolbox: { feature: { saveAsImage: {} } }, grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true }, xAxis: [ { type: 'category', boundaryGap: false, data: ['2020年3月', '2020年2月', '2020年1月', '2019年12月', '2019年11月', '2019年10月'] } ], yAxis: [ { type: 'value', max: max, min:0, splitNumber: 5, axisLabel: { formatter: function(value) { if(value > maxSumOtherSeriesSingle){ return (Number(value)*100 +Number(minuend)*100)/100 } return value } } } ], series: [ { name: '损失类占比', type: 'line', stack: '总量', areaStyle: {}, data: [0.47, 0.63, 0.59, 0.53, 0.55, 0.56] }, { name: '次级占比', type: 'line', stack: '总量', areaStyle: {}, data: [0.31, 0.30, 0.32, 0.34, 0.35, 0.37] }, { name: '关注类占比', type: 'line', stack: '总量', areaStyle: {}, data: [1.53, 1.59, 1.04, 0.92, 1.03, 0.91] }, { name: '可疑类占比', type: 'line', stack: '总量', areaStyle: {}, data: [0.43, 0.40, 0.38, 0.38, 0.41, 0.41] }, { name: '正常占比', type: 'line', stack: '总量', areaStyle: {}, data: computemaxSeries } ] };