tanyanfei 4 vuotta sitten
vanhempi
commit
bd4e01fd9c
2 muutettua tiedostoa jossa 22 lisäystä ja 112 poistoa
  1. 11 16
      pages/gameDetail/gameDetail.js
  2. 11 96
      pages/index/index.js

+ 11 - 16
pages/gameDetail/gameDetail.js

@@ -5,14 +5,7 @@ var host = app.globalData.host;
 var id, record_id;
 
 Page({
-  onShareAppMessage: function (res) {
-    return {
-      title: 'ECharts 可以在微信小程序中使用啦!',
-      path: '/pages/index/index',
-      success: function () { },
-      fail: function () { }
-    }
-  },
+
   data: {
     ec: {
       onInit: initChart
@@ -98,7 +91,8 @@ function initChart(canvas, width, height, dpr) {
           for (let i = 0; i < records.length; i++) {
             let date = records[i].stock_date.split('-');
             xdata.push(date[1] + '/' + date[2])
-            ydata.push(records[i].today_fund)
+            let y = records[i].total_income.replace('%', '')
+            ydata.push(Number(y))
           }
           xdata = xdata.reverse()
           ydata = ydata.reverse()
@@ -153,13 +147,14 @@ function initChart(canvas, width, height, dpr) {
               smooth: true,
               symbolSize: 8,
               lineStyle: {
-                color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
-                  offset: 0,
-                  color: '#FF2D68'
-                }, {
-                  offset: 1,
-                  color: '#4C4BFF'
-                }]),
+                color: '#FF2D68'
+                // color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
+                //   offset: 0,
+                //   color: '#FF2D68'
+                // }, {
+                //   offset: 1,
+                //   color: '#4C4BFF'
+                // }]),
               },
               itemStyle: {
                 borderWidth: 5,

+ 11 - 96
pages/index/index.js

@@ -78,7 +78,8 @@ Page({
         for (let i = 0; i < records.length; i++) {
           let date = records[i].stock_date.split('-');
           xdata.push(date[1] + '/' + date[2])
-          ydata.push(records[i].today_fund)
+          let y = records[i].total_income.replace('%','')
+          ydata.push(Number(y))
         }
         xdata = xdata.reverse()
         ydata = ydata.reverse()
@@ -109,99 +110,12 @@ Page({
 });
 
 
-/**折线图 */
-function initChart(canvas, width, height, dpr) {
-  wx.getStorage({
-    key: 'userInfo',
-    success: res => {
-      var info = res.data
-      wx.request({
-        url: host + '/api/wx/index',
-        header: {
-          'Authorization': info.token
-        },
-        success: res => {
-          var records = res.data.data.records, xdata=[],ydata=[];
-          for (let i = 0; i < records.length; i++) {
-            let date = records[i].stock_date.split('-');
-            xdata.push(date[1] + '/' + date[2])
-            ydata.push(records[i].today_fund+'%')
-          }
-          xdata = xdata.reverse()
-          ydata=ydata.reverse()
-          console.log(ydata)
-          const chart = echarts.init(canvas, null, {
-            width: width,
-            height: height,
-            devicePixelRatio: dpr // new
-          });
-          canvas.setChart(chart);
-          var option = {
-            legend: {
-              show: false
-            },
-            grid: {
-              x: 35,
-              y: 40,
-              x2: 10,
-              y2: 35
-            },
-            tooltip: {
-              show: true,
-              trigger: 'axis'
-            },
-            xAxis: {
-              type: 'category',
-              data: xdata,
-              axisLabel: {
-                interval: 0,
-                rotate: 40,
-                color: '#999999'
-              }
-            },
-            yAxis: {
-              axisLine: {
-                show: true
-              },
-              type: 'value',
-              name: '收益曲线',
-            },
-            series: [{
-              name: 'A',
-              type: 'line',
-              smooth: true,
-              symbolSize: 8,
-              lineStyle: {
-                color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
-                  offset: 0,
-                  color: '#FF2D68'
-                }, {
-                  offset: 1,
-                  color: '#4C4BFF'
-                }]),
-              },
-              itemStyle: {
-                borderWidth: 5,
-                borderColor: '#FFAD52',
-                color: '#FFAD52'
-              },
-              data: ydata
-            }]
-          };
 
-          chart.setOption(option);
-          return chart;
-        }
-      })
-    },
-  })
-  
-  
-}
 
 
 
 function setOption(chart, xdata, ydata) {
+  console.log(ydata)
   var option = {
     legend: {
       show: false
@@ -247,13 +161,14 @@ function setOption(chart, xdata, ydata) {
       smooth: true,
       symbolSize: 8,
       lineStyle: {
-        color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
-          offset: 0,
-          color: '#FF2D68'
-        }, {
-          offset: 1,
-          color: '#4C4BFF'
-        }]),
+        color:'#FF2D68'
+        // color: new echarts.graphic.LinearGradient(1, 0, 0, 0, [{
+        //   offset: 0,
+        //   color: '#FF2D68'
+        // }, {
+        //   offset: 1,
+        //   color: '#4C4BFF'
+        // }]),
       },
       itemStyle: {
         borderWidth: 5,