最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue基于echarts實(shí)現(xiàn)立體柱形圖

 更新時間:2021年09月03日 13:55:29   作者:小游-523  
這篇文章主要為大家詳細(xì)介紹了vue基于echarts實(shí)現(xiàn)立體柱形圖,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們可以參考一下

立體柱形圖是由前面、右面、上面三部分組成,繪制時需要先繪制前面為一個圖形,右面和上面繪制為一個圖形,然后在echats中注冊,在option的series中renderItem中渲染

代碼如下:

(1)注冊繪制圖形

registry () {
      let MyCubeRect = this.$echarts.graphic.extendShape({
        shape: {
          x: 0,
          y: 0,
          width: 20,
          zWidth: 8,
          zHeight: 4
        },
        buildPath: function (ctx, shape) {
          const api = shape.api
          const xAxisPoint = api.coord([shape.xValue, 0])
          const p0 = [shape.x, shape.y]
          const p1 = [shape.x - shape.width / 2, shape.y]
          const p4 = [shape.x + shape.width / 2, shape.y]
          const p2 = [shape.x - shape.width / 2, xAxisPoint[1]]
          const p3 = [shape.x + shape.width / 2, xAxisPoint[1]]

          ctx.moveTo(p0[0], p0[1])
          ctx.lineTo(p1[0], p1[1])
          ctx.lineTo(p2[0], p2[1])
          ctx.lineTo(p3[0], p3[1])
          ctx.lineTo(p4[0], p4[1])
          ctx.lineTo(p0[0], p0[1])
          ctx.closePath()
        }
      })
      let MyCubeShadow = this.$echarts.graphic.extendShape({
        shape: {
          x: 0,
          y: 0,
          width: 20,
          zWidth: 8,
          zHeight: 4
        },
        buildPath: function (ctx, shape) {
          const api = shape.api
          const xAxisPoint = api.coord([shape.xValue, 0])
          const p1 = [shape.x - shape.width / 2, shape.y]
          const p4 = [shape.x + shape.width / 2, shape.y]
          const p6 = [shape.x + shape.width / 2 + shape.zWidth, shape.y - shape.zHeight]
          const p7 = [shape.x - shape.width / 2 + shape.zWidth, shape.y - shape.zHeight]
          const p3 = [shape.x + shape.width / 2, xAxisPoint[1]]
          const p5 = [shape.x + shape.width / 2 + shape.zWidth, xAxisPoint[1] - shape.zHeight]

          ctx.moveTo(p4[0], p4[1])
          ctx.lineTo(p3[0], p3[1])
          ctx.lineTo(p5[0], p5[1])
          ctx.lineTo(p6[0], p6[1])
          ctx.lineTo(p4[0], p4[1])

          ctx.moveTo(p4[0], p4[1])
          ctx.lineTo(p6[0], p6[1])
          ctx.lineTo(p7[0], p7[1])
          ctx.lineTo(p1[0], p1[1])
          ctx.lineTo(p4[0], p4[1])
          ctx.closePath()
        }
      })
      this.$echarts.graphic.registerShape('MyCubeRect', MyCubeRect)
      this.$echarts.graphic.registerShape('MyCubeShadow', MyCubeShadow)
    }

(2)渲染圖形

barChartOption: {
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'cross',
            label: {
              backgroundColor: '#6a7985'
            }
          }
        },
        grid: {
          containLabel: true,
          top: '30px',
          bottom: '0px',
          left: '0px'
        },
        xAxis: {
          type: 'category',
          axisLabel: {
            interval: 0,
            fontSize: fontSize(12)
          },
          axisLine: {
            show: false,
            lineStyle: {
              color: '#98b9c5'
            }
          },
          data: []  //通過后端傳入數(shù)據(jù)js傳入
        },
        yAxis: {
          type: 'value',
          axisLabel: {
            fontSize: fontSize(12)
          },
          axisLine: {
            show: false,
            lineStyle: {
              color: '#98b9c5'
            }
          },
          splitLine: {
            lineStyle: {
              color: '#3a586a',
              type: 'dashed'
            }
          }
        },
        series: [{
          name: '單位面積能耗',
          type: 'custom',
          renderItem: (params, api) => {
            let location = api.coord([api.value(0), api.value(1)])
            return {
              type: 'group',
              children: [{
                type: 'MyCubeRect',
                shape: {
                  api,
                  xValue: api.value(0) - 0.5,
                  yValue: api.value(1),
                  x: location[0],
                  y: location[1]
                },
                style: api.style()
              },
              {
                type: 'MyCubeShadow',
                shape: {
                  api,
                  xValue: api.value(0) - 0.5,
                  yValue: api.value(1),
                  x: location[0],
                  y: location[1]
                },
                style: {
                  fill: api.style(),
                  text: ''
                }
              }]
            }
          },
          stack: '單位面積能耗',
          label: {
            show: true,
            position: 'top',
            formatter: '{c}',
            textStyle: {
              fontSize: fontSize(12),
              color: '#fff',
              align: 'center'
            }
          },
          itemStyle: {
            color: new this.$echarts.graphic.LinearGradient(
              0, 0, 0, 1,
              [
                { offset: 0, color: '#b1950d' },
                { offset: 0.5, color: '#aea20d' },
                { offset: 1, color: '#a5aa12' }
              ]
            )
          },
          data: [] //后端傳入數(shù)據(jù)
        }]
      }

注意事項:

1)、在注冊圖形時style:只能使用 style: api.style();
text: ''后面才能使用label在圖形頂部放置value
2)、this.$echarts是經(jīng)過統(tǒng)一封裝之后的,具體情況還需具體考慮
3)、生成圖形

generateBarChart () {
      let vm = this
      if (this.$refs['uintEnergyConsume']) { //this.$refs是生成圖形區(qū)域的ref值
        this.$echarts.graphic.registerShape('MyCubeRect', this.MyCubeRect)
        this.$echarts.graphic.registerShape('MyCubeShadow', this.MyCubeShadow)
        this.barChart = this.$echarts.init(this.$refs['uintEnergyConsume'])
        this.barChart.setOption(this.barChartOption, false, true)
        $(window).resize(function () { //屏幕自適應(yīng)
          vm.handleResize()
        })
      }
    }

(4)template中代碼

<div  ref="uintEnergyConsume"  id="uintEnergyConsume"  class="chart-container" 
 style="width: 100%;"  element-loading-text="加載中..."></div>
</div>

(5)效果如下:

參考圖形網(wǎng)址:Vue使用Echarts實(shí)現(xiàn)立體柱狀圖

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Vue實(shí)現(xiàn)的父組件向子組件傳值功能示例

    Vue實(shí)現(xiàn)的父組件向子組件傳值功能示例

    這篇文章主要介紹了Vue實(shí)現(xiàn)的父組件向子組件傳值功能,結(jié)合完整實(shí)例形式簡單分析了vue.js組件傳值的相關(guān)操作技巧,需要的朋友可以參考下
    2019-01-01
  • Vue 2源碼解析HTMLParserOptions.start函數(shù)方法

    Vue 2源碼解析HTMLParserOptions.start函數(shù)方法

    這篇文章主要為大家介紹了Vue 2源碼解析HTMLParserOptions.start函數(shù)方法,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-08-08
  • Vue中使用Teleport的方法示例

    Vue中使用Teleport的方法示例

    這篇文章主要為大家介紹了Vue中使用Teleport的方法示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-08-08
  • vue組件內(nèi)部引入外部js文件的方法

    vue組件內(nèi)部引入外部js文件的方法

    這篇文章主要介紹了vue組件內(nèi)部引入外部js文件的方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-01-01
  • 在vue中使用jointjs的方法

    在vue中使用jointjs的方法

    本篇文章主要介紹了在vue中使用jointjs的方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-03-03
  • 手把手教學(xué)vue的路由權(quán)限問題

    手把手教學(xué)vue的路由權(quán)限問題

    這篇文章主要介紹了手把手教學(xué)vue的路由權(quán)限問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-12-12
  • dataV大屏在vue中的使用方式

    dataV大屏在vue中的使用方式

    這篇文章主要介紹了dataV大屏在vue中的使用方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • vue單頁面實(shí)現(xiàn)當(dāng)前頁面刷新或跳轉(zhuǎn)時提示保存

    vue單頁面實(shí)現(xiàn)當(dāng)前頁面刷新或跳轉(zhuǎn)時提示保存

    這篇文章主要介紹了vue單頁面實(shí)現(xiàn)當(dāng)前頁面刷新或跳轉(zhuǎn)時提示保存,在當(dāng)前頁面刷新或跳轉(zhuǎn)時提示保存并可取消刷新,以防止填寫的表單內(nèi)容丟失,感興趣的小伙伴們可以參考一下
    2018-11-11
  • Vue3.2.x中的小技巧及注意事項總結(jié)

    Vue3.2.x中的小技巧及注意事項總結(jié)

    Vue是一套用于構(gòu)建用戶界面的漸進(jìn)式JavaScript框架,是目前最火的前端框架之一,是前端工程師的必備技能,下面這篇文章主要給大家介紹了關(guān)于Vue3.2.x中的小技巧及注意事項的相關(guān)資料,需要的朋友可以參考下
    2022-04-04
  • Vue組件通信的幾種實(shí)現(xiàn)方法

    Vue組件通信的幾種實(shí)現(xiàn)方法

    這篇文章主要介紹了Vue組件通信的幾種實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04

最新評論

冀州市| 抚宁县| 聂荣县| 日土县| 襄垣县| 遵化市| 盱眙县| 庐江县| 松潘县| 乌拉特后旗| 东海县| 五大连池市| 安岳县| 盖州市| 乡宁县| 阳高县| 白沙| 丹棱县| 泾川县| 肥东县| 牡丹江市| 抚州市| 汝州市| 义乌市| 禄丰县| 柳州市| 琼海市| 兴和县| 阆中市| 台中县| 阳谷县| 乐亭县| 阜宁县| 五指山市| 新巴尔虎右旗| 宝山区| 广宁县| 阿瓦提县| 吉隆县| 盘锦市| 海安县|