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

VUE+elementui組件在table-cell單元格中繪制微型echarts圖

 更新時間:2020年04月20日 16:53:10   作者:吃三個漢堡  
這篇文章主要介紹了VUE+elementui組件在table-cell單元格中繪制微型echarts圖,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧

需求效果圖示例

實際完成效果圖

**

代碼實現(xiàn)

注:table表格為二次封裝的子組件
-在table表格中 根據(jù) scope.$index動態(tài)設置元素的id ,便于指定單元格的echarts初始化;

-在單元格中觸發(fā)一個方法,傳入當前的scope.row數(shù)據(jù)或者指定其他數(shù)據(jù),并且傳入 scope.$index 以及一個字符串便于識別當前是哪條數(shù)據(jù)的charts

-在方法中繪制echarts**

	 <el-table-column align="center">
    	 <template slot="header" slot-scope="scope">
      <div v-if="tableTitle == 'sale'">
       <p v-if="dateType != '1'">
        近{{ dateType }}天累計
        <br />
        / 日均銷量
       </p>
       <p v-if="dateType == '1'">昨日累計銷量</p>
      </div>
      <div v-if="tableTitle == 'fav'">
       <p v-if="dateType != '1'">
        近{{ dateType }}天累計
        <br />
        / 日均收藏量
       </p>
       <p v-if="dateType == '1'">昨日累計收藏</p>
      </div>
     </template>
     <div slot-scope="scope" style="white-space:nowrap;">
      <span class="xiao-red-color">{{ realRowName(scope.row, '0') || '-' }}</span>
      <span v-if="dateType != '1'" class="xiao-red-color">
       /
       {{ isNaN(realRowName(scope.row, '0')) ? '-' : (realRowName(scope.row, '0') / (parseInt(dateType) - calcShelfTime(scope.row.real_created_time, '0') &lt; 0 ? parseInt(dateType): calcShelfTime(scope.row.real_created_time, '0'))).toFixed(0)}}
      </span>
     </div>
    </el-table-column>
    <el-table-column label="每日銷量趨勢" align="center" v-if="dateType != '1'">
     <template slot-scope="scope">
      {{ drawEcharts(scope.row, scope.$index, 'sale') }}
      <div :id="`tiger-sale-trend-index` + scope.$index" class="tiger-trend-charts"></div>
     </template>
    </el-table-column>

繪制echarts的方法(數(shù)據(jù)僅為示例,實際開發(fā)根據(jù)傳進來的scope.row數(shù)據(jù))注意此處初始化echarts對象時采用VUE的this.$nextTick方法,以防獲取不到未渲染的節(jié)點元素。

drawEcharts() {
   //繪制趨勢echarts
   // console.log(arguments)
   let option = {
    tooltip: {
     trigger: 'axis'
    },
    // legend: {
    //  data: ['每日30天銷量分析']
    // },
    grid: {
     left: '10px',
     right: '30px',
     top: '40px',
     bottom: '10px',
     containLabel: true
    },
    xAxis: {
     show: false,
     type: 'category',
     boundaryGap: false,
     data: ['03-21', '03-22', '03-23', '03-24', '03-25', '03-26', '03-27']
    },
    yAxis: {
     show: false,
     type: 'value'
    },
    series: [
     {
      name: '每日30天銷量分析',
      type: 'line',
      data: [120, 500, 101, 86, 173, 230, 6]
     }
    ]
   };
   let chartId = 'tiger-' + arguments[2] + '-trend-index' + arguments[1];
   this.$nextTick(() => {
    let myChart = this.echarts.init(document.getElementById(chartId), 'macarons');
    myChart.setOption(option);
    myChart.resize();
   });
  },

AND 不要忘記設置echarts的高度,否則一輩子也出不來圖形(示例,根據(jù)實施開發(fā)調(diào)整)

&-frame {
  display: flex;
  flex-flow: column nowrap;
  justify-content: space-between;

  .price-bar {
   color: red !important;
  }
  .tiger-trend-charts {
   height: 60px;
   min-width: 100px;
  }
 }

到此這篇關于VUE+elementui組件在table-cell單元格中繪制微型echarts圖的文章就介紹到這了,更多相關VUE elementui 單元格echarts圖內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!

相關文章

最新評論

渝中区| 六枝特区| 汕头市| 临城县| 兴隆县| 河北区| 井陉县| 新竹市| 军事| 库尔勒市| 噶尔县| 遂溪县| 凤台县| 甘孜县| 探索| 游戏| 汉阴县| 滨海县| 福贡县| 衡水市| 仪陇县| 休宁县| 惠水县| 塔河县| 连江县| 永定县| 南阳市| 米林县| 辉县市| 沂南县| 荔波县| 如皋市| 阳曲县| 台北县| 吉安县| 高邮市| 宽城| 南雄市| 土默特左旗| 彰化县| 北海市|