【Echarts】echarts渐变重叠立体柱形图

echarts渐变重叠立体柱形图在这里插入图片描述

echarts随意一个示例代码
直接点击上方链接↑↑↑将此段代码放到echarts的示例代码编辑框里:

var xData2 = ['x1']
      var data1 = [50]
      var data2 = [50]
      var dataAdd = data2.map((item, index) => {return item + data1[index]})
      
option = {
        grid: {
          left: 0,
          bottom: 15,
          top: '10%',
          right: 80
        },
        xAxis: {
          data: xData2,
          axisTick: {
            show: false
          },
          axisLine: {
            show: false
          },
          axisLabel: {
            show: false
          }
        },
        yAxis: {
          splitLine: {
            show: false
          },
          axisTick: {
            show: false
          },
          axisLine: {
            show: false
          },
          axisLabel: {
            // textStyle: {
            //     color: '#fff',
            //     fontSize: 20,
            // },
            // 不显示Y轴数值
            formatter: function() {
              return ''
            }
          }
        },
        series: [
          {
            name: '0',
            type: 'pictorialBar',
            symbolSize: [41, 15],
            symbolOffset: [0, 8],
            z: 0,
            symbol: 'diamond',
            itemStyle: {
              opacity: 1,
              color: function(params) {
                return new echarts.graphic.LinearGradient(
                  1,
                  // 深色#2BA9ED 浅色 #34EDF2
                  0,
                  0,
                  0,
                  [
                    {
                      offset: 0,
                      color: '#E1DC53' // 0% 处的颜色
                    },
                    {
                      offset: 1,
                      color: '#E1DC53' // 100% 处的颜色
                    }
                  ],
                  false
                )
              }
              // color: 'transparent'
            },
            data: [1]
          },
          // 数据的柱状图1
          {
            name: '1',
            type: 'bar',
            barWidth: 41,
            z: 1,
            stack: 'Search Engine',
            itemStyle: {
              // lenged文本
              opacity: 1, // 这个是 透明度
              color: function(params) {
                return new echarts.graphic.LinearGradient(
                  0,
                  1,
                  0,
                  0,
                  [
                    {
                      offset: 0,
                      color: '#E1DC53' // 0% 处的颜色
                    },
                    {
                      offset: 1,
                      color: '#E8AE62' // 100% 处的颜色
                    }
                  ],
                  false
                )
              }
            },
            data: data1
          },
          // 数据顶部的样式
          {
            name: '2',
            type: 'pictorialBar',
            symbol: 'diamond',
            symbolSize: [41, 15],
            symbolOffset: [0, -8],
            z: 2,
            itemStyle: {
              normal: {
                opacity: 1,
                color: '#000', // 100% 处的颜色
                label: {
                  show: true, // 开启显示
                  position: 'top', // 在上方显示
                  textStyle: {
                    // 数值样式
                    color: '#FFFFFF',
                    fontSize: 20,
                    top: 50
                  },
                  formatter: function(param) {
                    return param.data + '%'
                  }
                }
              }
            },
            symbolPosition: 'end',
            data: data1
          },
          // 数据的柱状图2
          {
            name: 'Google',
            type: 'bar',
            z: 2,
            stack: 'Search Engine',
            emphasis: {
              focus: 'series'
            },
            itemStyle: {
              // lenged文本
              opacity: 1, // 这个是 透明度
              color: function(params) {
                return new echarts.graphic.LinearGradient(
                  0,
                  1,
                  0,
                  0,
                  [
                    {
                      offset: 0,
                      color: '#000' // 0% 处的颜色
                    },
                    {
                      offset: 1,
                      color: '#fff' // 100% 处的颜色
                    }
                  ],
                  false
                )
              }
            },
            data: data2
          },
          // 阴影的顶部
          {
            name: '', // 头部
            type: 'pictorialBar',
            symbol: 'diamond',
            symbolSize: [41, 15],
            symbolOffset: [0, -8],
            z: 12,
            symbolPosition: 'end',
            itemStyle: {
              normal: {
                opacity: 1,
                color: function(params) {
                  return new echarts.graphic.LinearGradient(
                    0,
                    0,
                    1,
                    0,
                    [
                      {
                        offset: 0,
                        color: '#000' // 0% 处的颜色
                      },
                      {
                        offset: 1,
                        color: '#fff' // 100% 处的颜色
                      }
                    ],
                    false
                  )
                },
                label: {
                  show: true, // 开启显示
                  position: 'top', // 在上方显示
                  textStyle: {
                    // 数值样式
                    color: '#FFFFFF',
                    fontSize: 20,
                    top: 50
                  },
                  formatter: function(param) {
                    return param.data + '%'
                  }
                }
              }
            },
            data: dataAdd
          },
        ]
      }
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ECharts 是一个基于 JavaScript 的开源可视化库,它可以用于制作各种类型的图表,包括立体柱形图立体柱形图是一种三维图表,它可以展示数据在三个方向上的变化情况,通过不同的高度来表示数据的大小。 在 ECharts 中制作立体柱形图,需要使用柱形图和三维坐标系两个组件。柱形图组件用于绘制柱形,而三维坐标系组件则负责展示立体效果。 下面是一个简单的立体柱形图的配置示例: ``` option = { tooltip: {}, visualMap: { max: 20, inRange: { color: ['#50a3ba', '#eac736', '#d94e5d'] } }, xAxis3D: { type: 'category', data: ['A', 'B', 'C', 'D', 'E'] }, yAxis3D: { type: 'value' }, zAxis3D: { type: 'category', data: ['2019', '2020', '2021'] }, grid3D: { boxWidth: 200, boxDepth: 80, viewControl: { distance: 300 }, light: { main: { intensity: 1.2, shadow: true }, ambient: { intensity: 0.3 } } }, series: [{ type: 'bar3D', data: [ ['A', 0, '2019', 10], ['B', 1, '2019', 15], ['C', 2, '2019', 13], ['D', 3, '2019', 17], ['E', 4, '2019', 12], ['A', 0, '2020', 7], ['B', 1, '2020', 9], ['C', 2, '2020', 11], ['D', 3, '2020', 15], ['E', 4, '2020', 8], ['A', 0, '2021', 12], ['B', 1, '2021', 8], ['C', 2, '2021', 14], ['D', 3, '2021', 10], ['E', 4, '2021', 15] ], shading: 'lambert', label: { textStyle: { fontSize: 16, borderWidth: 1 } }, itemStyle: { opacity: 0.8 } }] }; ``` 以上代码中,我们定义了一个三维坐标系和一个柱形图柱形图的数据包括横轴、纵轴和高度,通过 series.type 属性指定为 bar3D 类型。grid3D 中定义了一些参数用于控制立体效果的显示,包括箱子的宽度和深度,视角距离和光照等。在页面中引入 echarts.min.js 文件后,可以通过调用 echarts.init() 方法和 setOption() 方法将配置应用到图表中。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值