91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

vue+echarts怎么實現3D柱形圖

發布時間:2022-04-02 13:46:14 來源:億速云 閱讀:1004 作者:iii 欄目:開發技術

這篇文章主要介紹了vue+echarts怎么實現3D柱形圖的相關知識,內容詳細易懂,操作簡單快捷,具有一定借鑒價值,相信大家閱讀完這篇vue+echarts怎么實現3D柱形圖文章都會有所收獲,下面我們一起來看看吧。

效果如下:

vue+echarts怎么實現3D柱形圖

1、安裝echarts

npm install echarts --save

2、引入echarts

import echarts from "echarts";
//修改原型鏈,可在全局使用
Vue.prototype.$echarts = echarts;

3、創建圖表 首先需要在 HTML 中創建圖表的容器

<div id="echarts_park"></div>
     //圖表的容器必須指定寬高
     #echarts_park {
         width: 400px;
         height: 200px;
}

4、渲染圖表

mounted() {
    this.drawPark();
  },
  methods: {
    drawPark() {
        //初始化echarts
      let myChart = this.$echarts.init(document.getElementById("echarts_park"));
      let num= [
        "12",
        "12",
        "12",
        "14",
        "12",
        "12",
        "12",
        "14",
        "12",
        "12",
        "12",
      ];
      let xData = [
        "杭州市",
        "杭州市",
        "杭州市",
        "杭州市",
        "杭州市",
        "杭州市",
        "杭州市",
        "杭州市",
        "杭州市",
        "杭州市",
        "杭州市",
      ];
      var colors = [
        {
          type: "linear",
          x: 0,
          x2: 1,
          y: 0,
          y2: 0,
          colorStops: [
            {
              offset: 0,
              color: "#0088F1",
            },
            {
              offset: 1,
              color: "#00D1FF",
            },
          ],
        },
        {
          type: "linear",
          x: 0,
          x2: 0,
          y: 0,
          y2: 1,
          colorStops: [
            {
              offset: 0,
              color: "#67D0FF",
            },
            {
              offset: 1,
              color: "#3486DA",
            },
          ],
        },
      ];
      var barWidth = 18;
      // 繪制圖表
      myChart.setOption({
        tooltip: {
          trigger: "axis",
          axisPointer: {
            // 坐標軸指示器,坐標軸觸發有效
            type: "shadow", // 默認為直線,可選為:'line' | 'shadow'
          },
          formatter: function (params) {
            var tipString = params[0].axisValue + "<br />";
            var key = "value";
            params.sort(function (obj1, obj2) {
              var val1 = obj1[key];
              var val2 = obj2[key];
              if (val1 < val2) {
                return 1;
              } else if (val1 > val2) {
                return -1;
              } else {
                return 0;
              }
            });
            var indexColor;
            for (var i = 0, length = params.length; i < length; i++) {
              if (params[i].componentSubType == "bar") {
                indexColor = params[i + 1].color;
                tipString +=
                  '<span style="display:inline-block;margin-right:5px;border-radius:10px;width:9px;height:9px;background:' +
                  indexColor +
                  '"></span>';
                tipString +=
                  '<span data-type ="lineTip" data-val=' +
                  params[i].value +
                  ">" +
                  params[i].seriesName +
                  ":" +
                  params[i].value +
                  "</span><br />";
              }
            }
            return tipString;
          },
        },
        grid: {
          left: "3%",
          right: "3%",
          bottom: "6%",
          top: "20%",
          containLabel: true,
        },
        xAxis: {
          type: "category",
          data: xData,
          offset: 6,
          axisLine: { lineStyle: { color: " #CCCCCC" } },
          axisTick: {
            alignWithLabel: true,
          },
          axisLabel: {
            interval: 0,
            // rotate: 20,
            textStyle: {
              color: "#000",
              fontStyle: "normal",
              fontFamily: "微軟雅黑",
              fontSize: 13,
              margin: 10,
            },
          },
        },

        yAxis: {
          type: "value",
          name: "(%)",
          nameTextStyle: {
            align: "right",
            color: "#4D4D4D",
          },
          axisLine: {
            show: false,
            lineStyle: { color: "#CCCCCC" },
          },
          axisTick: { show: false },
          splitLine: {
            show: true,
            lineStyle: { type: "dashed", color: "#CCCCCC" },
          },
          axisLabel: {
            textStyle: {
              color: "#4D4D4D",
              fontSize: 14,
            },
          },
        },
        series: [
          {
            name: "2020",
            type: "bar",
            barGap: "14%",
            barWidth: 18,
            itemStyle: {
              normal: {
                color: colors[1],
                barBorderRadius: 0,
              },
            },
            data: num,
          },
          {
            z: 2,
            name: "2020",
            type: "pictorialBar",
            data: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
            symbol: "diamond",
            symbolOffset: ["0%", "50%"],
            symbolSize: [barWidth, 10],
            itemStyle: {
              normal: {
                color: colors[1],
              },
            },
          },
          {
            z: 3,
            name: "2020",
            type: "pictorialBar",
            symbolPosition: "end",
            data: qichu,
            symbol: "diamond",
            symbolOffset: ["0%", "-50%"],
            symbolSize: [barWidth, (10 * (barWidth - 1)) / barWidth],
            itemStyle: {
              normal: {
                borderColor: "#67D0FF",
                borderWidth: 2,
                color: "#67D0FF",
              },
            },
          },
        ],
      });
    },
},

關于“vue+echarts怎么實現3D柱形圖”這篇文章的內容就介紹到這里,感謝各位的閱讀!相信大家對“vue+echarts怎么實現3D柱形圖”知識都有一定的了解,大家如果還想學習更多知識,歡迎關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

穆棱市| 铅山县| 汾西县| 扶余县| 渭源县| 祥云县| 商洛市| 刚察县| 都匀市| 商丘市| 铜山县| 庆安县| 杭州市| 乐东| 白河县| 枣强县| 新野县| 平罗县| 益阳市| 遂昌县| 合阳县| 鄂尔多斯市| 许昌县| 纳雍县| 恩平市| 榆树市| 扬州市| 咸宁市| 湘阴县| 上思县| 榆中县| 黑龙江省| 界首市| 珲春市| 晋江市| 辽宁省| 锡林浩特市| 安化县| 三门峡市| 德庆县| 庄河市|