日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長提供免費收錄網(wǎng)站服務(wù),提交前請做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

1、ehcats組件庫可自行到echats官網(wǎng)下載,下載好之后放到你的項目包里面。

下載地址:
https://Github.com/ecomfe/echarts-for-weixin

2、echarts.json 部分

首先在json文件里引入echarts組件

{ "usingComponents": { "ec-canvas": "../../ec-canvas/ec-canvas" //這里使用了相對路徑 } }

2、echarts.html 部分

<view class="contAIner">
  <ec-canvas id="mychart-dom-bar" canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>
<!-- 在這引入echarts組件標(biāo)簽 -->
</view>

這里ec-canvas綁定id就可以使用echarts組件

3、echarts.css 部分

.container{
  width: 100%; 
  height: 520rpx; 
}
.ec-canvas{
  width: 100%;
  height: 520rpx;
}

組件ec-canvas默認(rèn)寬高100%,它的寬高大小取決于它的父元素view標(biāo)簽

4、echarts.js 部分

import * as echarts from '../../ec-canvas/echarts';
// chart為圖表實例,記得要聲明為全局的
var chart = null
function initChart(canvas, width, height, dpr) {
      chart = echarts.init(canvas, null, {
      width: width,
      height: height,
      devicePixelRatio: dpr
		});
      chart.showLoading() //顯示Loading
      canvas.setChart(chart);
      var option = {
      title: {
      text: '獲取數(shù)據(jù)中',
      left: 'center'
      },
      };
      chart.setOption(option);
      return chart;
}
Page({
      data: {
      ec: {
      onInit: initChart
      }
      },
      onLoad() {},
      getData() {
          //這里是模擬的數(shù)據(jù)請求,項目中請使用wx.request替換掉setTimeouot
          setTimeout(() => {
          chart.hideLoading() //隱藏Loading
          chart.setOption({
          title: {
          text: '獲取數(shù)據(jù)完成',
          },
          legend: {
          data: ['A', 'B', 'C'],
          top: 50,
          left: 'center',
          backgroundColor: 'red',
          z: 100
          },
          grid: {
          containLabel: true
          },
          tooltip: {
          show: true,
          trigger: 'axis'
          },
          xAxis: {
          type: 'category',
          boundaryGap: false,
          data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
          // show: false
          },
          yAxis: {
          x: 'center',
          type: 'value',
          splitLine: {
          lineStyle: {
          type: 'dashed'
          }
          }
          // show: false
          },
          series: [{
          name: 'A',
          type: 'line',
          smooth: true,
          data: [18, 36, 65, 30, 78, 40, 33]
          }, {
          name: 'B',
          type: 'line',
          smooth: true,
          data: [12, 50, 51, 35, 70, 30, 20]
          }, {
          name: 'C',
          type: 'line',
          smooth: true,
          data: [10, 30, 31, 50, 40, 20, 10]
          }]
          })
      }, 1000);
},
   /**
   * 生命周期函數(shù)--監(jiān)聽頁面初次渲染完成  根據(jù)項目需求在不同周期調(diào)用
   */
  onReady() {
    //獲取數(shù)據(jù)
    this.getData()
    },
});

5、最終的效果圖如下:

 

6、最后總結(jié)一下JS思路,首先import引入echats組件庫,在data中定義好key,然后進(jìn)行echats的初始化,在初始化中需要echats組件的配置信息(在echats官網(wǎng)示例里找),最后在生命周期函數(shù)中進(jìn)行初始化函數(shù)的調(diào)用,把必要的參數(shù)傳進(jìn)去就可以出效果了。

分享到:
標(biāo)簽:程序
用戶無頭像

網(wǎng)友整理

注冊時間:

網(wǎng)站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨大挑戰(zhàn)2018-06-03

數(shù)獨一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學(xué)四六

運動步數(shù)有氧達(dá)人2018-06-03

記錄運動步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績評定2018-06-03

通用課目體育訓(xùn)練成績評定