liyongli 3 years ago
parent
commit
60b495839e
1 changed files with 22 additions and 6 deletions
  1. 22 6
      src/components/maincomponents.vue

+ 22 - 6
src/components/maincomponents.vue

@@ -75,7 +75,13 @@
           </el-button>
         </el-button-group>
       </div>
-      <canvas id="barChart" v-if="heightBar > 0" :height="heightBar" style="width: 100%" class=""></canvas>
+      <canvas
+        id="barChart"
+        v-if="heightBar > 0"
+        :height="heightBar"
+        style="width: 100%"
+        class=""
+      ></canvas>
     </div>
 
     <div class="card">
@@ -197,7 +203,7 @@ export default {
       usertotal: 0,
       height: 0,
       c: ["#FB6161", "#EC72DC", "#F98E53", "#49BED0", "#4BCA8B"],
-      heightBar: 0
+      heightBar: 0,
     };
   },
   filters: {
@@ -340,10 +346,9 @@ export default {
         title: this.topic,
       }).then(r => {
         let li = (r || []).reverse();
-        console.log(li)
         this.heightBar = li.length ? li.length * 35 + 40 : 0;
         localStorage.type = this.type;
-        if(this.heightBar === 0) return
+        if (this.heightBar === 0) return;
         this.$nextTick(() => {
           this.bar1(li);
         });
@@ -370,12 +375,23 @@ export default {
       });
       linechart.source(li, {
         dt: {
-          tickCount: 3,
+          tickCount: 5,
         },
         playCount: {
           tickCount: 5,
         },
       });
+      linechart.axis("dt", {
+        label: function label(text, index, total) {
+          const textCfg = {};
+          if (index === 0) {
+            textCfg.textAlign = "left";
+          } else if (index === total - 1) {
+            textCfg.textAlign = "right";
+          }
+          return textCfg;
+        },
+      });
       linechart.scale("playCount", {
         formatter(text) {
           return that.numform(text);
@@ -416,7 +432,7 @@ export default {
         id: "barChart",
         pixelRatio: window.devicePixelRatio,
         padding: [10, 50, 30, 140],
-        height: this.heightBar
+        height: this.heightBar,
       });
 
       barchart.source(li, {