diff --git a/src/components/visualSort/index.vue b/src/components/visualSort/index.vue
index 0fc877206f467e030c61cf342619443437b0eb79..140e1492fbf330f4563511c2cc776a391c75bac3 100644
--- a/src/components/visualSort/index.vue
+++ b/src/components/visualSort/index.vue
@@ -61,6 +61,8 @@ function bubbleSort(arr) {
// 每个长方形之间的间隔
var space = 20;
+ const total=arr.reduce((p,c)=>p+c,0)
+
// 清空画布
ctx.clearRect(0, 0, canvas.width, canvas.height);
// 设置字体
@@ -70,7 +72,7 @@ function bubbleSort(arr) {
ctx.fillStyle = '#61C5FE';
// x 的 值等于 第i个长方形 * (长方形的宽+每个长方形的间隔)
// y 的 值等于 画板的高度 - 第i的元素的值
- ctx.fillRect(i * (width + space), maxWidth - arr[i], width, arr[i]);
+ ctx.fillRect(i * (width + space), maxWidth - arr[i], width, (arr[i]/total)*800);
ctx.fillStyle = '#240be4';
// maxWidth - arr[i]-5,这里多- 5,是为了能让文字,在长方形上方一点显示,看的明显些
ctx.fillText(arr[i], i * (width + space), maxWidth - arr[i] - 5);
@@ -131,7 +133,7 @@ const sortBtn = () => {
-->
-
+