tanyanfei 4 anos atrás
pai
commit
505a91006c
1 arquivos alterados com 15 adições e 3 exclusões
  1. 15 3
      pages/index/index.js

+ 15 - 3
pages/index/index.js

@@ -125,10 +125,11 @@ 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)
+            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,
@@ -206,14 +207,15 @@ function setOption(chart, xdata, ydata) {
       show: false
     },
     grid: {
-      x: 35,
+      x: 50,
       y: 40,
       x2: 10,
       y2: 35
     },
     tooltip: {
       show: true,
-      trigger: 'axis'
+      trigger: 'axis',
+      formatter: '{b0}: {c0}%'
     },
     xAxis: {
       type: 'category',
@@ -230,6 +232,16 @@ function setOption(chart, xdata, ydata) {
       },
       type: 'value',
       name: '收益曲线',
+      axisLabel: {
+        formatter: function (value, index) {//隐藏 0
+          let texts = [];
+          texts.push(value+'%')
+          return texts;
+        },
+        show: true,
+        interval: 0,
+        // rotate: 40,
+      },
     },
     series: [{
       name: 'A',