Toggle navigation
销售金额省份对比
By
q***6
2021-01-21 06:47:55
脚本
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 data={ Amount:["54300.00","54014.00","50034.00","50034.00","50034.00","24004.00","14334.00"], Province:['贵州','山东','湖南','黑龙江','河南','辽宁省','北京'] }; //初始化数据 var category = []; var barData = []; var length1 = 7; if (data.Amount.length <= 7) { length1 = data.Amount.length; } for (var i = 0; i < length1; i++) { barData.push(data.Amount[length1 - i - 1]) } for (var i = 0; i < length1; i++) { category.push(data.Province[length1 - i - 1]) } var yMax = 54300; var dataShadow = []; for (var i = 0; i < barData.length; i++) { dataShadow.push(yMax) } let colorList1 = ['#07eef2', '#ebe485', '#ef7e14', '#42dc8b']; var option = { backgroundColor:'#00033A', tooltip: { trigger: "axis", axisPointer: { // 坐标轴指示器,坐标轴触发有效 type: "shadow" // 默认为直线,可选为:'line' | 'shadow' } }, grid: { left: "2%", right: "8%", bottom: "10%", top: '10%', //去掉标题,图表整体往上移动 containLabel: true }, xAxis: { type: "value", show: false,//直接设置show|的属性的话x轴的轴线和垂直于它的网格线以及x轴数据会一起显示隐藏,这里需要全部隐藏包括所以直接show,如果需要单独给它们设置显示隐藏详见以下设置 bottom: 2, boundaryGap: ['0%', '1%'],//留白大小,坐标轴1边留白,横向柱状图的右侧label**人不会超出宽度被隐藏 }, yAxis: { boundaryGap: ['0%', '1%'],//留白大小,坐标轴1边留白 axisLabel: { fontSize: 15, color: '#05CCCA', interval: 0, //margin: 95, margin: 15, textStyle: { position: 'topLeft', }, show: false, }, type: "category", data: category, axisTick: { //y轴刻度线 show: false }, axisLine: {//y轴轴线 show: false } }, series: [ { // For shadow name: '最大销售金额', type: 'bar', itemStyle: { normal: { barBorderRadius: 40, color: function (params) { let colorList = ['#002d52', '#292a38', '#28172a', '#0b283f', '#1d074a', '#311535', '#050d4e']; return colorList[params.dataIndex]; } }, emphasis: { barBorderRadius: 40 }, }, barGap: '-100%', barCategoryGap: '50%', // barCategoryGap:'40%', data: dataShadow, animation: true, barWidth: 15, label: { formatter: function (param) { for (let i = 0; i < barData.length; i++) { if (param.dataIndex == i) { return barData[i] + "元"; } } }, right: '3%', show: true, textStyle: { fontWeight: 400, fontSize: 14, color: "#069AE6" }, position: "right" }, }, { name: "销售金额", top: 20, color: "#00A6FC", type: "bar", stack: "总量", barCategoryGap: 2, itemStyle: { //通常情况下: normal: { barBorderRadius: 8, //每个柱子的颜色即为colorList数组里的每一项,如果柱子数目多于colorList的长度,则柱子颜色循环使用该数组 color: function (params) { var colorList = [ ['#18579e', '#07eef2'], ['#77633c', '#ebe485'], ['#815529', '#ef7e14'], ['#0d3247', '#42dc8b'], ['#551384', '#810dfc'], ['#734040', '#fb7070'], ['#131d54', '#0141fa'], ]; var index = params.dataIndex; if (params.dataIndex >= colorList.length) { index = params.dataIndex; } return new echarts.graphic.LinearGradient(1, 0, 0, 0, [{ offset: 0, color: colorList[index][1] }, { offset: 1, color: colorList[index][0] } ]); } }, }, label: { formatter: function (param) { for (let i = 0; i < category.length; i++) { if (param.dataIndex == i) { return category[i]; } } }, right: '3%', show: true, offset: [4, -17], textStyle: { fontWeight: 400, fontSize: 15, color: "#4984d5", }, position: "topLeft" }, //设置柱的宽度 barWidth: 15, // height:'70%', data: barData }] }