• Echarts-实现3D柱状图


    效果图显示

    在这里插入图片描述

    代码如下

    可分为3部分。顶部小菱形,中部普通2维柱子,底部小三角

    DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="UTF-8" />
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <script
          type="text/javascript"
          src="https://cdn.jsdelivr.net/npm/echarts@5/dist/echarts.min.js"
        >script>
        <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js">script>
        <title>Documenttitle>
      head>
      <body>
        <div id="main" style="width: 350px; height: 400px">div>
        <script>
          var myChart = echarts.init(document.getElementById('main'))
          var option = {
            xAxis: {
              type: 'category',
              data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
            },
            yAxis: {
              type: 'value',
            },
            series: [
              // 顶部小菱形
              {
                type: 'pictorialBar',
                name: 'pictorial element',
                z: 10,
                data: [
                  {
                    value: 60,
                    symbol: 'diamond',
                    symbolOffset: [0, '-50%'],
                    symbolPosition: 'end', //图形边缘与柱子结束的地方内切
                    symbolSize: ['-90%', 30], //根据柱子大小来做调整
                    itemStyle: {
                      normal: {
                        color: '#FEE47B',
                      },
                    },
                  },
                  {
                    value: 26,
                    symbol: 'diamond',
                    symbolOffset: [0, '-50%'],
                    symbolPosition: 'end', //图形边缘与柱子结束的地方内切
                    symbolSize: ['-95%', 30], //根据柱子大小来做调整
                    itemStyle: {
                      normal: {
                        color: '#FEE47B',
                      },
                    },
                  },
                  {
                    value: 58,
                    symbol: 'diamond',
                    symbolOffset: [0, '-50%'],
                    symbolPosition: 'end', //图形边缘与柱子结束的地方内切
                    symbolSize: ['-95%', 30], //根据柱子大小来做调整
                    itemStyle: {
                      normal: {
                        color: '#FEE47B',
                      },
                    },
                  },
                  {
                    value: 43,
                    symbol: 'diamond',
                    symbolOffset: [0, '-50%'],
                    symbolPosition: 'end', //图形边缘与柱子结束的地方内切
                    symbolSize: ['-95%', 30], //根据柱子大小来做调整
                    itemStyle: {
                      normal: {
                        color: '#FEE47B',
                      },
                    },
                  },
                  {
                    value: 89,
                    symbol: 'diamond',
                    symbolOffset: [0, '-50%'],
                    symbolPosition: 'end', //图形边缘与柱子结束的地方内切
                    symbolSize: ['-95%', 30], //根据柱子大小来做调整
                    itemStyle: {
                      normal: {
                        color: '#FEE47B',
                      },
                    },
                  },
                ],
              },
              // 柱子数据
              {
                type: 'bar',
                name: 'reference bar',
                barGap: '-100%',
                barWidth: 20,
                // symbol: 'image://' + params.picture, // 图片
                symbolOffset: [0, 0],
                z: 2,
                itemStyle: {
                  // 渐变
                  color: {
                    x: 1,
                    y: 0,
                    x2: 0,
                    y2: 0,
                    type: 'linear',
                    global: false,
                    colorStops: [
                      { offset: 0, color: '#bd530a' },
                      { offset: 0.5, color: '#bd530a' },
                      { offset: 0.5, color: '#ca7e06' },
                      { offset: 1, color: '#ca7e06' },
                    ],
                  },
                },
                data: [60, 26, 58, 43, 89],
              },
              // 底部三角形
              {
                type: 'pictorialBar',
                name: 'joy',
                barGap: '-100%',
                z: 3,
                barWidth: 20,
                data: [
                  {
                    value: 10,
                    symbol: 'triangle',
                    symbolOffset: [0, 20],
                    symbolSize: ['-100%', 20],
                    symbolRotate: 180,
                    itemStyle: {
                      color: {
                        x: 1,
                        y: 0,
                        x2: 0,
                        y2: 0,
                        type: 'linear',
                        global: false,
                        colorStops: [
                          { offset: 0, color: '#bd530a' },
                          { offset: 0.5, color: '#bd530a' },
                          { offset: 0.5, color: '#ca7e06' },
                          { offset: 1, color: '#ca7e06' },
                        ],
                      },
                    },
                  },
                  {
                    value: 10,
                    symbol: 'triangle',
                    symbolOffset: [0, 20],
                    symbolSize: ['-100%', 20],
                    symbolRotate: 180,
                    itemStyle: {
                      color: {
                        x: 1,
                        y: 0,
                        x2: 0,
                        y2: 0,
                        type: 'linear',
                        global: false,
                        colorStops: [
                          { offset: 0, color: '#bd530a' },
                          { offset: 0.5, color: '#bd530a' },
                          { offset: 0.5, color: '#ca7e06' },
                          { offset: 1, color: '#ca7e06' },
                        ],
                      },
                    },
                  },
                  {
                    value: 10,
                    symbol: 'triangle',
                    symbolOffset: [0, 20],
                    symbolSize: ['-100%', 20],
                    symbolRotate: 180,
                    itemStyle: {
                      color: {
                        x: 1,
                        y: 0,
                        x2: 0,
                        y2: 0,
                        type: 'linear',
                        global: false,
                        colorStops: [
                          { offset: 0, color: '#bd530a' },
                          { offset: 0.5, color: '#bd530a' },
                          { offset: 0.5, color: '#ca7e06' },
                          { offset: 1, color: '#ca7e06' },
                        ],
                      },
                    },
                  },
                  {
                    value: 10,
                    symbol: 'triangle',
                    symbolOffset: [0, 20],
                    symbolSize: ['-100%', 20],
                    symbolRotate: 180,
                    itemStyle: {
                      color: {
                        x: 1,
                        y: 0,
                        x2: 0,
                        y2: 0,
                        type: 'linear',
                        global: false,
                        colorStops: [
                          { offset: 0, color: '#bd530a' },
                          { offset: 0.5, color: '#bd530a' },
                          { offset: 0.5, color: '#ca7e06' },
                          { offset: 1, color: '#ca7e06' },
                        ],
                      },
                    },
                  },
                  {
                    value: 10,
                    symbol: 'triangle',
                    symbolOffset: [0, 20],
                    symbolSize: ['-100%', 20],
                    symbolRotate: 180,
                    itemStyle: {
                      color: {
                        x: 1,
                        y: 0,
                        x2: 0,
                        y2: 0,
                        type: 'linear',
                        global: false,
                        colorStops: [
                          { offset: 0, color: '#bd530a' },
                          { offset: 0.5, color: '#bd530a' },
                          { offset: 0.5, color: '#ca7e06' },
                          { offset: 1, color: '#ca7e06' },
                        ],
                      },
                    },
                  },
                ],
              },
            ],
          }
          myChart.setOption(option)
        script>
      body>
    html>
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249
    • 250
    • 251
    • 252
    • 253
    • 254
  • 相关阅读:
    AWS制作WordPress在国内外的利弊?
    echarts柱状图TOP排名
    JavaScript完整体系
    React源码之概念篇
    (附源码)mysql anjule客户信息管理系统 毕业设计 181936
    PHP8中查询数组中指定元素-PHP8知识详解
    Python爬虫在Web应用自动化测试中的应用
    服了,攻城狮的酒后真言竟然是这些?
    谷粒学院——后台管理系统功能模块
    广州华锐互动VRAR | VR课件内容编辑器解决院校实践教学难题
  • 原文地址:https://blog.csdn.net/qq_41675812/article/details/127411512