diff --git a/components/sleep-list-data/sleep-list-data.vue b/components/sleep-list-data/sleep-list-data.vue index 993b563..e215ec6 100644 --- a/components/sleep-list-data/sleep-list-data.vue +++ b/components/sleep-list-data/sleep-list-data.vue @@ -36,6 +36,7 @@ }, methods:{ doDraw(canvasWidth){ + console.log(canvasWidth) const colorArr = [ '#e933dd', '#6452da', @@ -49,7 +50,8 @@ let current = 0; let times = 0; // 计算出每个线条的宽度 - const oneLineWidth = (this.dataList.length / canvasWidth).toFixed(2) + const oneLineWidth = (canvasWidth / this.dataList.length).toFixed(2) + console.log(oneLineWidth) const ctx = uni.createCanvasContext(this.canvasId, this); // 设置填充颜色为红色 this.dataList.map((v,i) => { @@ -59,6 +61,7 @@ ctx.setFillStyle(colorArr[parseInt(v)]); // 绘制矩形 ctx.fillRect((i * oneLineWidth).toFixed(2), heightArr[parseInt(v)],oneLineWidth, 20); + console.log((i * oneLineWidth).toFixed(2)) // current = v; // times = 1 // } diff --git a/unpackage/dist/build/web/index.html b/unpackage/dist/build/web/index.html index fd7ad15..d36cc3e 100644 --- a/unpackage/dist/build/web/index.html +++ b/unpackage/dist/build/web/index.html @@ -1,2 +1,2 @@